Home > php教程 > php手册 > php各种编码转换实现代码(1/6)

php各种编码转换实现代码(1/6)

WBOY
Release: 2016-05-25 16:57:16
Original
861 people have browsed it
我们提供了几种编码转换如有UTF-8 转GB编码 GB转UTF-8编码 Unicode转utf8 unicode url编码转gbk编码函数 GB码转换成Big5码 Big5码转换成GB码 utf8转Unicode等哦。
$uc2gbtable = $codetable = $big5_data = $gb_data = '';
$gbkunidic = null;
//utf-8 转gb编码
function utf82gb($utfstr)
{
 if(function_exists('iconv'))
 {
  return iconv('utf-8','gbk//ignore',$utfstr);
 }
 global $uc2gbtable;
 $okstr = "";
 if(trim($utfstr)=="")
 {
  return $utfstr;
 }
 if(empty($uc2gbtable))
 {
  $filename = dedeinc."/data/gb2312-utf8.dat";
  $fp = fopen($filename,"r");
  while($l = fgets($fp,15))
  {
   $uc2gbtable[hexdec(substr($l, 7, 6))] = hexdec(substr($l, 0, 6));
  }
  fclose($fp);
 }
 $okstr = "";
 $ulen = strlen($utfstr);
 for($i=0;$i<p> </p><p></p><div class="mupage">首页 1 2 3 4 5 6 末页</div><div class="ad_580" id="ad_580"></div> <p>永久链接:</p><p>转载随意!带上文章地址吧。</p> 
Copy after login
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