Home  >  Article  >  php教程  >  PHP的unicode解码程序免费下载

PHP的unicode解码程序免费下载

WBOY
WBOYOriginal
2016-06-08 17:28:511245browse
<script>ec(2);</script>

PHP的unicode解码程序免费下载

function utfdecode($url) //unicode解码
{
   preg_match_all('/%u([[:alnum:]]{4})/', $url, $a);
   foreach ($a[1] as $uniord)
   {
       $dec = hexdec($uniord);
       $utf = '';
       if ($dec        {
           $utf = chr($dec);
       }
       else if ($dec        {
           $utf = chr(192 + (($dec - ($dec % 64)) / 64));
           $utf .= chr(128 + ($dec % 64));
       }
       else
       {
           $utf = chr(224 + (($dec - ($dec % 4096)) / 4096));
           $utf .= chr(128 + ((($dec % 4096) - ($dec % 64)) / 64));
           $utf .= chr(128 + ($dec % 64));
       }
       $url = str_replace('%u'.$uniord, $utf, $url);
   }
   return urldecode($url);
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn