Created
July 11, 2012 19:54
-
-
Save tiegz/3092853 to your computer and use it in GitHub Desktop.
utf8 helper for 1.8/1.9 upgrade
This file contains hidden or 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
# A simple string helper compatible with both 1.8 and 1.9. Avoids | |
# duplication of force_encoding('utf-8'). | |
class String | |
def utf8 | |
respond_to?(:force_encoding) ? force_encoding('utf-8') : self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment