38 ms·
Since HTML5 UTF-8 is the default charset. And for headers, they are parsed as ASCII encoded in almost all cases although ISO-8859-1 is supported.
by ko27 3y ago
Since HTML5 UTF-8 is the default charset. And for headers, they are parsed as ASCII encoded in almost all cases although ISO-8859-1 is supported.
- fulafel 3y agoI tried to find confirmation of this but found only: https://html.spec.whatwg.org/multipage/semantics.html#charset https://html.spec.whatwg.org/multipage/semantics.html#charse... > The Encoding standard requires use of the UTF-8 character encoding and requires use of the "utf-8" encoding label to identify it. Those Sounds to me like it tells you that you have to explicitly declare the charset as UTF-8, so you don't get the HTTP default of Latin-1. (But that's just one "living standard" not exactly synonymous with with HTML5 and it might change, or might have been different last week..)
- ko27 3y ago> so you don't get the HTTP default of Latin-1. That's not what your linked spec says. You can try it yourself, in any browser. If you omit the encoding the browser uses heuristics to guess, but it will always work if you write UTF-8 even without meta charset or encoding header.
- fulafel 3y agoI don't doubt browsers use heuristics. But spec-wise I think it's your turn to to provide a reference in favour of a utf-8-is-default interpretation :)
- ko27 3y agoNo it isn't. My original point is that Latin-1 is used very rarely on Internet and is being phased out. Now it's your turn to provide some references that a significant percentage of websites are omitting encoding (which is required by spec!) and using Latin-1. But if you insist, here is this quote: https://www.w3docs.com/learn-html/html-character-sets.html https://www.w3docs.com/learn-html/html-character-sets.html > UTF-8 is the default character encoding for HTML5. However, it was used to be different. ASCII was the character set before it. And the ISO-8859-1 was the default character set from HTML 2.0 till HTML 4.01. or another: https://www.dofactory.com/html/charset https://www.dofactory.com/html/charset > If a web page starts with <!DOCTYPE html> (which indicates HTML5), then the above meta tag is optional, because the default for HTML5 is UTF-8.
- bawolff 3y ago> My original point is that Latin-1 is used very rarely on Internet and is being phased out. Nobody disagrees with this, but this is a very different statement from what you said originally in regards to what the default is. Things can be phased out but still have the old default with no plan to change the default. Re other sources - how about citing the actual spec instead of sketchy websites that seem likely to have incorrect information.
- rhdunn 3y agoThe WHATWG HTML spec [1] has various heuristics it uses/specifies for detecting the character encoding. In point 8, it says an implementation may use heuristics to detect the encoding. It has a note which states: > The UTF-8 encoding has a highly detectable bit pattern. Files from the local file system that contain bytes with values greater than 0x7F which match the UTF-8 pattern are very likely to be UTF-8, while documents with byte sequences that do not match it are very likely not. When a user agent can examine the whole file, rather than just the preamble, detecting for UTF-8 specifically can be especially effective. In point 9, the implementation can return an implementation or user-defined encoding. Here, it suggests a locale-based default encoding, including windows-1252 for "en". As such, implementations may be capable of detecting/defaulting to UTF-8, but are equally likely to default to windows-1252, Shift_JIS, or other encoding. [1] https://html.spec.whatwg.org/#determining-the-character-encoding https://html.spec.whatwg.org/#determining-the-character-enco...