If you look at the documentation, it needs a regular expression. Does '\u00a0' work?
Perhaps something like the following?
//escape:
var entityMap = {
"&": "&",
"<": "<",
">": ">",
'"': '"',
"'": ''',
"/": '/'
};
function escapeHtml(string) {
return String(string).replace(
/[&<>"'\/]/g,
function (s) {
return entityMap[s];
}
);
}
console.log(escapeHtml("1 & 2"));
//unescape
function decodeEntities(encodedString) {
var textArea = document.createElement('textarea');
textArea.innerHTML = encodedString;
return textArea.value;
}
console.log(decodeEntities('1 & 2')); // '1 & 2'
Actually I discovered a Before commit on the object which overwrited the change. Initial expression of me works.