This question already has an answer here:
I have some server side code in PHP
which looks like this
$var2 = htmlspecialchars($var1);
For example,
"It's Monday" gets converted to "It's Monday"
I am not able to decode the text back in javascript using the function unescape.
unescape("It's Monday") // returns "It's Monday"
How can i decode this in javascript to get the original string back, apart from using replace (because this way i'd have to manually handle all special cases) ?
</div>
You can assign the html-encoded text to an dummy element and get back it's text, to do this:
$('<span/>').html("It's Monday").text()
returns "It's Monday"
Note: The above does not modify the DOM (unlike I said before I edited the answer)