DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Matt has posted 1 posts at DZone. View Full User Profile

String Translit For Rails

06.06.2008
| 6992 views |
  • submit to reddit
        // Translit for Rails using ActiveSupport. (convert é in e and other utf8 codes in latin chars)

class String
  def translit
    ActiveSupport::Multibyte::Handlers::UTF8Handler.normalize(self,:d).split(//u).reject { |e| e.length > 1 }.join
  end
end