`echo "$tmp"|iconv -f GBK -t UTF8`;

解决方案 »

  1.   

    google把,很多gb转utf8的程序,用的是码表
      

  2.   

    test/* gb转utf8 */
    function gb2utf8($gb)
    {
        static $gb2utf8codetable ;    if ( function_exists('iconv') )  {
             return $message = iconv("gb2312", "UTF-8", $gb) ;
        }
        if ( ! $gb2utf8codetable ) {
              $codetablefile = file("gb2utf8",1);
              $gb2utf8codetable=array();
              while(list($key,$value)=each($codetablefile))
                    $gb2utf8codetable[substr($value,0,2)]=substr($value,5,substr($value,3,1));
        }
        for($utf8=""; $gb!=''; )
        {
              if (ord(substr($gb,0,1))>127) {
                  $utf8.=$gb2utf8codetable[substr($gb,0,2)];
                  $gb=substr($gb,2);
              } else {
                  $utf8.=substr($gb,0,1);
                  $gb=substr($gb,1);
              }
        }
        return $utf8;
    }/* utf8转gb */
    function utf82gb($utf8)
    {
        static $utf82gbcodetable ;    if ( function_exists('iconv') )
             return $message = iconv("UTF-8", "gb2312" ,$utf8) ;    if ( ! $utf82gbcodetable ) {
              $codetablefile = file("gb2utf8",1);
              $utf82gbcodetable=array();
              while(list($key,$value)=each($codetablefile))
                    $utf82gbcodetable[substr($value,5,substr($value,3,1))]=substr($value,0,2);
        }    for($gb=""; $utf8!=''; )
        {
              if (ord(substr($utf8,0,1))>224) { #   三字节
                  $gb .= $utf82gbcodetable[substr($utf8,0,3)];
                  $utf8=substr($utf8,3);
              } elseif ( ord(substr($utf8,0,1))>127 ) {
                  $gb .= $utf82gbcodetable[substr($utf8,0,2)];
                  $utf8=substr($utf8,2);
              } else {
                  $gb.=substr($utf8,0,1);
                  $utf8=substr($utf8,1);
              }
        }    return $gb;
    }
      

  3.   

    可以下载一个点阵字体
    以前ucdos自带那种