[英]How to fix an error related to UTF-8/ASCII
Ok, I've got an App built using Rails 4.2 and MongoDB (MongoId V4) for storage. 好的,我有一个使用Rails 4.2和MongoDB(MongoId V4)构建的应用程序用于存储。 The information (text) stored in some of the tables/collections is a mix of English and Danish.
存储在某些表/集合中的信息(文本)是英语和丹麦语的混合。 The App is not localized in any way/shape/form yet as it is an API only.
该应用程序尚未以任何方式/形状/形式进行本地化,因为它仅是一个API。
I have a Sidekiq worker that updates the documents in my database. 我有一个Sidekiq工作程序,可以更新数据库中的文档。 The problem I'm having is that every time a document is updated in Sidekiq, I get the following error:
我遇到的问题是,每次在Sidekiq中更新文档时,都会出现以下错误:
Encoding::UndefinedConversionError: "\\xE9" from ASCII-8BIT to UTF-8 output in Sidekiq.
编码:: UndefinedConversionError:“ \\ xE9”从ASCII-8BIT到Sidekiq中的UTF-8输出。
How can I fix that? 我该如何解决?
我认为您可以在更新该特定记录之前使用string.force_encoding(Encoding :: UTF_8)对utf8进行强制编码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.