Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > UTF8

Reply
 
 
Peter C
Guest
Posts: n/a
 
      03-15-2005
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
 
Reply With Quote
 
 
 
 
Carlos
Guest
Posts: n/a
 
      03-17-2005
[Peter C <>, 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 `' 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.


 
Reply With Quote
 
 
 
 
Florian Gross
Guest
Posts: n/a
 
      03-24-2005
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 `' 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...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
given char* utf8, how to read unicode line by line, and output utf8 gry C++ 2 03-13-2012 04:32 AM
UTF8 to Unicode conversion Spamtrap Perl 6 07-31-2004 04:59 AM
open with encoding(utf8) takes forever Erik Sandblom Perl 0 05-28-2004 02:01 PM
LWP::Simple and utf8 problem Thomas =?ISO-8859-15?Q?G=F6tz?= Perl 0 04-19-2004 09:48 AM
Cmenu, Text Interfaces, and UTF8 shade Perl 1 08-11-2003 11:24 AM



Advertisments