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=array_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; }?>