(注:源代碼中的include "data_big5.php";這個文件 " /> 亚洲av毛片一级二级在线,欧美国产精品一区,国产一级片

中文字幕日韩一区二区_国产一区二区av_国产毛片av_久久久久国产一区_色婷婷电影_国产一区二区精品

繁體中文轉換為簡體中文的PHP函數

前幾天我在oso論壇上問有沒有這個源程序,沒人回復。終于下定決心移植一個這樣的函數,感謝網友Keyes提供移植用的Delphi源代碼。其調用方式為$txt=big5togb($txt)。
    (注:源代碼中的include "data_big5.php";這個文件在就是一個數組,在http://caocao.oso.com.cn/data_big5.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 isbig5($code)
{
  if (strlen($code)>=2)
  {
    $code=strtok($code,"");

    if (ord($code[0]) < 161)
    {
      return (0);
    }
    else
    {
      if (((ord($code[1]) >= 64)&&(ord($code[1]) <= 126))||((ord($code[1]) >= 161)&&(ord($code[1]) <= 254)))
      {
        return (1);
      }
      else
      {
        return (0);
      }
    }
  }
  else
  {
    return (0);
  }
}

function big5offset($code)
{
  if (strlen($code) >= 2)
  {
    $code=strtok($code,"");
    if ((ord($code[1]) >= 64)&&(ord($code[1]) <= 126))
    {
      return ((ord($code[0]) - 161) * 157 + (ord($code[1]) - 64));
    }
    if ((ord($code[1]) >= 161)&&(ord($code[1]) <= 254))
    {
      return ((ord($code[0]) - 161) * 157 + 63 + (ord($code[1]) - 161));
    }
  }
  return (-1);
}

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

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

    if (isbig5($tmpStr))
    {
      $offset=big5offset($tmpStr);
      if (($offset >= 0)||($offset <= 14757))
      {
        $output.=wordtostring($big5order[$offset]);
        $idx++;
      }
      else
      {
        $output.= $code[$idx];
      }
    }
    else
    {
      $output.= $code[$idx];
    }
    $idx++;
  }
  return ($output);
}
?>  

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

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

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

主站蜘蛛池模板: av国产精品毛片一区二区小说 | 不卡视频在线 | 福利视频一区二区 | 国产在线拍偷自揄拍视频 | 1000部精品久久久久久久久 | 日韩欧美国产一区二区三区 | 欧美视频在线看 | 韩日一区二区 | 91手机精品视频 | 亚洲三区在线观看 | 日日操天天射 | 国产精品国产三级国产aⅴ中文 | 黄色网页在线 | 亚洲视频免费观看 | 亚洲导航深夜福利涩涩屋 | 国产高清在线精品一区二区三区 | 欧美一级大片免费观看 | 免费观看成人鲁鲁鲁鲁鲁视频 | 日本午夜精品一区二区三区 | 日本在线播放一区二区 | 久久综合一区二区三区 | 日韩精品一区二区三区四区视频 | av网站在线播放 | 国产精品久久二区 | 天天插天天干 | 欧美专区在线 | 成人午夜网站 | 日日操夜夜操天天操 | 欧美福利在线 | 久久久久无码国产精品一区 | 欧美激情综合色综合啪啪五月 | 高清一区二区三区 | 亚洲高清一区二区三区 | 国产精品永久免费视频 | av电影手机在线看 | 国产精品九九 | 欧美亚洲综合久久 | 九九色综合 | 中文字幕人成乱码在线观看 | 婷婷久久综合 | 黄色一级大片视频 |