Convert special characters HTML entities
Convert special characters HTML entities
In Editor,
1. in edit mode if the content was saved as HTML entities, it does not convert back during display.
2. while save it should provide an option to convert the special characters to HTML entities. I am using this function to do that on each object property. But it seems a desirable feature.
String.prototype.HTMLEncode = function(str) {
var result = "";
var str = (arguments.length===1) ? str : this;
str = str.replace(/"/g, '\"')
for(var i=0; i<str.length; i++) {
var chrcode = str.charCodeAt(i);
result+=(chrcode>127 || chrcode==34 || chrcode==39 || chrcode==60 || chrcode==62 || chrcode==96) ? "&#"+chrcode+";" : str.substr(i,1)
}
return result;
}
Do we have this already available?
Answers
And I updated the "set" function to from
// this._typeFn( 'set', val );
to
// this._typeFn( 'set', $.parseHTML(val)[0].textContent );
for the decoding while display edit.