python对utf-8编码的支持真让人恼火。在Google App Enginea上发ajax请求时,有中文字符时,乱码问题很让人头痛。尝试了一种解决方法是可行的:
[list]
[*]浏览器端使用encodeURIComponent或者encodeURI编码中文字符;
[*]服务器端使用urllib模块的unquote方法:
[/list]
[list]
[*]浏览器端使用encodeURIComponent或者encodeURI编码中文字符;
[*]服务器端使用urllib模块的unquote方法:
[/list]
str= urllib.unquote(ajaxChineseString.encode("utf-8"))
本文介绍了解决AJAX请求中出现中文乱码的方法。客户端使用encodeURIComponent进行编码,服务器端通过urllib.unquote解码。该方案有效解决了Google AppEngine平台上的中文字符显示问题。
3万+

被折叠的 条评论
为什么被折叠?



