Created
September 7, 2011 17:45
-
-
Save samuelkadolph/1201233 to your computer and use it in GitHub Desktop.
Turn "\\u2603" to "☃" in ruby without eval
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
class String | |
def parse_unicode | |
dup.parse_unicode! | |
end | |
def parse_unicode! | |
gsub!(/\\u([0-9a-fA-F]{4})/) { [$1.to_i(16)].pack("U") } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment