The encoding that Notepad++ just calls "ANSI", does anyone know what to call it for Ruby?

Owen_AR picture Owen_AR · Apr 18, 2013 · Viewed 32.6k times · Source

I have a bunch of .txt's that Notepad++ says (in its drop-down "Encoding" menu) are "ANSI".

They have German characters in them, [äöüß], which display fine in Notepad++.

But they don't show up right in irb when I File.read 'this is a German text example.txt' them.

So does anyone know what argument I should give Encoding.default_external=?

(I'm assuming that'd be the solution, right?)

When 'utf-8' or 'cp850', it reads the "ANSI" file with "äöüß" in it as "\xE4\xF6\xFC\xDF"...

(Please don't hesitate to mention apparently "obvious" things in your answers; I'm pretty much as newbish as you can be and still know just enough to ask this question.)

Answer

Jörg W Mittag picture Jörg W Mittag · Apr 18, 2013

What they mean is probably ISO/IEC 8859-1 (aka Latin-1), ISO-8859-1, ISO/IEC 8859-15 (aka Latin-9) or Windows-1252 (aka CP 1252). All 4 of them have the ä at position 0xE4.