时间:2021-07-01 10:21:17 帮助过:28人阅读
function unicode_urldecode($url)
{
preg_match_all('/%u([[:alnum:]]{4})/', $url, $a);
foreach ($a[1] as $uniord)
{
$dec = hexdec($uniord);
$utf = '';
if ($dec < 128)
{
$utf = chr($dec);
}
else if ($dec < 2048)
{
$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);
}
http://www.bkjia.com/PHPjc/321701.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321701.htmlTechArticle折腾了一天的时间,才弄出点眉目来。 做AJAX应用或Flash应用,提交中文内容到后台,涉及到编码解码(encode、decode)及编码格式的转换。 网上...