views:

100

answers:

3

hi, im 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!

A: 

Shouldn't something like this do it?

'Mc Donald's'.replace(/&#(\d+);/g, function(m, g) {
  return String.fromCharCode(g);
});
kangax
worked! thanks again!
andufo
A: 

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