Created
October 4, 2012 21:16
-
-
Save afcapel/3836513 to your computer and use it in GitHub Desktop.
Encoding text to ASCII with custom fallbacks
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
# encoding: utf-8 | |
substitutions = Proc.new do |c| | |
case c | |
when 'ñ' then 'n' | |
when 'í' then 'i' | |
else '?' | |
end | |
end | |
puts 'Las castañas son asín o asá'.encode('ASCII', invalid: :replace, crlf_newline: true, fallback: substitutions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment