PHP function for converting Simplified to traditional Chinese characters

Source: Internet
Author: User
? Hessianhessian@21cn.com recommendations are released in ctohome. comgb_big5 (the Text to wait for conversion, the language type of the Text to wait for conversion) functiongb_big5 ($ Text, $ Source_Languagegb) {switch ($ Source_Language) {casegb: $ fpfopen (gb-big5.table, r ); brea // Hessian Released on ctohome.com
// Gb_big5 ("text waiting for conversion", "language type waiting for conversion ")
Function gb_big5 ($ Text, $ Source_Language = "gb "){
Switch ($ Source_Language ){
Case "gb ":
$ Fp = fopen ("gb-big5.table", "r ");
Break;
Case "big5 ":
$ Fp = fopen ("big5-gb.table", "r ");
Break;
Default:
$ Fp = fopen ("gb-big5.table", "r ");
Break;
}

$ Max = strlen ($ Text)-1;
For ($ I = 0; $ I <$ max; $ I ++ ){
$ H = ord ($ Text [$ I]);
If ($ h> = 160 ){
$ L = ord ($ Text [$ I + 1]);
If ($ h = 161 & $ l = 64 ){
$ Gb = "";
} Else {
Fseek ($ fp, ($ h-160) * 510 + ($ L-1) * 2 );
$ Gb = fread ($ fp, 2 );
}
$ Text [$ I] = $ gb [0];
$ Text [$ I + 1] = $ gb [1];
$ I ++;
}
}
Fclose ($ fp );
Return $ Text;
}

// Example: $ big5 is a traditional Chinese character. $ gb is a simplified Chinese character. after the output, switch the browser encoding. this is the Ajax code.
/*
$ Big5 = "emblem species 9a # HGYUG7KJN * (* ^ ";
$ Gb = "traditional Chinese ";
Echo gb_big5 ($ gb, "gb ");
Echo"




";
Echo gb_big5 ($ big5, "big5 ");
*/

?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.