UTF8

Discussion in 'Ruby' started by Peter C, Mar 15, 2005.

  1. Peter C

    Peter C Guest

    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
     
    Peter C, Mar 15, 2005
    #1
    1. Advertising

  2. Peter C

    Carlos Guest

    [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.
     
    Carlos, Mar 17, 2005
    #2
    1. Advertising

  3. 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...
     
    Florian Gross, Mar 24, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shade
    Replies:
    1
    Views:
    1,671
  2. Thomas =?ISO-8859-15?Q?G=F6tz?=

    LWP::Simple and utf8 problem

    Thomas =?ISO-8859-15?Q?G=F6tz?=, Apr 19, 2004, in forum: Perl
    Replies:
    0
    Views:
    718
    Thomas =?ISO-8859-15?Q?G=F6tz?=
    Apr 19, 2004
  3. Erik Sandblom

    open with encoding(utf8) takes forever

    Erik Sandblom, May 28, 2004, in forum: Perl
    Replies:
    0
    Views:
    547
    Erik Sandblom
    May 28, 2004
  4. Spamtrap

    UTF8 to Unicode conversion

    Spamtrap, Jul 30, 2004, in forum: Perl
    Replies:
    6
    Views:
    9,923
    Joe Smith
    Jul 31, 2004
  5. gry
    Replies:
    2
    Views:
    736
    Alf P. Steinbach
    Mar 13, 2012
Loading...

Share This Page