It took a day to make a point.
Do AJAX applications or flash applications, submit Chinese content to the background, involving encoding and decoding (encode, decode) and encoding format conversion.
The PHP end of the Internet unescape function is recommended not to use, it mixed in English and Chinese in the English filter out, I was inexplicably n long Ah, suggested with Unicode_urldecode this.
And then the conversion of the encoding format, which mainly involves the storage of data and the return of the client, with Iconv, this function seems to be from the C + + reference.
Copy CodeThe code is as follows:
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 (+ ($dec% 64));
}
Else
{
$utf = Chr (224 + (($dec-($dec% 4096))/4096);
$utf. = Chr ((($dec% 4096)-($dec% 64))/64);
$utf. = Chr (+ ($dec% 64));
}
$url = Str_replace ('%u '. $uniord, $utf, $url);
}
Return UrlDecode ($url);
}
http://www.bkjia.com/PHPjc/321701.html www.bkjia.com true http://www.bkjia.com/PHPjc/321701.html techarticle It took a day to make a point. Do AJAX applications or flash applications, submit Chinese content to the background, involving encoding and decoding (encode, decode) and encoding format conversion. Online ...