JQuery when adding text to html charset utf8 not working

When I pass information to a div inside html, charset utf 8 is not recognized, and it comes with polling points inside the text. Is there a way to force charset utf 8 inside jquery so that all the text passed to the script gets into the correct encoding?

Edit: I think I installed all the encodings I could use in all my files: HTML

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type:application/json; charset=UTF-8" />
<script type="text/javascript" src="scripts/jquery-1.9.0.min.js" charset="utf-8"></script>
<script type="text/javascript" src="message_validator.js" charset="utf-8"></script>
</head>
<body>
<div class="error_display" charset="utf-8"></div>
<form charset="utf-8">
<input type="text" id="name" class="textbox" name="name" minlength="2" maxlength="12" />
</form>
</body>

JQuery

 $(document).ready(function() {
    $(document).load("Content-Type:application/json; charset=UTF-8");
    $('.submit').click(function(){
        var errorlist = [];
        errorlist.length = 0;

        errorlist.push("- Tem de preencher os campos obrigat&#243;rios.");

         if(errorlist.length >= 1){
            $('.error_display').animate({'height':errorlist.length*20}, {queue:false, duration:500});
            for(var i = 0; i < errorlist.length; i++) {
                $('.error_display').append(errorlist[i]+"<br/>");
            }

         }
    });
});
+5
source share
2 answers

Place the text with the correct characters, and then try to decode it as follows:

errorlist.push(decodeURIComponent(escape("- Tem de preencher os campos obrigatórios.")));

Check also these examples for encoding / decoding text here.

+2
source

. , UTF8 .

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

, ( , OP) UTF-8.

+1

All Articles