开发者

Ruby on Rails and utf-16

I have a translation s开发者_如何学运维cript that allows for translators to submit arabic translations, but for some reason Ruby doesn't like the encoding. Is there a way to encode the submitted text as utf-16?


How are translations submitted? A web browser will never submit form data as UTF-16, even if the form that generated the submission was on a UTF-16-encoded page. It's generally a bad idea to use UTF-16 on the web; as an encoding that isn't ASCII-compatible, dealing with it is a pain and there are server and client bugs to watch out for. Instead, always use UTF-8.

I guess UTF-16 in an uploaded file is possible. In that case I would sniff the first two bytes for a UTF-16LE/BE BOM and if present transcode the file to UTF-8 before doing any further work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜