最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2006年10月09日 00:00:00   作者:  
前幾天我在oso論壇上問有沒有這個源程序,沒人回復。終于下定決心移植一個這樣的函數(shù),感謝網(wǎng)友Keyes提供移植用的Delphi源代碼。其調(diào)用方式為$txt=big5togb($txt)。
    (注:源代碼中的include "data_big5.php";這個文件在就是一個數(shù)組,在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);
}
?>  

【本文版權歸作者與奧索網(wǎng)共同擁有,如需轉(zhuǎn)載,請注明作者及出處】    
  • 基于文本的訪客簽到簿

    基于文本的訪客簽到簿

    基于文本的訪客簽到簿...
    2006-10-10
  • 使用網(wǎng)絡地址轉(zhuǎn)換實現(xiàn)多服務器負載均衡

    使用網(wǎng)絡地址轉(zhuǎn)換實現(xiàn)多服務器負載均衡

    使用網(wǎng)絡地址轉(zhuǎn)換實現(xiàn)多服務器負載均衡...
    2006-10-10
  • 利用PHP創(chuàng)建動態(tài)圖像

    利用PHP創(chuàng)建動態(tài)圖像

    利用PHP創(chuàng)建動態(tài)圖像...
    2006-10-10
  • 將RTF格式的文件轉(zhuǎn)成HTML并在網(wǎng)頁中顯示的代碼

    將RTF格式的文件轉(zhuǎn)成HTML并在網(wǎng)頁中顯示的代碼

    將RTF格式的文件轉(zhuǎn)成HTML并在網(wǎng)頁中顯示的代碼...
    2006-10-10
  • php 刪除cookie和瀏覽器重定向

    php 刪除cookie和瀏覽器重定向

    php cookies刪除和瀏覽器重定向?qū)崿F(xiàn)代碼
    2009-03-03
  • PHP5 安裝方法

    PHP5 安裝方法

    PHP5 安裝方法...
    2007-01-01
  • php代碼優(yōu)化及php相關問題總結(jié)

    php代碼優(yōu)化及php相關問題總結(jié)

    php代碼優(yōu)化及php相關問題總結(jié)...
    2006-10-10
  • 自動跳轉(zhuǎn)中英文頁面

    自動跳轉(zhuǎn)中英文頁面

    自動跳轉(zhuǎn)中英文頁面...
    2006-10-10
  • 最新評論

    大英县| 瑞金市| 延川县| 麦盖提县| 乌审旗| 婺源县| 汉寿县| 夹江县| 曲阳县| 云南省| 岗巴县| 海伦市| 长武县| 太谷县| 马公市| 永新县| 二手房| 安阳市| 黄冈市| 综艺| 鄂尔多斯市| 上犹县| 长顺县| 溆浦县| 科技| 枞阳县| 永胜县| 阜新| 庆元县| 井冈山市| 宜良县| 昌邑市| 建瓯市| 漳平市| 龙胜| 万山特区| 武夷山市| 噶尔县| 宁乡县| 瑞昌市| 图木舒克市|