Skip to content

Instantly share code, notes, and snippets.

@nofxx
Created August 9, 2008 04:31
Show Gist options
  • Save nofxx/4649 to your computer and use it in GitHub Desktop.
Save nofxx/4649 to your computer and use it in GitHub Desktop.
class String
ACCIDENTS = {
:a => %w{ ã á â },
:e => %w{ é ê },
:i => %w{ í },
:o => %w{ õ ó ô },
:u => %w{ ú },
:c => %w{ ç }
}
def to_ascii
ACCIDENTS.each_pair do |key, val|
val.each { |v| self.gsub!(v.to_s , key.to_s) }
end
self
end
end
puts "óãõáçeãúi".to_ascii # => oaoaceaui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment