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.
我最近安装了 Ruby 1.9.3。之后,当我开始使用 Mechanize 解析网页时,我总是收到此错误消息:“ArgumentError:UTF-8 中的无效字节序列”我在所有源文件的开头应用了“# encoding utf-8”。我能做些什么来避免这种烦恼?我应该使用 Ruby 1.8 还是更新到 Ruby 2.0?
你可以强制编码UTF-8以防机械化,我想它会有点不同。
UTF-8
我们在模型中设置 ActiveRecord 和 Facebook 属性值时遇到了类似的问题。为了解决这个问题,即使在应用程序级别我们已将编码设置为utf-8
utf-8
obj.attr.force_encoding("utf-8") if obj.attr.class == String
倾斜中的 UTF8 编码问题