[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby 1.9 # coding: utf-8

Damjan Rems

3/27/2009 12:06:00 PM


I am trying some ruby 1.9. taste for the first time and I have got to
this new behaviour. Since my location is in Estern Europe, most of my
source files are coded in utf-8. I have found out that I should use #
coding: utf-8 if I want to omit nasty "rubyArchiveTesti.rb:82: invalid
multibyte char (US-ASCII)" error.

Where can I set that all my source files are encoded in utf-8, since I
don't like the idea of editing them all.

by
TheR
--
Posted via http://www.ruby-....

5 Answers

Gregory Brown

3/27/2009 12:16:00 PM

0

On Fri, Mar 27, 2009 at 8:05 AM, Damjan Rems <d_rems@yahoo.com> wrote:
>
> I am trying some ruby 1.9. taste for the first time and I have got to
> this new behaviour. Since my location is in Estern Europe, most of my
> source files are coded in utf-8. I have found out that I should use #
> coding: utf-8 if I want to omit nasty "rubyArchiveTesti.rb:82: invalid
> multibyte char (US-ASCII)" error.
>
> Where can I set that all my source files are encoded in utf-8, since I
> don't like the idea of editing them all.

-Ku does this but it's not recommendable. If your code needs to run
on any other computers, it would need to be run with this flag.
The source encoding magic comments are just a reality of Ruby 1.9
based development, and it seems that your problem could be solved by
better settings in your editor to automatically add this line for you.

-greg

foo.rb:

p __ENCODING__

$ ruby19 foo.rb
#<Encoding:US-ASCII>
$ ruby19 -Ku foo.rb
#<Encoding:UTF-8>


-greg


--
Technical Blaag at: http://blog.majesticseacr...
Non-tech stuff at: http://metametta.bl...
"Ruby Best Practices" Book now in O'Reilly Roughcuts:
http://rubybestpra...

Radoslaw Bulat

3/27/2009 12:38:00 PM

0

On Fri, Mar 27, 2009 at 1:05 PM, Damjan Rems <d_rems@yahoo.com> wrote:
>
> I am trying some ruby 1.9. taste for the first time and I have got to
> this new behaviour. Since my location is in Estern Europe, most of my
> source files are coded in utf-8. I have found out that I should use #
> coding: utf-8 if I want to omit nasty "rubyArchiveTesti.rb:82: invalid
> multibyte char (US-ASCII)" error.
>
> Where can I set that all my source files are encoded in utf-8, since I
> don't like the idea of editing them all.

You should get to like it. It's only *1* line per file. Image that
someone with differencts locale wants to use your file. He shoulnd't
care what encoding did you use.

If you are too lazy to write it by habd you can write some script
which do that for you ;).


--=20
Pozdrawiam

Rados=B3aw Bu=B3at
http://radarek... - m=F3j blog

Damjan Rems

3/27/2009 1:10:00 PM

0

RadosÅ?aw BuÅ?at wrote:
> On Fri, Mar 27, 2009 at 1:05 PM, Damjan Rems <d_rems@yahoo.com> wrote:
>>
>> I am trying some ruby 1.9. taste for the first time and I have got to
>> this new behaviour. Since my location is in Estern Europe, most of my
>> source files are coded in utf-8. I have found out that I should use #
>> coding: utf-8 if I want to omit nasty "rubyArchiveTesti.rb:82: invalid
>> multibyte char (US-ASCII)" error.
>>
>> Where can I set that all my source files are encoded in utf-8, since I
>> don't like the idea of editing them all.
>
> You should get to like it. It's only *1* line per file. Image that
> someone with differencts locale wants to use your file. He shoulnd't
> care what encoding did you use.
>
> If you are too lazy to write it by habd you can write some script
> which do that for you ;).
>
>
> --
> Pozdrawiam
>
> Rados�aw Bu�at
> http://radarek... - m�j blog


Yeah. But it kind-a iratete me since I haven't seen this in all those
what is different in ruby 1.9 since 1.8.6 documents I have been reading.
It was not even trivial to find the solution.

It's my first day and I was suppose to love it. But almost none of my
programs work as before.

I have just realized that reading file takes about 50x times more on my
Vista then in 1.8.6. (on XP also). Lets go bug reporting.


by
TheR




--
Posted via http://www.ruby-....

Gregory Brown

3/27/2009 1:25:00 PM

0

On Fri, Mar 27, 2009 at 9:09 AM, Damjan Rems <d_rems@yahoo.com> wrote:

> Yeah. But it kind-a iratete me since I haven't seen this in all those
> what is different in ruby 1.9 since 1.8.6 documents I have been reading.
> It was not even trivial to find the solution.
>
> It's my first day and I was suppose to love it. But almost none of my
> programs work as before.

Why do you expect they should? Ruby 1.9 represents a completely new
generation of Ruby, and had a whole year of a 'testing period' before
it's first stable release. If you don't pay attention to what's
going on, and then expect something to 'just work', you're asking for
trouble. That said, although there are minor tweaks that need to be
made to most Ruby 1.8 based software, it's normally a quick process to
get things running on Ruby 1.9.

-greg

James Gray

3/27/2009 3:30:00 PM

0

On Mar 27, 2009, at 8:09 AM, Damjan Rems wrote:

> Yeah. But it kind-a iratete me since I haven't seen this in all those
> what is different in ruby 1.9 since 1.8.6 documents I have been =20
> reading.
> It was not even trivial to find the solution.

I've been working on character encoding documentation for both Ruby =20
1.8 and Ruby 1.9 on my blog:

http://blog.grayproductions.net/articles/understa...

I haven't got to the 1.9 stuff yet, but I promise it's coming=85

James Edward Gray II=