0

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!

Alyona Yavorska
5792 gold badges14 silver badges20 bronze badges
asked Sep 4, 2009 at 2:42

3 Answers 3

1
answered Sep 4, 2009 at 3:22
Sign up to request clarification or add additional context in comments.

Comments

1

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

answered Sep 4, 2009 at 3:36

Comments

0

Shouldn't something like this do it?

'Mc Donald's'.replace(/&#(\d+);/g, function(m, g) {
 return String.fromCharCode(g);
});
answered Sep 4, 2009 at 3:27

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.