Skip to content

Instantly share code, notes, and snippets.

@tiegz
Created July 11, 2012 19:54
Show Gist options
  • Save tiegz/3092853 to your computer and use it in GitHub Desktop.
Save tiegz/3092853 to your computer and use it in GitHub Desktop.
utf8 helper for 1.8/1.9 upgrade
# 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