Код:
function htmlspecialchars_decode(string, quote_style) {
// Convert special HTML entities back to characters
//
// version: 901.714
// discuss at: http://phpjs.org/functions/htmlspecialchars_decode
// + original by: Mirek Slugen
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Mateusz "loonquawl" Zalega
// + input by: ReverseSyntax
// + input by: Slawomir Kaniecki
// + input by: Scott Cariss
// + input by: Francois
// + bugfixed by: Onno Marsman
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// - depends on: get_html_translation_table
// * example 1: htmlspecialchars_decode("<p>this -> "</p>", 'ENT_NOQUOTES');
// * returns 1: '<p>this -> "</p>'
var histogram = {}, symbol = '', tmp_str = '', entity = '';
tmp_str = string.toString();
if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
return false;
}
// & must be the last character when decoding!
delete(histogram['&']);
histogram['&'] = '&';
for (symbol in histogram) {
entity = histogram[symbol];
tmp_str = tmp_str.split(entity).join(symbol);
}
return tmp_str;
}