translit string (americanize)
require 'iconv' class String def translit self.gsub(/[^\x20-\x7f]/){ Iconv.iconv('us-ascii//IGNORE//TRANSLIT', 'utf-8',$&)[0].sub(/^[\^`'"~](?=[a-z])/i, '')} end end
DZone Snippets > caffo > string
12358 users tagging and storing useful source code snippets
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
require 'iconv' class String def translit self.gsub(/[^\x20-\x7f]/){ Iconv.iconv('us-ascii//IGNORE//TRANSLIT', 'utf-8',$&)[0].sub(/^[\^`'"~](?=[a-z])/i, '')} end end