Sep 19, 2015

HTML Encode Issues

Sometimes while navigating on internet, or as a developer, you see strange characters, and then you wonder, what the hell is happening ? where is the problem? my browser, computer or the page itself ? look here how to solve this problem!

The problem occurs when the HTML page file contains characters encoded with a different format of that which the browser is using to read, displaying them incorrectly. For example, the HTML page is encoded with "Windows-1262" format, but the browser is reading as "UTF-8", then you will see things like this:
The solution is simple, the HTML file and browser encode format must match, for example, both using UTF-8. But how can this be done? in the HTML header tag insert the 'charset' meta tag, that tells to the browser what is its encoded format:

<meta charset="UTF-8" />

And in the editor used to save the HTML file, set the encode format to UTF-8 too. For example, in the Eclipse IDE:

Notepad++ editor:

Now with both, HTML file and browser using the same encode format you can see the characters correctly:
That's all !

About the versions
  • Eclipse Java EE IDE  Luna (4.4.1)
  • Notepad++ 6.5.5

0 comentários :

Post a Comment