echo utf8_decode("&#20013&#22269&#20154&#27665");

解决方案 »

  1.   

    <?php
    echo utf8_decode("&#20013&#22269&#20154&#27665");//output :中国人民  
    ?>不是乱码
      

  2.   

    $str=utf8_decode(("&#20013&#22269&#20154&#27665");
    然后将它写入数据库没问题的
    或者直接写入,然后读出来的时候再转换
      

  3.   

    找到转换办法了,这是一个10进制方式显示的Unicode字符需要先下载一个Unicode的转换Classhttp://www.phpe.net/class/95.shtml然后
    <?php
      include("./encoding/encoding.inc.php");  $source = "&#20013&#22269&#20154&#27665";  // 原代码
      $newstr = "";  $strEncoding=new Encoding();  
      $strEncoding->SetGetEncoding("UTF-16LE") || die("编码名错误"); 
      $strEncoding->SetToEncoding("GBK")||die("编码名错误");   $chars = explode("&#",$source); // 将字code分割到Array
         
      for( $i=0; $i<sizeof($chars); $i++ )
      {
          $newstr .= $strEncoding->EncodeString(pack("I",$chars[$i])); // Unicode到GBK转换
      
      }
      echo $newstr;
    ?>
      

  4.   

    <?php
    /**
     * 转换unicode十进制内码为utf-8编码
     */
    function u2utf8($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 $str; 
    }$source = "&#20013&#22269&#20154&#27665";preg_match_all("/&#([0-9]+)/",$source,$regs);
    print_r($regs);
    foreach($regs[1] as $v)
      $source = str_replace("&#$v",iconv("UTF-8","GB2312",u2utf8($v)),$source);
    echo $source;
    ?>
      

  5.   

    曾经写过一个 js 的~~~~~~~~~<script language="JavaScript">
    function Unicode2oStr(str){
    var re=/&#[\da-fA-F]{1,5};/ig;
    var arr=str.match(re);
    if(arr==null)return("");
    for(var i=0;i<arr.length;i++){
    arr[i]=String.fromCharCode(arr[i].replace(/[&#;]/g,""));
    }
    return(arr.toString().replace(/,/g,""))
    }alert(Unicode2oStr("&#20013;&#22269;&#20154;&#27665;"));
    </script>