简体   繁体   English

如何修复与UTF-8 / ASCII相关的错误

[英]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.

相关问题 如何修复ActionView :: Template :: Error(不兼容的字符编码:ASCII-8BIT和UTF-8) - How to fix ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8) 如何修复“不兼容的字符编码:UTF-8和ASCII-8BIT”? - How do I fix “Incompatible character encodings: UTF-8 and ASCII-8BIT”? 错误:不兼容的字符编码:UTF-8和ASCII-8BIT - Error: Incompatible character encodings: UTF-8 and ASCII-8BIT 执行失败:错误:从ASCII-8BIT到UTF-8的“\ xFE” - Failed to execute: Error: “\xFE” from ASCII-8BIT to UTF-8 如何在Ruby 2中修复损坏的UTF-8字符串 - How to fix broken UTF-8 string in ruby 2 没有UTF字符的HAML模板错误:ActionView :: Template :: Error(不兼容的字符编码:ASCII-8BIT和UTF-8) - HAML template error with no UTF characters: ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8) 无法以ASCII或UTF-8格式读取字符串 - Unable to read in a string as ASCII or UTF-8 MySQL将UTF-8更改为ASCII-8BIT - MySQL changes UTF-8 to ASCII-8BIT 我该如何解决:ArgumentError:UTF-8中的无效字节序列? - How do I fix: ArgumentError: invalid byte sequence in UTF-8? ActionView :: Template :: Error(不兼容的字符编码:UTF-8和ASCII-8BIT): - ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM