From: Michael Brooks Date: 2011-01-17T02:10:22+09:00 Subject: Re: [Ruby 1.9] New String rules? "felix.leg" wrote in message news:igv4bb$a49$1@news.onet.pl... >I have just updated my Ruby into 1.9.0, and tried to run one of my >programs. But I got that response: > > zrzutnik.rb:19: invalid multibyte char (US-ASCII) > > zrzutnik.rb:19: invalid multibyte char (US-ASCII) > > zrzutnik.rb:19: syntax error, unexpected $end, expecting keyword_end > > print "Klucz #{kl.inspect} jest nieznany. Zdefiniować > > nowy [T/N]? " > > ^ > (at Ruby 1.8 it works fine) > > Does it mean I can't use any longer any non-latin character in my > String-s? WTF? > > PS: The file ("zrzutnik.rb") is encoded all in utf-8 (without BOM). Hello: In Ruby 1.9.x you need to explicitly specify the encoding of your strings to fit your requirements. Your default string encoding appears to be US-ASCII (mine is CP850). If you want it to be UTF-8 use the following to force the string to that encoding: abc = "abc" puts abc.encoding.name # >> US-ASCII abc.force_encoding("UTF-8") puts abc.encoding.name # >> UTF-8 James Edward Gray II wrote an excellent blog on the topic here http://blog.grayproductions.net/articles/ruby_19s_string . Michael