From: Martin DeMello Date: 2006-01-25T00:48:52+09:00 Subject: Re: remove non-ASCII characters in a string Dave Burt wrote: > > tranmap.inject(self) do |str, (utf8, asc)| > p [utf8, asc] > str.gsub(utf8, asc) > end > end > end > > "I�t�rn�ti�n�liz�ti�n".utf8_trans_unaccent #=> "Internationalizaetion" # one time preprocessing INTL, ASC = "", "" tranmap.each {|k,v| INTL << k ASC << v } # quicker than repeated gsubs: str.tr(INTL, ASC) martin