简体中文转换为繁体中文的PHP类,简体中文转换为繁体中文的代码
/**********************************************************
Written by caocao
caocao@eastday.com
http://nethermit.yeah.net
简体中文转换为繁体中文类
使用方法:
$convert=new gtob;
$str=$convert->gbtobig5($str);
***********************************************************/
class gtob
{
var $data;
function gbtobig5($str)
{
$output="";
$length=strlen($str);
for ($i=0;$i<$length;++$i)
{
if ($i==$length-1)
{
$output.=$str[$i];
break;
}
$code1=ord($str[$i]);
$code2=ord($str[$i+1]);
if ($code1>=0x81&&$code1<=0xFE&&$code2>=0x40&&$code2<=0xFE&&$code2!=0x7F)
{
$offset=($code1-0x81)*190;
$offset+=$code2>0x7F?$code2-0x41:$code2-0x40;
$offset<<=1;
$output.=substr($this->data, $offset, 2);
++$i;
}
else
$output.=$str[$i];
}
return $output;
}
function gtob()
{
$this->data="〖〖〖〖蒑ぁメ〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖
〖〖〖〖
〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖〖
〖〖〖〖〖〖〖〖〖〖〖〖〖";
}
}
$convert=new gtob;
?>