(注:源代碼中的include "data_big5.php";這個文件 " /> 久久夜夜视频,毛片在线网站,欧美高清hd18日本

一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

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

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

主站蜘蛛池模板: 精品日韩欧美一区二区三区 | 日韩精品第1页 | 色天使色护士 在线视频观看 | 97人洗澡从澡人人爽人人模 | 污片在线看 | 国产成人亚洲综合 | 亚欧免费视频一区二区三区 | 亚洲乱码在线观看 | 久久亚洲伊人 | 久久91精品国产91久久小草 | 国产一区二区视频免费 | 国产二级毛片 | 亚洲综合在线最大成人 | 欧美日韩国产亚洲综合不卡 | 国产激爽大片在线播放 | 亚洲欧美精品 | 久久精品久久久久久久久人 | 婷婷综合久久 | 97高清国语自产拍中国大陆 | 精品午夜久久网成年网 | 国产美女精品一区二区三区 | 久久免费区一区二区三波多野 | 日韩午夜激情视频 | 国产熟睡乱子伦视频 | 伊人青青草 | 色综合久久六月婷婷中文字幕 | 久久66久这里精品99 | 久久亚洲国产成人亚 | 在线亚洲精品国产成人二区 | 色毛片| 国产婷婷一区二区在线观看 | 九色国产在线 | 91在线视频导航 | 性欧美xxxx视频在线观看 | 最新精品视频在线观看 | 色wwwwww| 国产精品免费_区二区三区观看 | 色综合久久88色综合天天提莫 | 青青热久| 国产精品久久久久久久成人午夜 | 四虎影视国产精品一区二区 |