Skip to content Skip to sidebar Skip to footer

How Do I Change The "actual Encoding" Of My HTML Document?

I ran my web page through the W3C HTML validator and received this error. The encoding ascii is not the preferred name of the character encoding in use. The preferred name is

Solution 1:

The HTML5 mode of the validator treats a mismatch between encoding declarations as an error. In the message, “internal encoding declaration” refers to a meta tag such as <meta charset=utf-8>, and “actual encoding” (misleadingly) refers to encoding declaration in HTTP headers.

According to current HTML specifications (HTML5 is just a draft), the mismatch is not an error, and the HTTP headers win.

There is no real problem if your document only contains Ascii characters. Ascii-encoded data is trivially UTF-8 encoded too, because in UTF-8, any Ascii character is represented as a single byte, with the same value as in Ascii.

It depends on the software used server-side whether and how you can change the HTTP headers. If they now specify charset=ascii, as it seems, it is not a real problem except in validation, provided that you keep using Ascii characters only. But it is somewhat odd and outdated. Try to have the encoding information there changed to charset=utf-8. You need not change the actual encoding, but if you later add non-Ascii characters, make sure you save the file as UTF-8 encoded by selecting a suitable command or option in the authoring program.


Solution 2:

Open your file in notepad, then save as > UTF-8 (next to the save button).


Solution 3:

On unix-like system you might use iconv tool to convert file from one encoding to another. It can also be used from the scope of programming language(e.g. php). The proper function has same name: http://www.php.net/manual/en/function.iconv.php


Solution 4:

Specifying encoding is one thing. Saving documents in a proper encoding is another.
Edit your documents in editors supporting UTF-8 encoding. Preferably UTF-8 without BOM. Notepad++ may be a good start.
Have a read too: UTF-8 all the way through.


Post a Comment for "How Do I Change The "actual Encoding" Of My HTML Document?"