From: Ross Bamford Date: 2006-05-27T04:00:29+09:00 Subject: Re: Question about -K, $KCODE, command line On Sat, 2006-05-27 at 03:38 +0900, Daniel Berger wrote: > Hi all, > > If I run a program from the shell like "ruby test.rb -K u", why isn't > $KCODE set within the program to "UTF8"? > > # test.rb > puts $KCODE > > ruby test.rb -K u -> "NONE" ??? > > It looks like the only way to change it is to assign to $KCODE directly > within the program. Why? Would changing $KCODE from a command line > option have unintended side effects? You need -Ku, not -K u. The K is being taken as empty, and the 'u' is being passed as an argument to your script. $ ruby -Ku -e 'puts $KCODE' UTF8 $ ruby -e 'puts $KCODE' -Ku UTF8 -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk