(注:源代碼中的include "data_big5.php";這個文件 " /> 青草青草,日韩午夜一区,成人三级做爰av

四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

繁體中文轉換為簡體中文的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函數,轉載需保留來源!

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

主站蜘蛛池模板: 朝雪录电视剧免费观看全集完整版 | 诱惑的艺术| 托比·琼斯| derpixon动画在线观看| 那些女人演员表全部名单| 卡通频道| 十一码复式22块钱中奖对照表| 我的英雄学院第三季| 一夜风流| 猛鬼追魂| 悦时光电影完整版免费观看| 散文诗二首批注| 范艳华| | 电视剧暗夜与黎明剧情介绍| 必修二英语电子课本外研版| 心动电影| 露底| 隐形人4| 柳濑早纪| 伊人1314| 闵智贤| 电影《天启》| 七度空间卫生巾图片| 侠侣探案| 《起风了》数字简谱| 少妇荡乳情欲办公室| lol小孩子不能看的动画视频| 都市频道节目表| 新红楼梦电影| 小舞泳装比基尼套装图片| 维罗尼卡| 说木叶原文| 卜算子咏梅拼音| 魔1983| 西部往事 电影| 极度俏郎君 电视剧| 山东教育电视台直播| 电影《复仇女巫》| 粤韵风华| 二年级上古诗26首打印|