tags:

views:

169

answers:

2

Take this text for example:

the three umlauts are ä, ö, and ü..

Let's assume they are in a text file, which I'm reading like this:

data = File.read("umlauts.txt")

Now, if I try to output them, I get this:

the three umlauts are Σ, ÷, and ⁿ.

If I write it to a file, they get outputted correctly. How can I make them show up properly on a windows command prompt? I'm using Ruby 1.8.6. I want to be able to perform quick debug from the command prompt.

+1  A: 

What encoding is the file? I'm guessing probably utf-8. Windows cmd prompt does not use utf-8.

Here's a good article that covers this: http://illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html

slebetman
and there's no way to force it do that?
Geo
Not sure but I don't think so. What you can do is convert the encoding before printing the output (or some languages allow you to specify encoding on streams, not sure about ruby).
slebetman
@Geo: Maybe switch operating systems? :P
thenduks
@Geo: "and there's no way to force it do that" => see my answer.
JRL
+1  A: 

Maybe set a different code page for cmd?

For explanations on encodings, read this.

JRL