On 13 Apr 2008, at 23:01, Erik L. wrote:
I need to convert strings with international characters to strings
with corresponding ASCII codes. For example Ã©, Ã¨, Ã«, and Ãª (and all
other e-related versions) should convert to e and so on.
Does anyone have a good solution on this?
Create a file core_extensions.rb in /lib/ and stick this in:
Iconv.iconv(“ASCII//IGNORE//TRANSLIT”, “UTF-8”, self).join.sanitize
self.gsub(/[^a-z._0-9 -]/i, “”).downcase
Restart your rails server to load the file. Then when you want to
convert the string, you just do something like “ThÃ¯s Ã¯s Ã
tÃ©ststrÃ¯ng”.to_ascii and it will convert the characters to their ascii
Peter De Berdt