3 ms·
The WHATWG HTML spec [1] has various heuristics it uses/specifies for detecting the character encoding. In point 8, it says an implementation may use heuristic
by rhdunn 3y ago
The 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...