Special character in "entrée" cannot be displayed correctly if defined in a separate javascript file


The following string is defined in a json.js file.

var test = "One complimentary entrée with the purchase of an entrée.";

It is included in an index.html file by

  <script type="text/JavaScript" src="./json.js"></script>

When the string is displayed in UI, it shows up as

"One complimentary entr�e with the purchase of an entr�e."

But if string is defined directly in the index.html, then it is not a problem.

Can anyone suggest a solution on how to keep the text in the separate .js file?


Make sure that the included file is saved using the same encoding as the page.

If for example the page is saved as UTF-8, the included file will also be loaded as UTF-8.

Escape the non-Latin character to an HTML entity, &eacute; or change all aspects your development system and code editors to parse all text characters as UTF8.

Need Your Help

javascript - identify image paint complete in browser

javascript javascript-events

Incase of a high resolution image load in browser, even after network got the image from server. Browser taking some time to display them as it paints gradually.