When I'm passing information to a div inside html the charset utf 8 is not recognized and it comes with interrogation points inside the text. Is there a way to force the charset utf 8 inside jquery so all the text passed by the script comes in the correct charset?
Edit: I think I set all the charsets I could inside 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ó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/>");
}
}
});
});
Put your text with the correct characters and then try to decode it like this:
errorlist.push(decodeURIComponent(escape("- Tem de preencher os campos obrigatórios.")));
Check also those examples to encode/decode the text here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With