What is the best way to accent words in .js files?

Posted on

Question :

Is there a way to write words the way they are, with their accents?

In php, just use:

<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />

In javascript, the word Informação must be written Informau00e7u00e3o .

Is there an alternative?


Answer :

Set up your text editor (notepad ++, sublime, etc.) to save edits as UTF-8 or charset that you find most appropriate for you.

It is recommended to use a multibyte character set such as UTF-8 (No BOM).

Loading .js files

When loading a JavasScript file, it is also recommended to specify the charset used:

<script src="file.js" charset="utf-8"></script>

Specify the meta tag

In HTML, obviously specify the meta tag:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

The entire environment should be well configured.

If you are using PHP , specify the header:

header('Content-Type: text/html; charset=UTF-8');


  • The <meta> tag is unrelated to PHP. It’s from HTML.

  • This answer addresses the use of UTF-8, however, it does not necessarily mean that it is the best form or final solution. Using UTF-8 is a recommendation to make your application’s charset internationalized because UTF-8 supports multibyte characters.

  • Leave a Reply

    Your email address will not be published. Required fields are marked *