[lnkForumImage]
TotalShareware - Download Free Software

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


 

pkchau

3/15/2005 5:59:00 PM

I'm working with Japanese character sets in Windows. I can save my
*.rb files with notepad using UTF-8 but I can't run them with Ruby.
This is what happens when I try to run it.


c:\> ruby -Ku myFile.rb
jpn.rb:1: undefined method `' for main:Object
(NoMethodError)


Am I doing something wrong?


My goal is the read/write strings (containing Japanese characters)
from a web browser. Is there a recommend way of doing this?


Peter
2 Answers

Carlos

3/17/2005 2:07:00 PM

0

[Peter C <pkchau@gmail.com>, 2005-03-15 18.59 CET]
> I'm working with Japanese character sets in Windows. I can save my
> *.rb files with notepad using UTF-8 but I can't run them with Ruby.
> This is what happens when I try to run it.
>
>
> c:\> ruby -Ku myFile.rb
> jpn.rb:1: undefined method `&#8745;&#9559;&#9488;' for main:Object
> (NoMethodError)
>
>
> Am I doing something wrong?

Probably you forgot to put quotes, or #, somewhere...

If you show us jpn.rb, or at least its first line, we can help you better.


Florian Gross

3/24/2005 7:30:00 PM

0

Peter C wrote:

> I'm working with Japanese character sets in Windows. I can save my
> *.rb files with notepad using UTF-8 but I can't run them with Ruby.
> This is what happens when I try to run it.
>
> c:\> ruby -Ku myFile.rb
> jpn.rb:1: undefined method `&#8745;&#9559;&#9488;' for main:Object
> (NoMethodError)
>
> Am I doing something wrong?

I guess you're running into the same old BOM issue. Notepad and other
editors put a special marker at the beginning of documents. Ruby parses
that either as a variable or method name. You can work around it by
starting your application with an assignment:

nothing_useful = nil

Ruby will then parse it as an assignment to a variable that starts with
the BOM and ends with 'nothing_useful'.

It's a reported problem and I hope that Ruby will do this the correct
way and just ignore the BOM in the future...