(To) http://jyqx.spaces.live.com/blog/cns! F9f71c7d6cb19944! 203. The entry is sequential from high to low by performance
Iconv,
MbstringAnd
Homemade font library,The following code is a simple demonstration! Other codes are similar to each other.
PHP code
<? Function encode_conver ($ subject, $ function) {Switch ($ function) {Case 1: $ subject = iconv ("gb2312", "UTF-8", $ subject); break; case 2: $ subject = mb_convert_encoding ($ subject, "UTF-8", "gb2312"); break; Case 3: $ subject = gb2utf8 ($ subject); break ;} return $ subject;} function gb2utf8 ($ string) {$ ut = ""; $ GB = file (". /gbk.txt "); $ GB = explode (" | ", $ GB [0]); $ UTF = file (". /utf8.txt "); $ UTF = explode (" | ", $ UTF [0]); $ GB = arr Ay_flip ($ GB); While ($ string) {$ ST = substr ($ string, 0, 1); $ string = substr ($ string, 1 ); if (ord ($ st) <128) {$ ut. = $ st;} else {$ St. = substr ($ string, 0, 1); $ string = substr ($ string, 1); $ ut. = $ UTF [$ GB [$ st] ;}return $ ut ;}?>