Skip to content

Instantly share code, notes, and snippets.

@ninowalker
Created December 15, 2011 20:28
Show Gist options
  • Save ninowalker/1482729 to your computer and use it in GitHub Desktop.
Save ninowalker/1482729 to your computer and use it in GitHub Desktop.
Convert HTML entities to unicode
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