views:

225

answers:

2

What is the simplest way for transliteration of non English characters in ruby. That is conversion such as:

translit "Gévry"
#=> "Gevry"

+4  A: 

Ruby has an Iconv library in its stdlib which converts encodings in a very similar way to the usual iconv command

Gareth
Yeah.. `Iconv.iconv('ascii//ignore//translit', 'utf-8', string).to_s` does the job.
Selva
+3  A: 

Try taking a look at this script from TechniConseils which replaces accented characters in a string. Example of usage:

"Gévry".removeaccents #=> Gevry
dismal_denizen