Created
December 15, 2011 20:28
-
-
Save ninowalker/1482729 to your computer and use it in GitHub Desktop.
Convert HTML entities to unicode
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
import htmlentitydefs | |
import re | |
def unescape_entities(m): | |
return unichr(htmlentitydefs.name2codepoint[m.group(1)]) | |
print re.sub(r'&(\w+);', unescape_entities, "× ™Foo&bar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment