I wrote this extension to String a long time ago. I think it does what you want.
require 'iconv' class String def pretty_url Iconv.iconv("ASCII//IGNORE//TRANSLIT", "UTF-8", self).join.sanitize rescue self.sanitize end def sanitize self.gsub(/[^a-z._0-9 -]/i, "").tr(".", "_").gsub(/(\s+)/, "_").dasherize.downcase end end Thibaut Barrère wrote: > Hi! > > I could not find it so far - but maybe rails i18n is the right list for > that > question: is there something already available somewhere in the ruby > space > to remove accents and other diacritics from a string ? (like: > translation > éphémère to ephemere, etc) > > I've seen the mephisto PermalinkFu trick (iconv from utf-8 to > ascii//ignore//translit) but it doesn't work on my workstation. > > I've attached DiacriticsFu which I wrote and is working fine for me - > I'd be > happy to find something cleaner, cross-platform, and which does not rely > on > Rails like this implementation (it would most likely work with unicode > hacks) > > any hint, comment, link, idea ? > > cheers > > Thibaut -- Posted via http://www.ruby-forum.com/. _______________________________________________ Railsi18n-discussion mailing list Railsi18n-discussion@rubyforge.org http://rubyforge.org/mailman/listinfo/railsi18n-discussion