How to fix javascript encoding problem?

Asked

Viewed 8,147 times

6

I’m running the code below:

alert('Não é possível realizar essa operação sem a seleção de uma banca.');

but it’s showing up like this:

inserir a descrição da imagem aqui

3 answers

5


The problem is not the Javascript database, but the one on the page. Try using <meta charset="utf-8" /> in your section head:

<html lang="pt-br">
<head>
    <meta charset="utf-8" />

Use this tag right after the opening of head, before the title. Depending on the stage of your project and how it was set up, it may be that the charset is not utf-8, and yes iso-8859-1

5

Check in your text editor or ide, what is the default encoding type for new files, after you check you will see that it should be UTF-8 or iso-8859-1 (also called Windows-1252 times). If the file already exists, you can check the encoding via the footer on Notepad++.

Use the meta tag for each case:

Html5

<meta charset="utf-8" />

html4.x

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

You must use UTF-8 or iso-8859-1

4

When this occurs:

  1. Open the file in Notepad++ and convert to UTF-8
  2. I make sure the page has the header <meta charset="utf-8">.

Solves in 90% of cases.

Browser other questions tagged

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