Encoding::UndefinedConversionError - "\xC2" from ASCII-8BIT to UTF-8
ハッシュをJSON文字列に変換しようとするたびに取得し続けます。[.encode | .force_encoding](["UTF-8" | "ASCII-8BIT" ])
、チェーン.encode
、.force_encoding
バックワード、パラメーターの切り替えを試してみましたが、何も機能していないようだったので、次のようなエラーが発生しました。
begin
menu.to_json
rescue Encoding::UndefinedConversionError
puts $!.error_char.dump
p $!.error_char.encoding
end
menuは、MySQL DBからのコンテンツを含む続編のdataset.to_hashであり、utf8_general_ciエンコーディングであり、これを返します。
"\ xC2"
<#Encoding:ASCII-8BIT>
何を使用しても、エンコーディングは変更されませ.encode
ん.force_encoding
。.gsub!(/\\\xC2/)
運が悪かったので、弦を交換しようとさえしました。
何か案は?