Hannibal episodes in tvdb have weird characters in them.
For example:
Œuf
So ruby spits out:
./manifesto.rb:19:in `encode': "\xC3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
from ./manifesto.rb:19:in `to_json'
from ./manifesto.rb:19:in `<main>'
Line 19 is:
puts @tree.to_json
Is there a way to deal with these non utf characters? I'd rather not replace them, but convert them? Or ignore them? I don't know, any help appreciated.
Weird part is that script works fine via cron. Manually running it creates error.
ISO-8859-1
instead ofASCII-8BIT
to the variable@tree
as@tree.force_encoding('ISO-8859-1')
. BecauseASCII-8BIT
is used just for binary files. – Малъ Скрылевъcron
environment is somehow resolving the default input encoding for you. I think your input is actually UTF-8 in the first place (C3 is a common byte to see at the start of a multi-byte character from European characters) – Neil SlaterŒ
in the iso cp? – Малъ СкрылевъEncoding.default_external = Encoding::UTF_8
replacing utf to proper one – Малъ Скрылевъ