2

In CSS, you can declare the text encoding of the CSS file using the @charset at-rule at the very top of the file. For example:

@charset "UTF-8";

(See http://www.w3.org/International/questions/qa-css-charset.en.php).

Is there a similar mechanism for JavaScript files? (Aside from the Content-Type HTTP header.)

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
  • possible duplicate of [How to declare character encoding in an INDIVIDUAL JS file?](http://stackoverflow.com/questions/8833231/how-to-declare-character-encoding-in-an-individual-js-file) – Paul D. Waite Jan 12 '14 at 18:18

2 Answers2

1
<!-- I normally use this meta tag -->
<head>
    <meta charset="utf-8">
    <!-- ... -->
</head>

<script type="text/javascript" charset="utf-8" src="path/to/your/file.js"></script>
rusben
  • 646
  • 1
  • 6
  • 13
0

In the absence of this being closed as a duplicate: no, there’s not.

See How to declare character encoding in an INDIVIDUAL JS file?

Community
  • 1
  • 1
Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270