Reputation: 10974
I'm using Google Translate API, and if I try to translate Mc Donald's this is what I get as a result:
Mc Donald's
How can I translate '
to '
-- in JavaScript -- and so on for any other numeric character reference?
Thanks!
Upvotes: 0
Views: 730
Reputation: 91
JS libraries often have helper api's for this, Prototype for example has its unescapeHTML() function on String that works perfect, notice the examples:
http://prototypejs.org/api/string/unescapeHTML
Upvotes: 1
Reputation: 39168
Shouldn't something like this do it?
'Mc Donald's'.replace(/&#(\d+);/g, function(m, g) {
return String.fromCharCode(g);
});
Upvotes: 0
Reputation: 27884
Check those two:
Javascript equivalent for PHP's html_entity_decode
And its dependence:
Javascript equivalent for PHP's get_html_translation_table
Upvotes: 1