Ruby Error Utf-8 to Ascii

Ruby error UTF-8 to ASCII

RDoc updated last week, and was supposed to help fix encoding problems.

Try gem update rdoc and see if that helps.

`write': \xCF from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) while writing to file from url

Use force_encoding:

open(uri) {|url_file| tempfile.write(url_file.read.force_encoding("UTF-8"))

Error: Incompatible character encodings: UTF-8 and ASCII-8BIT

In the file boot.rb, I added this line:

ENV['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'

Whit this I solved my problem.

\x90 from ASCII-8BIT to UTF-8 error rails

So after hours trying to find out what the problem is, I have figured this out.

The problem was the part where I tried to encode my hash to JSON. Apparently Rails or my application do not understand the .to_json method, so I had to use the JSON.generate(data) serialization as described here: http://ruby-doc.org/stdlib-2.0.0/libdoc/json/rdoc/JSON.html#module-JSON-label-Generating+JSON



Related Topics



Leave a reply



Submit