odd characters when printing in the textarea

Asked

Viewed 683 times

2

I’m having trouble printing the characters correctly. if I write anything inside the html, the characters are normal. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  • if I write a text with special characters in javascript and have it printed in a textarea: "Referral", this ends up returning in the textarea Indicação

    document.getElementById('textarea').value = "Indicação";
    

You have some way of printing that, right? the only way to print "right" is by doing what the guy on this blog said? http://marcelomaidden.blogspot.com.br/2012/11/como-colocar-acentuacao-em-alerts.html

  • Javascript is in an external file?

  • <script type="text/javascript" src="js/teste.js" charset="ISO-8859-1"></script> yes. I tried to do something like, but I couldn’t.

  • @João on the Meta tag you put UTF-8, and in the javascript example you put ISO-8859-1, I don’t know much about Charsets, but it shouldn’t be the same?

  • did not work if I put the same values.

  • 2

    See if the Javascript file is encoded as ISO-8859-1. This already happened to me, the PHP scripts had the accents broken because the HTML was in UTF-8 and the scripts in ISO-8859-1 (even with the header pointing UTF-8). To convert the files you can use Notepad++ or any other text editor. In Notepad++: Menu > Encoding > Enconde in UTF-8 without BOM

2 answers

0


John, the problem is that your file Charsets are incompatible.

I don’t know the editor you are using, but to avoid problems, you should save all files with the same charset, preferably UTF-8.

And to ensure browser compatibility, I still use the tag <meta charset="utf-8" /> shortly after <head> in my html file.

You can use the Notepad++ [http://notepad-plus-plus.org/download] to check the charset of your files and even convert. (menu "Format").

-2

in my case the solutions were not solving this problem. It had been missing to configure the language in the html file(tag html lang="en").

That solved the problem.

Browser other questions tagged

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