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

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

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

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


script.rb
=2D-------------------
user =3D "I=C3=B1aki"
puts user
=2D-------------------


Now run:

~# ruby1.8 script.rb
=3D> "I=C3=B1aki"

~# ruby1.9 script.rb
=3D> 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=
,=20
sure.






=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
I

Iñaki Baz Castillo

El Mi=C3=A9rcoles, 2 de Septiembre de 2009, I=C3=B1aki Baz Castillo escribi=
=C3=B3:
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.=20


=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
J

Joe

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


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?
 
B

brabuhr

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 =3D "I=F1aki"
puts user
--------------------

~# ruby1.9 script.rb
=3D> 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 =3D "I=F1aki"
puts user
 
I

Iñaki Baz Castillo

El Mi=E9rcoles, 2 de Septiembre de 2009, (e-mail address removed) escribi=F3:
=20
How about:
=20
# encoding: utf-8
user =3D "I=F1aki"
puts user


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

"abc".encoding
=3D> #<Encoding:UTF-8>

so...?

Thanks for your reply.




=2D-=20
I=F1aki Baz Castillo <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top