Rails 字符编码问题视图到控制器
字符编码开始让我恼火。
我花了一段时间才从数据库中以正确的编码在屏幕上获取所有内容,但在 i18n 助手的帮助下,这一切成功了。
现在我只剩下一个问题:保存文本...
如果我在文本字段中添加一些带有重音符号的字母(例如 é ç ...)并想要保存它,它已经在我的控制器中显示为某种奇异的字符组合。
有人可以告诉我这是为什么以及如何解决这个问题。
顺便说一句,一切都是 UTF-8
谢谢!
//编辑: 当我保存表单时,这是我的日志输出
Parameters: {"free_text"=>"test 1 2 é",
并且所有内容都支持 UTF-8...
The character encoding starts to irritate me.
It took me a while to get everything from the DB in the right encoding on the screen, but with help from the i18n helper, this worked out.
Now I only have one more problem: saving text...
If i add some letters with accents (eg é ç ...) in a text field and want to save it, already in my controller it show as some exotic combination of characters.
Could someone tell me why this is and how I can fix this.
Everything is in UTF-8 btw
Thanks!
//Edit:
When I save the form, this is my log output
Parameters: {"free_text"=>"test 1 2 é",
And everything is capable of UTF-8...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能说明一下你的输出吗?
让我猜猜你的情况。
假设您将这些字符记录在控制器的 log/development.log 或 production.log 中。
如果您查看该登录终端,则应确保您的终端能够以适当的字体显示 UTF-8。此外,您的 shell 能够显示 UTF-8,文本查看器也能显示。
Can you illustrate your output?
Let me guess your situation.
Supposed that you log those characters in controller in log/development.log or production.log.
If you view that log in terminal, you should ensure your terminal is capable to show UTF-8, with appropriate font. Also, your shell is capable to show UTF-8 and so do your the text viewer.