web page encoding, with contradictory settings [du

2019-07-09 16:19发布

This question already has an answer here:

If a web page has,

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
…
</head>

but the http header has

Content-Type    text/html; charset=UTF-8

Then what encoding is assumed?

标签: html http web
1条回答
可以哭但决不认输i
2楼-- · 2019-07-09 16:31

In HTML5 the priority is defined as:

  1. User browser setting
  2. Byte order mark
  3. HTTP header
  4. <meta http-equiv="Content-Type"> or <meta charset> depending on attribute order.
  5. Browser default for the locale.

See http://www.w3.org/html/wg/drafts/html/master/syntax.html#determining-the-character-encoding for the gory details.

查看更多
登录 后发表回答