Created
February 7, 2012 22:36
-
-
Save schocco/1762611 to your computer and use it in GitHub Desktop.
encode any string to html
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
# can be used to hide email addresses in the html source of Web sites from spiders | |
def html_encode(email): | |
''' | |
Takes a unicode string as only parameter and returns | |
a sequence of html encoded chars. | |
>>> html_encode(u"[email protected]") | |
'test@website.org' | |
''' | |
list = [] | |
for char in email: | |
list.append("&#%s" % ord(char)) | |
return ";".join(list) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seriously the only example I could find that escapes ALL characters.