Created
January 24, 2012 10:27
-
-
Save np422/1669511 to your computer and use it in GitHub Desktop.
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
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