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

Asked

Viewed 367 times

3

There is 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 should be written like this Informa\u00e7\u00e3o.

There is an alternative?

  • The default accepted by all browsers for HTML5 is utf-8. do not use iso-8859-1. And write the normal word without treating the characters.

1 answer

4


Set up your text editor (Notepad++, sublime, etc.) to save edits as UTF-8 or the charset you find most suitable for your case.

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, of course, specify the meta tag:

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

The whole environment should be well configured.

If you are using PHP, specify the header:

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

Remarks:

  1. The tag <meta> has no relation to PHP. It’s HTML.

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

  • Thank you.......

Browser other questions tagged

You are not signed in. Login or sign up in order to post.