Is there js function that replace xml Special Character with their escape sequence?
I have used this:
function htmlSpecialChars(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
There's an interesting JS library here: Client side HTML encoding and decoding
You could use PHP's htmlspecialchars
from the PHPJS project.