From: Christian Neukirchen Date: 2006-01-25T03:38:20+09:00 Subject: Re: remove non-ASCII characters in a string pere.noel@laponie.com.invalid (Une b�vue) writes: > Dave Burt wrote: > >> My version might look like this: >> >> NON_ASCII = /[\x80-\xff]/ >> "I�t�rn�ti�n�liz�ti�n".gsub(NON_ASCII, "?") #=> "I?t?rn?ti?n?liz?ti?n" > > i'd like not to remove no-ascii chars but replace all accentuated chars > (in an UTF-8 string) by them non-accentuated counterpart : > > � => e > � => a > � => c > > [...] > > what is the best way to do that in Ruby? How about this: require 'iconv' puts Iconv.open("ASCII//TRANSLIT", "ISO-8859-1").iconv("I�t�rn�ti�n�liz�ti�n") #=> I~nt"ern^ati^on`alizaetion > une b�vue -- Christian Neukirchen http://chneukirchen.org