function   encodeURIComponent($text)   { 
    preg_match_all( "/[\x81-\xfe]?./ ",$text,$regs); 
    $rtext   =   " "; 
    foreach($regs[0]   as   $v)   { 
      $ch   =   iconv( "gb2312 ", "UTF-8 ",$v); 
      $rtext   .=   sprintf( "%%%02X%%%02X%%%02X ",ord($ch[0]),ord($ch[1]),ord($ch[2])); 
    } 
    return   $rtext; 
} function   escape($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; 

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 "){ 
if   (!eregi( "WIN ",PHP_OS)){ 
$tmpString   =   "%u ".substr($v,4,2).substr($v,2,2); 

            $ar[$k]   =   iconv( "UCS-2 ", "GB2312 ",pack( "H4 ",substr($tmpString,-4))); 
  } 
        elseif(substr($v,0,3)   ==   "&#x ") 
            $ar[$k]   =   iconv( "UCS-2 ", "GB2312 ",pack( "H4 ",substr($v,3,-1))); 
        elseif(substr($v,0,2)   ==   "&# ")   { 
            $ar[$k]   =   iconv( "UCS-2 ", "GB2312 ",pack( "n ",substr($v,2,-1))); 
        } 
    } 
    return   join( " ",$ar);