Class_PHP tutorial for conversion from Simplified to Traditional Chinese
WBOYOriginal
2016-07-21 16:01:51803browse
This is a class packaged in Simplified and Traditional Chinese. Another two table files are needed: 1. http://www.jerry.com.tw/php/big5.map 2. http://www.jerry.com.tw/php/gb.map The program is as follows: CCharset.php3
//============= ======================================== // Programmer: Magic Jerry // // function Big5_Gb($str) => big5 to GB for string // function Gb_Big5($str) => GB to Big5 for string //== ================================================== = class CCharset {
var $gb_map="gb.map"; //If you want to put it in another path, add the complete path var $big5_map="big5.map" ; //For example="/home/table/gb.map
var $dep_char = 127;
//------------- -------------------------------------------------- -- function cbig5_gb($str,$fd) {
//====How to directly convert text string======== include("CCharset.php3"); $obj=new CCharset; $big5= "This is a big5 text string"; $tgb=$obj->Big5_Gb($big5); echo $tgb; //===> $tgb is the converted gb codeword String $tbig5=$obj->Gb_Big5($tgb); echo $tbig5; // Returned again: big5 //=========== =========================== ?>
< ? //If you convert web pages or files directly // Syntax http://your.domain.com.tw/this program.php3?http://Web page url or file to be transcoded // example: Convert Kimo homepage // http://your.domain.com.tw/this program.php3?http://www.kimo.com.tw/index.shtml // Note: If the following writing method encounters a web page that uses cookies, such as authenticating users, it may be kicked back and cause a login error. // Why? Think about it... @_@ include(" CCharset.php3"); $file=$QUERY_STRING; $fcontents = join( '', file( "$file" ) ); $fcontents=str_replace("", "", $fcontents); $code=new CCharset; $gb=$code->Big5_Gb($fcontents); echo $ gb; ?>
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