Home > Article > Backend Development > Chinese COOKIE_PHP tutorial for reading PHP settings using Javascript
Agni Website Building Academy (Bkjia.Com) PHP Tutorial The PHP program writes some Chinese data in COOKIE, but when it is read with Javascript, it is read and cannot be displayed correctly? I believe many friends have encountered this situation. I searched the day before yesterday and found a solution: PHP writes COOKIE in UTF-8 encoding, and JS just decodes it when reading it out, because Javascript uses it internally. It is Unicode encoding.
The following is the quoted content: /** * * URL encode / decode * **/ var Url = { // public method for url encoding // public method for url decoding // private method for UTF-8 encoding for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { } return utftext; // private method for UTF-8 decoding while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { /** |
www.bkjia.com