日期:2013-04-23 浏览次数:20406 次
/**********************************
//Big5码转换成GB码
**********************************/
function big52gb($Text) {
global $BIG5_DATA;
if(empty($BIG5_DATA)){
$filename = dirname(__FILE__)."/data/big5-gb.table";
$fp = fopen($filename, "rb");
$BIG5_DATA = fread($fp,filesize($filename));
fclose($fp);
}
$max = strlen($Text)-1;
for($i=0;$i<$max;$i++) {
$h = ord($Text[$i]);
if($h>=0x80) {
$l = ord($Text[$i+1]);
if($h==161 && $l==64) {
$gbstr = " ";
}else{
$p = ($h-160)*510+($l-1)*2;
$gbstr = $BIG5_DATA[$p].$BIG5_DATA[$p+1];
}
$Text[$i] = $gbstr[0];
$Text[$i+1] = $gbstr[1];
$i++;
}
}
return $Text;
}