In the JSON does not support Chinese, use it to send Chinese data will appear data loss or garbled, must be sent before the transmission of the string to encode, because the transmission in the past need to use JS data analysis, considering the JS has unescape function, so if there is an escape function in PHP, Encode the data and decode it with unescape on the client, which is much more convenient.
This article is for you to share a PHP decryption Unicode and escape cryptographic string function
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 This is the |
|
Search on the Internet, a lot of PHP implementation of the Escape function, the same
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14-15 16 |
function Phpescape ($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; } |
The above mentioned is the entire content of this article, I hope you can enjoy.