欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php gb2312转big5 函数

程序员文章站 2024-02-04 11:57:04
...

[PHP]代码

function GB2312toBIG5($c) {
$f = fopen(CODETABLE_DIR.$this->config['GBtoBIG5_table'], ‘r’);
$max=strlen($c)-1;
for($i = 0;$i < $max;$i++){ $h=ord($c[$i]); if($h>=160) {
$l=ord($c[$i+1]);
if($h==161 && $l==64){
$gb=” “;
} else{
fseek($f,($h-160)*510+($l-1)*2);
$gb=fread($f,2);
}
$c[$i]=$gb[0];
$c[$i+1]=$gb[1];
$i++;
}
}
$result = $c;
return $result;
}
相关标签: php