http://www.chinaunix.net Author: HonestQiao Posted: 2003-08-01 18:27:21
GB2UTF8.php files are as follows:
[CODE: 1: FD411E9991D] Class GB2UTF8 {var $ GB; // The GB2312 string VAR $ UTF8; //-converted UTF8 string VAR $ CODETABLE; / / The GB2312 code file used during the conversion process Array var $ errormsg; // Error message among the conversion process
Function GB2UTF8 ($ INSTR = ") {$ this-> GB = $ INSTR; $ this-> setgb2312 (); ($ this-> gb ==" ")? 0: $ this-> convert ();}
Function setgb2312 ($ INSTR = "gb2312.txt") {// set the GB2312 code file, default is GB2312.txt $ this-> errormsg = ""; $ TMP = @ file ($ INSTR); if (! $ tmp) {$ This-> error = "no gb2312"; return false;} $ this-> codetable = array (); while ($ key, $ value) = Each ($ THIS-> CODETABLE [ HEXDEC (Substr ($ Value, 0, 6))] = Substr ($ Value, 7, 6);}} Function Convert () {// Convert GB2312 string to UTF8 string, need to pre-set $ GB $ THIS- > utf8 = ""; if (! trim ($ this-> GB) || $ this-> errormsg! = "") {return ($ this-> utf8 = $ this-> errormsg);} $ strromsg);} $ str = $ THIS-> GB;
While ($ Str) {if (Substr ($ Str, 0, 1))> 127) {$ TMP = Substr ($ Str, 0, 2); $ Str = Substr ($ Str, 2, Strlen ($ SUBSTR ($ Str, 2, Strlen) Str); $ TMP = $ THIS-> U2UTF8 ($ this-> CodeTable [HEXDEC (bin2hex ($ TMP)) - 0x8080]); for ($ I = 0; $ I
Function U2UTF8 ($ INSTR) {for ($ I = 0; $ I
Description: You need to set up a font file correctly. Please confirm that you can use Font to export English directly (without using GB2UTF8). GB2312.TXT Please look online