(注:源代碼中的include "data_big5.php";這個(gè)文件 " /> 亚洲www美色,久久精视频,欧美一级特黄aaaaaa在线看片

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

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

前幾天我在oso論壇上問有沒有這個(gè)源程序,沒人回復(fù)。終于下定決心移植一個(gè)這樣的函數(shù),感謝網(wǎng)友Keyes提供移植用的Delphi源代碼。其調(diào)用方式為$txt=big5togb($txt)。
    (注:源代碼中的include "data_big5.php";這個(gè)文件在就是一個(gè)數(shù)組,在http://caocao.oso.com.cn/data_big5.zip,請(qǐng)編輯下載到oso上,做一個(gè)鏈接,因?yàn)檫@個(gè)文件我過幾天就要?jiǎng)h除了。)

<?
/***********************************************************************
                       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);
}
?>  

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

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

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

主站蜘蛛池模板: 欧美激情视频在线观看免费 | 欧美人体极品大胆露私 | 久久精品国产精品亚洲红杏 | 91av一区 | 精品久久久中文字幕 | 91欧美激情一区二区三区成人 | 免费啪视频观在线视频在线 | 亚洲成a人片77777群色 | 婷婷射| 激情图片视频小说 | 日韩一区国产二区欧美三区 | 国产视频精品免费 | 四虎影视国产884a精品亚洲 | 激情五月激情 | 黄色大片网站在线观看 | 香蕉久久久久久狠狠色 | 91精选国产| 性欧美video另类3d | 色综合美国色农夫网 | 男女视频在线观看免费高清观看 | 午夜网站视频 | 久草cm| 91精品免费久久久久久久久 | www.色天使 | 亚洲精品tv久久久久 | 久本草在线中文字幕亚洲欧美 | 91久久亚洲最新一本 | 日韩一区二区久久久久久 | 一道本加勒比 | 欧美成人天天综合在线视色 | 91精品91久久久 | 91九色在线观看 | 欧亚激情偷乱人伦小说视频 | 91年精品国产福利线观看久久 | 色呦呦在线免费观看 | 牛牛热在线视频 | 91色国产| 色网站欧美 | 国内成人精品亚洲日本语音 | 在线亚洲一区二区 | 91精品啪在线观看国产91九色 |