Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
写入数据库时出现此错误:
Encoding::UndefinedConversionError "\xD0" from ASCII-8BIT to UTF-8
在谷歌搜索了一下之后,问题似乎在于 ruby 1.9.2 字符串处理,但没有找到真正的解决方案。
我使用 magic_encoding 对所有数据强制使用 utf-8。我的数据库也在 utf-8 上运行。
我正在运行 rails 3.1 和 ruby 1.9.2。
任何人都可以对这个错误有所了解吗?
您应该将此行添加到 .rb 文件的顶部
# encoding: utf-8
或者你可以使用这个宝石
魔术编码
相关主题:
在所有文件中添加“#coding:utf-8”