Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3443 > unrolled thread

Re: Windows CMD and international chars (åäö)

Started byAndrey Mikhaylov <lolmaus@gmail.com>
First post2011-04-24 13:20 -0500
Last post2011-04-24 13:20 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.ruby

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Windows CMD and international chars (åäö) Andrey Mikhaylov <lolmaus@gmail.com> - 2011-04-24 13:20 -0500

#3443 — Re: Windows CMD and international chars (åäö)

FromAndrey Mikhaylov <lolmaus@gmail.com>
Date2011-04-24 13:20 -0500
SubjectRe: Windows CMD and international chars (åäö)
Message-ID<b0dd4769cf2a949320cac12ffedd783c@ruby-forum.com>
``````
Encoding.default_external = Encoding.find(Encoding.locale_charmap)
Encoding.default_internal = __ENCODING__

[STDIN, STDOUT, STDERR].each do |io|
  io.set_encoding(Encoding.default_external, Encoding.default_internal)
end
``````

This solution works. The text is now correctly displayed in Windows 
console.

But my code crashes whenever Ruby faces a string that contains a
non-CP866 character (like em dash "—"):

in `write': U+2014 from UTF-8 to IBM866
(Encoding::UndefinedConversionError)

How do i overcome this error? Not using UTF-8 is not an option.

Iconv has a nice solution: add "//IGNORE" to encoding name and error no
longer takes place. But IO does not recognize "//IGNORE", so this
solution i unacceptable.

I can't use Iconv instead of IO due to the following reason. I use
RubyMine. Unlike Windows console, RubyMine console works in pure UTF-8.
But whenever code run by RubyMine writes to disk, it seems to use
Windows encoding because text gets written in corrupt encoding. :( And i
do not know a way to distinguish RubyMine from Windows console so that
my program could perfrom only the conversions necessary for the current
environment.

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web