I have some Javascript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form:
I use this in my project: inspired by other answers but with an extra secure parameter, can be useful when you deal with decorated characters
var decodeEntities=(function(){
var el=document.createElement('div');
return function(str, safeEscape){
if(str && typeof str === 'string'){
str=str.replace(/\
And it's usable like:
var label='safe character éntity';
var safehtml=''+decodeEntities(label, true)+'';