Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Ruby in practice question: Do UTF-8 and Ruby fit well in practice?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you done any project using Ruby language that required UTF-8 support and do you think that Ruby lacks internationalization support?
 
Author
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For internationalization, there are several libraries to choose from. The one I'm most familiar with is [url=http://github.com/mattetti/i18n]i18n[/url], which I use as part of Rails.
 
Author
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ruby 1.9 includes some internationalization features, and Rails has recently added a LOT of great internationalization features.
 
Dragan Stankovic
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

My first project in ruby was simple site scraper using hpricot. Code sample that I tried to use seemed simple and straightforward. And then, because I tried to scrap a cyrillic site I run into problems which I couldn't solve. Xml parser started to throw errors, converting characters with iconv didn't work (or at least I couldn't make it work). So I gave up of doing this with ruby. I made that scraper in a matter of minutes using HtmlUnit (Java library)..

I'll give ruby another chance as soon as I have more time, but I was curious if the problem was with my lack of experience with ruby or (as I read at several forums) bad internationalization support in ruby. Anyway, as you pointed it out, it seems that they fixed the problems they had with earlier ruby versions so we'll see.
 
Assaf Arkin
Author
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might need to set $KCODE = 'U' in your script to tell Ruby to use UTF-8 by default.
 
Being a smart alec beats the alternative. This tiny ad knows what I'm talking about:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic