I have a HTML source field and a markup text field. What HTML I write and submit according to that the markup field changes. When I reopen the html field area it just gives the HTML source code of that markup field. Now the issue is, for every thing else except some escaped characters it is giving the correct html. But for escaped characters it is not working properly.
e.g.: for a white space source field is returning <p> </p>
But for copyright © sign, instead of returning <p> © </p>
, it is returning <p>©</p>
So is there any in-built function in JS that returns the HTML part for escaped characters from a string?
I even tried this:
function multiLineHtmlEncode(value) {
var lines = value.split(/\r\n|\r|\n/);
for (var i = 0; i < lines.length; i++) {
lines[i] = htmlEncode(lines[i]);
}
return lines.join('\r\n');
}
function htmlEncode(value) {
return jQuery('<div/>').text(value).html();
}
but not working.