adib16
adib16

Reputation: 1697

Charset UTF-8 for external JavaScript file

I add an external JavaScript file like this:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <script charset="utf-8" type="text/javascript" src="js/panel.js" ></script>
</head>

But the text stored in panel.js file is displayed like this in the HTML file:

H69�*

When I put JavaScript code in the HTML page, the text is displayed properly. But when I put JavaScript code in panel.js, it does not work.

Upvotes: 2

Views: 3933

Answers (2)

costamatrix
costamatrix

Reputation: 710

in the mac OS it is a capital -i...like this:

file -I

Upvotes: 0

exoddus
exoddus

Reputation: 2340

Then the file maybe is not properly saved as UTF-8.

$ file -i panel.js

What's the output?

If you use, for example Vi, open the file and save it with:

:w ++enc=utf-8 %

Upvotes: 6

Related Questions