From: Nit Khair Date: 2008-11-06T00:41:31+09:00 Subject: Re: irb and ruby giving different results Brian Candler wrote: > Nit Khair wrote: >> ENV.grep(/^LC/) show nothing in both irb and ruby > > My bad; try > > ENV.select{|k,v| k=~/^LC/} > >> ENV['LC_ALL']='C' 'POSIX' etc has no effect in both >> >> However, "echo $LC_ALL" on my prompt gives en_US.UTF-8. >> So when i did LC_ALL='C', i get only 95 in both ruby and irb. >> >> Is there any way i get can ruby to also give 191 ? > > Perhaps then: > > env LC_ALL=en_US.UTF-8 ruby foo.rb > > Also, looking through source: it seems that ruby doesn't normally call > setlocale() by itself, but maybe some third-party library which irb is > invoking is doing this for you. "readline" is a likely candidate. So you > could try: > > require 'readline' > > in your ruby file. Or check $LOADED_FEATURES in irb and try loading the > same modules in your ruby file. Very strange: 1. > ENV.select{|k,v| k=~/^LC/} give en_US.UTF-8 in both irb and ruby. I get LC_ALL AND LC_CTYPE. 2. > env LC_ALL=en_US.UTF-8 ruby foo.rb still gives 95 3. I copied $LOADED_FEATURES, and then tried out (I hope i have this correct): ["enumerator.so", "e2mmap.rb", "irb/init.rb", "irb/workspace.rb", "irb/context.rb", "irb/extend-command.rb", "irb/output-method.rb", "irb/notifier.rb", "irb/slex.rb", "irb/ruby-token.rb", "irb/ruby-lex.rb", "readline.bundle", "irb/input-method.rb", "irb/locale.rb", "irb.rb", "irb/completion.rb", "irb/ext/save-history.rb", "stringio.bundle", "yaml/error.rb", "syck.bundle", "yaml/ypath.rb", "yaml/basenode.rb", "yaml/syck.rb", "yaml/tag.rb", "yaml/stream.rb", "yaml/constants.rb", "rational.rb", "date/format.rb", "date.rb", "yaml/rubytypes.rb", "yaml/types.rb", "yaml.rb"].each do |rr| require "#{rr}" end I still get 95. -- Posted via http://www.ruby-forum.com/.