function utf8_gb($c){
    $str="";
    if ($c < 0x80) {
         $str.=$c;
    } else if ($c < 0x800) {
         $str.=chr(0xC0 | $c>>6);
         $str.=chr(0x80 | $c & 0x3F);
    } else if ($c < 0x10000) {
         $str.=chr(0xE0 | $c>>12);
         $str.=chr(0x80 | $c>>6 & 0x3F);
         $str.=chr(0x80 | $c & 0x3F);
    } else if ($c < 0x200000) {
         $str.=chr(0xF0 | $c>>18);
         $str.=chr(0x80 | $c>>12 & 0x3F);
         $str.=chr(0x80 | $c>>6 & 0x3F);
         $str.=chr(0x80 | $c & 0x3F);
    }
    return iconv('UTF-8', 'GB2312', $str);
}
echo utf8_gb("&#20013;");

解决方案 »

  1.   

    上面的搞错了,用这个
    echo mb_convert_encoding("&#25991;",'UTF-8','HTML-ENTITIES');
      

  2.   

    LS的浏览器编码没设置好,选utf8就行了
    或用
    echo mb_convert_encoding("&#25991;",'GB2312','HTML-ENTITIES');
      

  3.   

    第一个在本机测试通过,但是服务器居然没有iconv函数
    也没有mb_convert_encoding函数...
      

  4.   

    感谢boom123我又找了一些函数,终于把问题解决了,但是比较繁琐,100多行代码,还附加了一个文件。感觉不是什么好办法,就不把结果贴上来了。确实,如果能用上面那两个函数,问题就很好解决了。