0

I am passing some French characters in an ajax call to our database. They are expecting É to be passed as %26Eacute%3B, é to be passed as %26eacute%3B, etc. How can I do this in javascript?

Thanks.

Bakudan
  • 19,134
  • 9
  • 53
  • 73
user471317
  • 1,231
  • 2
  • 22
  • 35
  • 3
    I do not believe that any browser has a Javascript transcoding / filtering function that produces XML in a defined charset with the latin-1 chars turned into entities like this. – bmargulies Apr 01 '12 at 22:46
  • Check http://stackoverflow.com/questions/1354064/how-to-convert-characters-to-html-entities-using-plain-javascript – Gert Grenander Apr 01 '12 at 22:56

1 Answers1

2

You could use this htmlentities() function. And then encodeURIComponent on the result.

Demo: http://jsfiddle.net/Rf2rE/

stewe
  • 41,820
  • 13
  • 79
  • 75