pheromix
pheromix

Reputation: 19347

accentuated letters are not well formated inside an alert?

The text of the alert contains accentuated letters :

alert("Le type de question '" + _oDispo.zTypeQuestion + "' existe déjà dans notre base de données !") ;

enter image description here

How to format the text to make it well formated ?

Upvotes: 0

Views: 25

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075129

It would appear that the character set used in your JavaScript isn't being correctly identified to the browser.

Ensure that

  1. The JavaScript file really is saved in the encoding you think it's saved in (UTF-8 is a good choice); you'd do this in your text editor's save dialog and/or saving settings.

  2. The web server is serving that JavaScript file with the correct charset in the mime type, e.g. application/javascript; charset=UTF-8 (if you're using UTF-8).

  3. I don't think it matters in this particular case, but in general I find it simpler to ensure that both the JavaScript and the HTML use the same character set, and that that character set is correctly identified when serving the HTML as well as when serving the JavaScript. (But I don't think that matters here.)

Provided you do that, the characters in the JavaScript will be correctly interpreted by the JavaScript engine, and passed correctly to the browser for display in the alert.

More on the general problem (not the specifics of solving it): The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Upvotes: 2

Related Questions