3 ms·
> HTML5 defaults to UTF-8 I’m not sure this is correct, though the WHATWG docs[1] are kind of confusing. From what I can tell, it seems like HTML5 documents ar
by wolfgang42 5y ago
> HTML5 defaults to UTF-8
I’m not sure this is correct, though the WHATWG docs[1] are kind of confusing. From what I can tell, it seems like HTML5 documents are required to be UTF-8, but also this is required to be explicitly declared either in the Content-Type header, a leading BOM, or a <meta> tag in the first 1024 bytes of the file. Reading this blog post[2] it sounds like there is a danger that if you don’t do this then heuristics will kick in and try to guess the charset instead; the documented algorithm for this doesn't seem to consider the doctype at all.
[1]: https://html.spec.whatwg.org/dev/semantics.html#charset https://html.spec.whatwg.org/dev/semantics.html#charset
[2]: https://blog.whatwg.org/the-road-to-html-5-character-encoding https://blog.whatwg.org/the-road-to-html-5-character-encodin...