Hi,

2011/12/15 Chris Lervag <chris.lervag / gmail.com>

> Im working on a script which is going to be printing some non-ascii
> characters (), and for the life of me, I just cant seemto make it
> print in the Windows Command Prompt terminal! I think I have done what
> should be enough to make it work, defining the encoding in my ruby file,
> but it just isnt working. However, if I try to print the same
> characters in irb, it works just fine. I can make it work by injecting
> hex values in my strings, but Id rather not have to do that, as that
> code isnt very readable. Im at a loss here, and would be grateful if
> anyone can help me out with my encoding woes!
>
> OS: Windows XP 32 bit SP3
>
> C:\>ruby -v
> ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
>
> Content in file test.rb:
> # Encoding: CP850
> puts ""
> puts "\x91\x9B\x86"
> puts Encoding.default_external
>
>
It seems that the actual encoding of test.rb is not CP850 but UTF-8.

The string "" is encoded as "\xC3\xA6\xC3\xB8\xC3\xA5" inUTF-8.


> C:\>ruby test.rb
> изизиз
> 
> CP850
>
>
The string "изизиз" is "\xC3\xA6\xC3\xB8\xC3\xA5" in CP850.


> C:\>irb
> irb(main):001:0> puts ""
> 
> => nil
> irb(main):002:0> puts "\x91\x9B\x86"
> 
> => nil
> irb(main):003:0> puts Encoding.default_external
> CP850
>
>
> Regards,
> Chris
>
>
Regards,
Park Heesob