/**********************************
//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;
}
新闻热点
疑难解答