织梦之GB码转换成Big5码
程序员文章站
2022-05-10 09:28:01
...
转换
/********************************
//GB码转换成Big5码
*********************************/
function gb2big5($Text) {
global $GB_DATA;
if(empty($GB_DATA)){
$filename = dirname(__FILE__)."/data/gb-big5.table";
$fp = fopen($filename, "rb");
$gb = fread($fp,filesize($filename));
fclose($fp);
}
$max = strlen($Text)-1;
for($i=0;$i $h = ord($Text[$i]);
if($h>=0x80) {
$l = ord($Text[$i+1]);
if($h==161 && $l==64) {
$big = " ";
}else{
$p = ($h-160)*510+($l-1)*2;
$big = $GB_DATA[$p].$GB_DATA[$p+1];
}
$Text[$i] = $big[0];
$Text[$i+1] = $big[1];
$i++;
}
}
return $Text;
}
推荐阅读