UTF-8 code does not work

Asked

Viewed 1,538 times

1

I’m having a problem that seems simple but has given me work here.

I’m developing a single page application using Angularjs, on the page index.html i have the tag <meta charset="UTF-8"/>, and like all the partials are injected into this page, the encoding is replicated to them except for 1 file, outside that I am not being able to replicate the encoding for the Javascript, Alerts and registered messages on console.log are not receiving the encoding.

Does anyone know what could be going on ?

Follows html code:

<html ng-app="WebApp">
<head>
        <meta charset="UTF-8" />
        <title></title>
        <link href="css/style.css" rel="stylesheet" type="text/css" />
        "... demais arquivos css"
</head>
<body ng-controller="mainController">
        <!-- Bibliotecas externas-->
        <!-- Config -->
        <!-- Services -->
        <!-- Controllers -->

        <!-- template do header -->
        <div ng-include="'partials/header.html'"></div>

        <!-- Templates do Angular controlados pelas rotas-->
        <div ng-view></div>

        <!-- template do footer -->
        <div ng-include="'partials/footer.html'"></div>
</body>
</html>
  • 1

    Good morning, all files are saved as UTF8 without GOOD?

  • Yes, I’m saving with utf-8 encoding in sublime text

  • All files, both . js and . html? Could you provide a simple example of the problem to test?

  • I created a Pastebin to make it easier: http://pastebin.com/7704vqHu As you will see, the content is dynamically injected into the ng-view directive, so the partials when they are rendered by the browser will "inherit" this index.html. I have a partial that is nothing more than an ordered list of Buttons that when injected into ng-view gives encoding error of the seated characters, whereas another that is practically identical, the same problem does not happen.

  • But it only has html, we need js too.

  • Already tried with: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> ?

  • Thank you so much for the personal answers, I think the problem had something to do with some sublime configuration error at the time the files were saved, I went back to the initial settings and saved in UTF-8 with BOM and it all worked out.

Show 2 more comments

1 answer

0

Try using the meta tag in the recommended format:

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

Also confirm that your server is not sending a header Content-Type with another value as this would take precedence over the meta tag in your HTML (you can confirm using your browser dev-tools, inspecting each request).

Browser other questions tagged

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