到满多网站都有即时简繁切换的功能,只是都不见有人提供做法,因 此我也写了一段转换程式,给有需要的人参考:
以下程式所用的table档是a4chinese的big5-gb.table,其版权为a4chinese作者所有;PHP程式码部分则可自由修改应用,唯不得出售营利..^^
<br>1.先取得big5-gb.table档,你可在文章下面的链接找到.<br>2.加入下列PHP程式码:<br><font color="#000080"><br>function <font color="#007a00">big52gb</font>(<font color="#900000">$Text</font>){<br><font color="#900000">$fp</font> = <font color="#007a00">fopen</font>("big5-gb.table", "r");<br><font color="#900000">$max</font>=<font color="#007a00">strlen</font>(<font color="#900000">$Text</font>)-1;<br><font color="#007a00">for</font>(<font color="#900000">$i</font>=0;<font color="#900000">$i</font>$max</font>;<font color="#900000">$i</font>++){<br><font color="#900000">$h</font>=<font color="#007a00">ord</font>(<font color="#900000">$Text</font>[<font color="#900000">$i</font>]);<br><font color="#007a00">if</font>(<font color="#900000">$h</font>>=160){<br><font color="#900000">$l</font>=<font color="#007a00">ord</font>(<font color="#900000">$Text</font>[<font color="#900000">$i</font>+1]);<br><font color="#007a00">if</font>(<font color="#900000">$h</font>==161 && <font color="#900000">$l</font>==64){<br><font color="#900000">$gb</font>=" ";<br>}<font color="#007a00">else</font>{<br><font color="#007a00">fseek</font>(<font color="#900000">$fp</font>,(<font color="#900000">$h</font>-160)*510+(<font color="#900000">$l</font>-1)*2); <br><font color="#900000">$gb</font>=<font color="#007a00">fread</font>(<font color="#900000">$fp</font>,2); <br>}<br><font color="#900000">$Text</font>[<font color="#900000">$i</font>]=<font color="#900000">$gb</font>[0];<br><font color="#900000">$Text</font>[<font color="#900000">$i</font>+1]=<font color="#900000">$gb</font>[1];<br><font color="#900000">$i</font>++;<br>}<br>}<br><font color="#007a00">fclose</font>(<font color="#900000">$fp</font>);<br>return <font color="#900000">$Text</font>;<br>}<br><br>
3.接著就可以用了
$a="繁体转简体";
$a=big52gb($a);
以上程式码是最简单的方法,也就是一个一个翻,至於速度 还可以,若要快点,那就要改写一下方法了(我不是用这种方法,不过因为我的方法还在测试中,还不知稳不稳定, 所以暂时没写出来)...^^
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Where to find the Crane Control Keycard in Atomfall
3 weeks agoByDDD
Saving in R.E.P.O. Explained (And Save Files)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.