Results 1 to 7 of 7

Thread: Ruby and non-ASCII characters

  1. #1
    Join Date
    Oct 2007
    Location
    Santiago do Escoural
    Beans
    23
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Cool Ruby and non-ASCII characters

    I'm trying out Ruby. So far it seems fine, but I have a serious problem here on my system: several string methods don't work with characters other than ASCII. For instance:

    puts "Olá José António!".reverse

    and .upcase won't upcase, etc.

    The input method doesn't matter. If the string is entered via gets, the same problem occurs.

    What is going on? One is supposed to be able to use his own language? TIA.

  2. #2
    Join Date
    Nov 2008
    Location
    Here, There, Everywhere
    Beans
    1,163
    Distro
    Xubuntu

  3. #3
    Join Date
    Oct 2007
    Location
    Santiago do Escoural
    Beans
    23
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Ruby and non-ASCII characters

    Quote Originally Posted by danielrmt View Post
    Almost there:

    jmccm@ubuntu-base:~$ irb -rrubygems -runicode
    /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- unicode (LoadError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
    from /usr/lib/ruby/1.8/irb/init.rb:250:in `each'
    from /usr/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
    from /usr/lib/ruby/1.8/irb/init.rb:21:in `setup'
    from /usr/lib/ruby/1.8/irb.rb:54:in `start'
    from /usr/bin/irb:13
    jmccm@ubuntu-base:~$ irb -rrubygems -rUnicode
    /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- Unicode (LoadError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
    from /usr/lib/ruby/1.8/irb/init.rb:250:in `each'
    from /usr/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
    from /usr/lib/ruby/1.8/irb/init.rb:21:in `setup'
    from /usr/lib/ruby/1.8/irb.rb:54:in `start'
    from /usr/bin/irb:13
    jmccm@ubuntu-base:~$


    The Unicode thing seems to be still missing?

  4. #4
    Join Date
    Nov 2008
    Location
    Here, There, Everywhere
    Beans
    1,163
    Distro
    Xubuntu

    Re: Ruby and non-ASCII characters

    Have you installed the unicode gem?
    Code:
    sudo aptitude install rubygems # if not installed
    sudo gem install unicode

  5. #5
    Join Date
    Oct 2007
    Location
    Santiago do Escoural
    Beans
    23
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Ruby and non-ASCII characters

    Quote Originally Posted by danielrmt View Post
    Have you installed the unicode gem?
    Code:
    sudo aptitude install rubygems # if not installed
    sudo gem install unicode
    We're not quite there yet...

    Code:
    leader@toshiba-ubuntu:~$ sudo gem install unicode
    Building native extensions.  This could take a while...
    ERROR:  Error installing unicode:
    	ERROR: Failed to build gem native extension.
    
    /usr/bin/ruby1.8 extconf.rb install unicode
    extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
    	from extconf.rb:1
    
    Gem files will remain installed in /var/lib/gems/1.8/gems/unicode-0.1 for inspection.
    Results logged to /var/lib/gems/1.8/gems/unicode-0.1/ext/gem_make.out
    Last edited by xyzt; April 29th, 2009 at 02:14 PM.

  6. #6
    Join Date
    Nov 2008
    Location
    Here, There, Everywhere
    Beans
    1,163
    Distro
    Xubuntu

    Re: Ruby and non-ASCII characters

    Quote Originally Posted by xyzt View Post
    We're not quite there yet...
    mkmf... you need to install the ruby1.8-dev package from synaptic to install the gem. It was already installed on my PC (for other gems), so I didn't got that message when installing the unicode gem. Install build-essentials too, if not already installed.

  7. #7
    Join Date
    Oct 2007
    Location
    Santiago do Escoural
    Beans
    23
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Ruby and non-ASCII characters

    Now I'm really at a loss:

    Code:
    leader@toshiba-ubuntu:~$ sudo gem install unicode
    Building native extensions.  This could take a while...
    Successfully installed unicode-0.1
    1 gem installed
    leader@toshiba-ubuntu:~$ irb -rrubygems -runicode
    irb(main):001:0> puts "Olá José António!".reverse
    !oin��tnA ��soJ ��lO
    => nil
    irb(main):002:0>
    build-essential was already installed (for gcc), ruby1.8-dev was the one missing.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •