Created
January 22, 2018 18:03
-
-
Save kingsleyh/e00be6f62a10598e10d6dd50d9b25c41 to your computer and use it in GitHub Desktop.
ensure_ascii_compatible_encoding
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
def ensure_ascii_compatible_encoding(string, options = nil) | |
if string.encoding.ascii_compatible? | |
string | |
else | |
string.encode(Encoding::UTF_8, options || {:invalid => :replace, :undef => :replace}) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment