Skip to content

Instantly share code, notes, and snippets.

@ecarnevale
Created February 17, 2009 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarnevale/65633 to your computer and use it in GitHub Desktop.
Save ecarnevale/65633 to your computer and use it in GitHub Desktop.
Translit for Rails using ActiveSupport. (convert é in e and other utf8 codes in latin chars)
# from http://snippets.dzone.com/posts/show/5609
class String
def translit
ActiveSupport::Multibyte::Handlers::UTF8Handler.normalize(self,:d).split(//u).reject { |e| e.length > 1 }.join
end
end
Other solutions by Obie Fernandez: http://www.jroller.com/obie/tags/unicode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment