(注:源代碼中的include "data_gb.php";這個文件在就是一個數(shù)組,在http://caocao.oso.com.cn/data_gb.zip,請編輯下載到oso上,做一個鏈接, " /> 亚洲综合精品,久久国产主播,成人啪啪免费看

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

簡體中文轉換為繁體中文的PHP函數(shù)

感謝網(wǎng)友Keyes提供移植用的Delphi源代碼。其調用方式為$txt=gbtobig5($txt)。
    (注:源代碼中的include "data_gb.php";這個文件在就是一個數(shù)組,在http://caocao.oso.com.cn/data_gb.zip,請編輯下載到oso上,做一個鏈接,因為這個文件我過幾天就要刪除了。)

<?
/***********************************************************************
                       Written by caocao
                       caocao@eastday.com
                       http://caocao.oso.com.cn

                       With the help of Keyes
                       Keyes2000@263.NET
                       http://my-wjl.scu.edu.cn/~Keyes
***********************************************************************/
function isgb($code)
{
  if (strlen($code)>=2)
  {
    $code=strtok($code,"");
    if ((ord($code[0]) < 161)||(ord($code[0]) >= 247))
    {
      return (0);
    }
    else
    {
      if ((ord($code[1]) <= 161)||(ord($code[1]) >= 254))
      {
        return (0);
      }
      else
      {
        return (1);
      }
    }
  }
  else
  {
    return (1);
  }
}

function gboffset($code)
{
  if (strlen($code) >= 2)
  {
    $code=strtok($code,"");
    return ((ord($code[0]) - 161) * 94 + (ord($code[1]) - 161));
  }
  else
  {
    return(-1);
  }
}

function wordtostring($code)
{
  return (chr(hexdec(substr($code,0,2))).chr(hexdec(substr($code,2,2))));
}

function gbtobig5($code)
{
  include "data_gb.php";
  $output="";
  $length=strlen($code);
  $code=strtok($code,"");
  $idx=0;
  while ($idx < $length)
  {
    $tmpStr=$code[$idx].$code[$idx+1];

    if (isgb($tmpStr))
    {
      $offset=gboffset($tmpStr);
      if (($offset >= 0)||($offset <= 8177))
      {
        $output.=wordtostring($gborder[$offset]);
        $idx++;
      }
      else
      {
        $output.= $code[$idx];
      }
    }
    else
    {
      $output.= $code[$idx];
    }
    $idx++;
  }
  return ($output);
};
?>  

【本文版權歸作者與奧索網(wǎng)共同擁有,如需轉載,請注明作者及出處】    

php技術簡體中文轉換為繁體中文的PHP函數(shù),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 东丰县| 遵化市| 通海县| 独山县| 民和| 巴中市| 内丘县| 镇原县| 石嘴山市| 遂川县| 壶关县| 沂南县| 蓬莱市| 定远县| 会宁县| 弋阳县| 治县。| 塔城市| 乌审旗| 镇宁| 昌黎县| 晋宁县| 长沙县| 积石山| 马关县| 扬中市| 广安市| 和林格尔县| 永州市| 嘉义县| 滕州市| 铅山县| 铜陵市| 梁平县| 武冈市| 达拉特旗| 甘孜县| 中阳县| 枣庄市| 昌黎县| 铜梁县|