Skip to content

Instantly share code, notes, and snippets.

@samuelkadolph
Created September 7, 2011 17:45
Show Gist options
  • Save samuelkadolph/1201233 to your computer and use it in GitHub Desktop.
Save samuelkadolph/1201233 to your computer and use it in GitHub Desktop.
Turn "\\u2603" to "☃" in ruby without eval
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