Annoying: cannot write ' user=" Iñaki ' in a Ruby1.9 script

Hi, I’m really annoyed, please try this:

Open a file (in a UTF-8 system as any modern Linux) and write:

script.rb

user = “Iñaki”
puts user

Now run:

~# ruby1.8 script.rb
=> “Iñaki”

~# ruby1.9 script.rb
=> invalid multibyte char (US-ASCII)

I’m using the last 1.9 version: ruby-1.9.1-p129

How can it be possible? Of course, the file “script.rb” is encoded in
UTF-8,
sure.

El Miércoles, 2 de Septiembre de 2009, Iñaki Baz C. escribió:

I’m using the last 1.9 version: ruby-1.9.1-p129

That is not the last, but it also occurs with 1.9.1-p243.

On Sep 1, 4:15 pm, Iñaki Baz C. [email protected] wrote:

El Miércoles, 2 de Septiembre de 2009, Iñaki Baz C. escribió:

I’m using the last 1.9 version: ruby-1.9.1-p129

That is not the last, but it also occurs with 1.9.1-p243.

I confirm this script also fails with 1.9.1-p243 on Mac OS X 10.5.8.

That’s pretty terrible. Can anyone explain what the problem is?

El Miércoles, 2 de Septiembre de 2009, [email protected]
escribió:> >

~# ruby1.9 script.rb
=> invalid multibyte char (US-ASCII)

How can it be possible? The file “script.rb” is encoded in UTF-8

How about:

encoding: utf-8

user = “Iñaki”
puts user

Yes, that works… but I cannot figure why is this required. I use a
system
in UTF-8 so the file is encoded in UTF-8. Also Ruby1.9 seems to work in
UTF-8
by default:

“abc”.encoding
=> #Encoding:UTF-8

so…?

Thanks for your reply.

On Tue, Sep 1, 2009 at 7:13 PM, Iñaki Baz C.[email protected] wrote:

~# ruby1.9 script.rb
=> invalid multibyte char (US-ASCII)

How can it be possible? The file “script.rb” is encoded in UTF-8

How about:

encoding: utf-8

user = “Iñaki”
puts user

2009/9/2 John W Higgins [email protected]:

See
http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings

Thanks:

“The first is the main rule of source Encodings: source files receive
a US-ASCII Encoding, unless you say otherwise”

See
http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs