<body>

Caiwangqin's blog

Focus on Web2.0, Business, Architecture, Agile, Technic and beyond…

dead unescape with javascript on ruby

2006年5月19日 星期五

还是中文的问题,在?传递中文参数时请使用encodeURIComponent.


document.write(encodeURIComponent(”中文”));   =>  %E4%B8%AD%E6%96%87

document.write(escape(”中文”));                           =>  %u4E2D%u6587


Rails 能自动 decode 使用encodeURIComponent的编码,但不能对javascript escape的中文进行unescape.CGI.escape和CGI.unescape方法编码是以GBK方式编码中文的,而javascript的escape和unescape是utf-8方式。


标签:

posted by Caiwangqin, 上午1:19

<< 主页