Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 us-ascii. (Charmod C024) ✉ Line 5, Column 70: Internal encoding declaration utf-8 disagrees with the actual encoding of the document (us-ascii).

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

Apparently, I am not "actually" using UTF-8 even though I specified UTF-8 in my meta tag.

How do I, well, "actually" use UTF-8? What does that even mean?

like image 263
dangerChihuahua007 Avatar asked Oct 13 '25 04:10

dangerChihuahua007


2 Answers

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.

like image 142
Jukka K. Korpela Avatar answered Oct 14 '25 20:10

Jukka K. Korpela


Open your file in Notepad, and then Save asUTF-8 (next to the Save button).

like image 20
Derek 朕會功夫 Avatar answered Oct 14 '25 19:10

Derek 朕會功夫