? /***** Traditional Chinese simplified ***** // ** code table acquisition: getting /***** Traditional Chinese <=> simplified ****/
/**
Getting a code table:
Http://netcity.hinet.net/kstchieh/table.zip
There are two files in the package: big5-gb.table, gb-big5.table
The function gb2big5 failed to be tested in detail because it does not have a big5 environment.
*/
/**
Convert Big5 to GB
*/
Function big52gb ($ Text ){
Global $ big5;
$ 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 {
$ P = ($ h-160) * 510 + ($ L-1) * 2;
$ Gb = $ big5 [$ p]. $ big5 [$ p + 1];
}
$ Text [$ I] = $ gb [0];
$ Text [$ I + 1] = $ gb [1];
$ I ++;
}
}
Return $ Text;
}
/**
Convert the GB code to the Big5 code
*/
Function gb2big5 ($ Text ){
Global $ gb;
$ 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 ){
$ Big = "";
} Else {
$ P = ($ h-160) * 510 + ($ L-1) * 2;
$ Big = $ gb [$ p]. $ gb [$ p + 1];
}
$ Text [$ I] = $ big [0];
$ Text [$ I + 1] = $ big [1];
$ I ++;
}
}
Return $ Text;
}
?>
/***** Test ****/
$ A = "ah, sorry, no cancer, no. ai, no problem, aile saddle ammonia ";
Echo "original simplified $
";
$ A = "pendulum ??????? Gravel magic? ︺ Anchor ???? ";
Echo "original traditional Chinese $
";
$ A = big52gb ($ );
Echo "to simplified $
";
$ A = gb2big5 ($ );
Echo "to traditional Chinese $
";
?>
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.