Created
December 16, 2009 03:50
-
-
Save anirudhjoshi/257570 to your computer and use it in GitHub Desktop.
htmlcharacterconvertor.py
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
#!/usr/bin/python | |
# HTML Character Convertor | |
# Replaces HTML entities in a given string - with their correct character. | |
def extractKeyValueToDictionary(fileName): | |
allLines = open(fileName, 'r').readlines() | |
dictionary = {} | |
for line in allLines: | |
key,value=line.split(':') | |
dictionary[key]=value.strip() | |
return dictionary | |
def stringToConvert(string): | |
htmlSpecialCharacters = extractKeyValueToDictionary("spcharhtml") | |
editedString = string | |
for k,v in htmlSpecialCharacters.iteritems(): | |
if string.find(v) != -1: | |
editedString = editedString.replace(v, k) | |
return editedString |
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
–:– | |
—:— | |
¡:¡ | |
¿:¿ | |
":" | |
“:“ | |
”:” | |
‘:‘ | |
’:’ | |
«:« | |
»:» | |
: | |
&:& | |
¢:¢ | |
©:© | |
÷:÷ | |
>:> | |
<:< | |
µ:µ | |
·:· | |
¶:¶ | |
±:± | |
€:€ | |
£:£ | |
®:® | |
§:§ | |
™:™ | |
¥:¥ | |
á:á | |
Á:Á | |
à:à | |
À:À | |
â:â | |
Â:Â | |
å:å | |
Å:Å | |
ã:ã | |
Ã:Ã | |
ä:ä | |
Ä:Ä | |
æ:æ | |
Æ:Æ | |
ç:ç | |
Ç:Ç | |
é:é | |
É:É | |
è:è | |
È:È | |
ê:ê | |
Ê:Ê | |
ë:ë | |
Ë:Ë | |
í:í | |
Í:Í | |
ì:ì | |
Ì:Ì | |
î:î | |
Î:Î | |
ï:ï | |
Ï:Ï | |
ñ:ñ | |
Ñ:Ñ | |
ó:ó | |
Ó:Ó | |
ò:ò | |
Ò:Ò | |
ô:ô | |
Ô:Ô | |
ø:ø | |
Ø:Ø | |
õ:õ | |
Õ:Õ | |
ö:ö | |
Ö:Ö | |
ß:ß | |
ú:ú | |
Ú:Ú | |
ù:ù | |
Ù:Ù | |
û:û | |
Û:Û | |
ü:ü | |
Ü:Ü | |
ÿ:ÿ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment