- 论坛徽章:
- 0
|
本帖最后由 climby 于 2010-04-03 23:35 编辑
回复 17# blackmuyu
根据你描述的情况,我大概知道真正的原因了。
包含中文的字符,被perl的escape转义后,发给了jsp的页面,但jsp里面的unescape并没有按照escape的’协议‘去decode.所以乱码产生。 平时用的比较多的还是js 的escape, unescape. 但perl 的escape ,并不兼容 js 的escape, 简单说perl 的escape后, 甚至无法用js的unescape正确的decode,尤其是中文,有如下的notes为证,来自http://search.cpan.org/~gaas/URI-1.54/URI/Escape.pm
- Note: JavaScript has a function called escape() that produces the sequence "%uXXXX" for chars in the 256 .. 65535 range. This function has really nothing to do with URI escaping but some folks got confused since it "does the right thing" in the 0 .. 255 range. Because of this you sometimes see "URIs" with these kind of escapes. The JavaScript encodeURIComponent() function is similar to uri_escape_utf8().
复制代码 你打印的内容最终由ajax返回,我想最后的decode由js的unescape来完成的,所有解决问题的办法,我想我们可以在perl中使用跟js兼容的escape,试试,不妨试试这个
http://search.cpan.org/~taniguch ... scape/JavaScript.pm |
|