? Is it a class package? Okay? Complex ??? Q class. What else do I need ??? Table? N: 1. why? /// Program? T: MagicJerry // fu? Is it a class package? Okay? Complex ??? Q class,
In addition ??? Table? N:
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
// Program? T: Magic Jerry
//
// Function Big5_Gb ($ str) => big5? GB for string
// Function Gb_Big5 ($ str) => GB? Big5 for string
// ================================================ ====================
Class CCharset {
Var $ gb_map = "gb. map"; // If you want to put it in? E path ?? What is the complete path?
Var $ big5_map = "big5.map"; // example = "/home/table/gb. map
Var $ dep_char= 127;
//-----------------------------------------------------------------
Function cbig5_gb ($ str, $ fd ){
$ C = ord (substr ($ str, 0, 1 ));
$ X = ord (substr ($ str, 1, 1 ));
$ Address = ($ C-160) * 510) ($ X-1) * 2;
Fseek ($ fd, $ address );
$ Hi = fgetc ($ fd );
$ Lo = fgetc ($ fd );
Return "$ hi $ lo ";
}
Function cgb_big5 ($ str, $ fd ){
$ C = ord (substr ($ str, 0, 1 ));
$ X = ord (substr ($ str, 1, 1 ));
$ Address = ($ C-160) * 510) ($ X-1) * 2;
Fseek ($ fd, $ address );
$ Hi = fgetc ($ fd );
$ Lo = fgetc ($ fd );
Return "$ hi $ lo ";
}
//-----------------------------------------------------------------
Function Big5_Gb ($ str ){
$ Fd = fopen ($ this-> gb_map, "r ");
$ Str = str_replace ("charset = big5", "charset = gb2312", $ str );
$ Outstr = "";
For ($ I = 0; $ I $ Ch = ord (substr ($ str, $ I, 1 ));
If ($ ch> $ this-> dep_char ){
$ Outstr. = $ this-> cbig5_gb (substr ($ str, $ I, 2), $ fd );
$ I;
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.