Skip to content

Instantly share code, notes, and snippets.

@np422
Created January 24, 2012 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save np422/1669511 to your computer and use it in GitHub Desktop.
Save np422/1669511 to your computer and use it in GitHub Desktop.
class String
def _dump level
#Strings are sometimes frozen, dup-i-dup before we can encode
begin
self.dup.encode Encoding::ASCII_8BIT
rescue
self.dup.force_encoding Encoding::ASCII_8BIT
end
end
def self._load args
if args.respond_to? :encode
begin
args.encode Encoding::UTF_8
rescue
args.force_encoding Encoding::UTF_8
end
else
args
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment