龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php gb2312转big5 函数

时间:2014-07-19 02:09来源:网络整理 作者:网络 点击:
分享到:
php gb2312转big5 函数 [代码片段(20行)]
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;
}
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接