Home > php教程 > php手册 > body text

织梦之GB码转换成Big5码

WBOY
Release: 2016-06-21 08:58:10
Original
920 people have browsed it

转换

/********************************
//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;
}



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template