PHP Chinese processing skills. After a day, I came up with an eye. For AJAX or Flash applications, submitting Chinese content to the background involves encoding and decoding (encode, decode) and conversion of encoding formats. After a day of online competition, I came up with an eye.
For AJAX or Flash applications, submitting Chinese content to the background involves encoding and decoding (encode, decode) and conversion of encoding formats.
We recommend that you do not use the escape function on the PHP end on the internet. it filters out the English when both Chinese and English are mixed. I have been puzzled for a long time. we recommend using unicode_urldecode.
The conversion of the encoding format mainly involves data storage and client return, which can be done with iconv. this function seems to be used for reference in C ++.
The code is as follows:
Function unicode_urldecode ($ url)
{
Preg_match_all ('/% u ([[: alnum:] {4})/', $ url, $ );
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 );
}
Bytes. For AJAX or Flash applications, submitting Chinese content to the background involves encoding and decoding (encode, decode) and conversion of encoding formats. Online...