开发者

Ramaze Request Parameters in Unicode?

开发者 https://www.devze.com 2023-01-28 06:08 出处:网络
I\'ve got a partial for rendering a form that is throwing an error using unicode; I\'ve narrowed the error down to the line;

I've got a partial for rendering a form that is throwing an error using unicode; I've narrowed the error down to the line;

<input name='q' value='#{request.params['q']}' />

If I go to localhost/thepath?q=中文 it throws

Encoding::CompatibilityError at /thepath/
incompatible character encodings: ASCII-8开发者_运维技巧BIT and UTF-8

But

<input name='q' value='中文' />

Works fine, and all the unicode strings from values that aren't in the request work fine also.


One solution is to wash the input with #force_encoding, is there a more desirable method?

0

精彩评论

暂无评论...
验证码 换一张
取 消