国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

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

瀏覽:2日期:2024-01-01 17:01:15
前幾天我在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
主站蜘蛛池模板: 佳木斯市| 浦北县| 资阳市| 玉田县| 柯坪县| 广昌县| 津市市| 平顶山市| 合山市| 巨野县| 乌苏市| 大荔县| 楚雄市| 乐昌市| 贡觉县| 潮州市| 门头沟区| 昭平县| 曲水县| 阿拉善左旗| 洪泽县| 永城市| 井研县| 湟中县| 高阳县| 高尔夫| 息烽县| 修武县| 枣阳市| 东港市| 九龙城区| 铜川市| 惠安县| 镇远县| 巴彦县| 永新县| 南郑县| 青海省| 唐山市| 襄汾县| 石楼县|