html5 - Priority charset detection in web browser -


i need know priority of processing of encoding indication in web browser(html5). answer please sources please.

  1. http header
  2. bom
  3. meta
  4. heuristic / user setting

i dont know number of bom(somewhere second[https://blog.whatwg.org/the-road-to-html-5-character-encoding], somewhere first[how html meta charset works). dont know when browser detects according user setting when heuristic method.

sources: http://www.w3.org/tr/html401/charset.html#h-5.2.2 , http://www.w3.org/tr/html5-diff/#character-encoding , http://www.w3.org/tr/html5/document-metadata.html#charset

big thx.

bom should go before http header. [1][2]

there many official documents that say http header goes before bom. apparently, ignore them , reverse order such latter has higher precedence.

therefore:

  1. bom
  2. http header content-type:
  3. <meta> / @charset css
  4. environment (charset attribute of parent <iframe> , <link> elements, encoding of parent document, etc) and/or heuristics

i'm not quite sure (haven't looked into) precedence within 4.. also, [1] puts "user setting" before bom.

[1] note: step happens before next 1 honoring http content-type header willful violation of http specification, motivated desire maximally compatible legacy content. -- https://www.w3.org/tr/html5/syntax.html#determining-the-character-encoding

[2] note: decode algorithm gives precedence byte order mark (bom), , uses fallback when none found. -- https://www.w3.org/tr/css-syntax-3/#input-byte-stream


Popular posts from this blog