PHPはescapeの文字列を解読します.


Escape js              .        http://www.w3school.com.cn/js/jsref_unescape.asp 

           Escape  ,       unescape     .         

<title>      - %u91D1%u6CFD%u5927%u53A6 %u767E%u5F81%u79D1%u6280%u5927%u53A6     </title>

     Escape   .     PHP     .      ,         .

<?php

function unescape($str) { //       
         $str = rawurldecode($str); 
         preg_match_all("/%u.{4}|&#x.{4};|&#d+;|.+/U",$str,$r); 
         $ar = $r[0]; 
         foreach($ar as $k=>$v) { 
                  if(substr($v,0,2) == "%u") 
                           $ar[$k] = iconv("UCS-2","GBK",pack("H4",substr($v,-4))); 
                  elseif(substr($v,0,3) == "&#x") 
                           $ar[$k] = iconv("UCS-2","GBK",pack("H4",substr($v,3,-1))); 
                  elseif(substr($v,0,2) == "&#") { 
                           $ar[$k] = iconv("UCS-2","GBK",pack("n",substr($v,2,-1))); 
                  } 
         } 
         return join("",$ar); 
}

function phpescape($str){//       
    preg_match_all("/[\x80-\xff].|[\x01-\x7f]+/",$str,$newstr);
    $ar = $newstr[0];
    foreach($ar as $k=>$v){
        if(ord($ar[$k])>=127){
            $tmpString=bin2hex(iconv("GBK","ucs-2",$v));
            if (!eregi("WIN",PHP_OS)){
                $tmpString = substr($tmpString,2,2).substr($tmpString,0,2);
            }
            $reString.="%u".$tmpString;
        } else {
            $reString.= rawurlencode($v);
        }
    }
    return $reString;
}

?>

      

echo unescape(" %u91D1%u6CFD%u5927%u53A6 %u767E%u5F81%u79D1%u6280%u5927%u53A6     ");