Created
October 7, 2016 09:38
Decodes html entities back to normal html
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
function decodeHtmlEntities(str) { | |
console.log(str); | |
var special = { | |
"<" : "<", | |
">" : ">", | |
""" : '"', | |
"'" : "'", | |
"'" : "'", | |
"&" : "&", | |
"\\" : "" | |
}; | |
for(var i in special){ | |
while(str.indexOf(i) !== -1){ | |
str = str.replace(i, special[i]); | |
} | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment