烈火建站学院(bkjia.com)php教程 php程序在cookie里写了点中文数据,而用javascript读取时却读出来不能正确显示?相信很多朋友遇到过这种情况,前天搜索了一下,找到一种解决方法:php写cookie时以utf-8编码写,而js读出来的时候也解码一下就可以了,因为javascript内部使用的是unicode编码。
|
以下为引用的内容: /** * * URL encode / decode * **/ var Url = { // public method for url encoding // public method for url decoding // private method for UTF-8 encoding 立即学习“PHP免费学习笔记(深入)”; for (var n = 0; n var c = string.charCodeAt(n); if (c utftext += String.fromCharCode(c); } return utftext; // private method for UTF-8 decoding while ( i c = utftext.charCodeAt(i); if (c string += String.fromCharCode(c); } return string; } /** |
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号