From: Brian Candler Date: 2008-11-08T07:10:39+09:00 Subject: Re: irb and ruby giving different results Nit Khair wrote: > I still get 95. Possibly readline isn't calling setlocale until you actually invoke/initialise the library. Here's an alternative test. Install the RubyInline gem, and then stick this in front of your test program: require 'rubygems' require 'inline' class MyTest inline do |builder| builder.include '' builder.c " void set_locale(void) { setlocale(LC_ALL, 0); }" end end MyTest.new.set_locale If that works, you can remove the dependency on the LC_ALL environment variable by changing to: setlocale(LC_ALL, "en_US.UTF-8"); or whatever. However, this dependence on the C stdlib's half-baked idea of "locale" is very hairy. I understand why Ruby doesn't call setlocale() normally - it means that at least the normal behaviour is (a) sane, and (b) not affected randomly by global environment variable settings. To be honest, if you want a character class which always matches 0x20 to 0x7e and 0xa0 to 0xff, then you might as well just say so directly: [\x20-\x7e\xa0-\xff] -- Posted via http://www.ruby-forum.com/.