Make all javascript read utf-8 or iso-8859-1 character

Asked

Viewed 1,077 times

0

I have a file js, in which I minify to perform the proper tasks. What happens whenever I add this js on my pages, where it is called, the characters of the Portuguese language become illegible. So I think either the missing or the UTF-8 or the ISO-8859-1. But the question is, how do I put these calls in a single place in my file js, so that any function within the file makes use of these includes. A single read. I would not like that in each method I put this call, unless there is no way. Example below, I put only a part of my file js, the start and part of one of the existing functions:

var tituloMultiBrowser;

(function () {
    window.showModalDialog = window.showModalDialog || function (url, arg, opt) {
        url = url || '';                                     //URL
        arg = arg || null;                                   //Argumentos
        opt = opt || 'dialogWidth:300px;dialogHeight:200px'; //Opções: dialogTop;dialogLeft;dialogWidth;dialogHeight/CSS styles

        //Função Chamadora
        var caller = showModalDialog.caller.toString();

        var doc;

        var i = 0;

        if (window.parent.name == 'JANELASIS') {
            doc = window.parent.document;
        }
        else {
            var janela = window.parent.name;
            var janelaPai = window.parent;
            while (janela != 'JANELASIS' && i <= 20) {
                janelaPai = janelaPai.parent;
                janela = janelaPai.parent.name;
                i++;
            }
            doc = janelaPai.parent.document;
        }
..............................
}
  • Why don’t you standardize everything for UTF-8?

  • The issue is not in being utf or iso, but where. I already did, but as what I did is the same thing posted by Gabriel Rodrigues, I decided to mark his answer, because he gave me the same solution that I had found. Thank you.

  • 1

    That’s why I talked about standardizing everything for UTF-8, adding BOM to the files it solves. HTML5 even added a rule where BOM overrides any character statement in the body of the document. http://www.w3.org/International/questions/qa-byte-order-mark.en.php

  • Just out of curiosity, the UTF-8 zoomed in here. I only got it with ISO-8859-1. I don’t know, technically, what each of them does differently from the other, but one went right and the other didn’t.

  • ISO 8859 1 is extended ASCII where normal ASCII uses only 7 bits, the extended adds 1 more. There are several of them, UTF8 which is one of the Unicode representations (there are others, UTF16, UTF32...) supports all existing languages on the planet and even some false (Klingon). The theme is a bit confusing at first, this article http://www.joelonsoftware.com/articles/Unicode.html helps to understand the differences.

1 answer

1


we usually define in tag meta of the site : <meta charset="utf-8"> but I think you can do something like:

<script type="text/javascript" src="[path]/lang.js" charset="utf-8"></script>
  • There are still two frames that does not correctly load the pages inside it, talking about the characters.

  • at the beginning of the page you call the iframe this with charset="utf-8" ?

  • utf-8 is not cool, only with 8859-1. I do not know why, but it did not work utf-8.

  • you are using which html ?

  • Dude, this site started to be designed in the late 90s and early 2000s. Since then, it has had several hands and changes. It has everything here, except html 5. Just to give you an idea, now that they are adapting to the use of Chrome (our mission here), because until then it ran only in IE and very old versions. It’s a challenge. A mix of everything, like: ASP, Asp.Net, Java. Calling each other, this is what I know. Desktop applications in Delphi to chat with the site, is a mixtion.

Browser other questions tagged

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