Created
October 3, 2009 19:02
-
-
Save adhusson/200818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "iconv" | |
class String | |
def to_ascii | |
self.strip.to_ascii_ugly.tr("^a-zA-Z0-9 ","*").tr_s("*","") | |
end | |
# à => `a | |
# é => 'e | |
def to_ascii_ugly | |
Iconv.iconv("ascii//translit", "utf-8", self)[0] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment