Accept-Charset

这篇翻译不完整。请帮忙从英语翻译这篇文章

Accept-Charset  请求HTTP头通知客户端能够理解哪一个的字符集。 Using content negotiation, the server then selects one of the proposals, uses it and informs the client of its choice within the Content-Type response header. Browsers usually don't set this header as the default value for each content type is usually correct and transmitting it would allow easier fingerprinting.

If the server cannot serve any matching character set, it can theoretically send back a 406 (Not Acceptable) error code. But, for a better user experience, this is rarely done and the more common way is to ignore the Accept-Charset header in this case.

In early versions of HTTP/1.1, a default charset (ISO-8859-1) was defined. This is no more the case and now each content type may have its own default.

Header type Request header
Forbidden header name yes

句法

Accept-Charset: <charset>

// Multiple types, weighted with the quality value syntax:
Accept-Language: utf-8, iso-8859-1;q=0.5

指令

<charset>
A character set like utf-8 or iso-8859-15.
*
Any charset not mentioned elsewhere in the header; '*' being used as a wildcard.
;q= (q-factor weighting)
Any value is placed in an order of preference expressed using a relative quality value called the weight.

例子

Accept-Charset: iso-8859-1

Accept-Charset: utf-8, iso-8859-1;q=0.5

Accept-Language: utf-8, iso-8859-1;q=0.5, *;q=0.1

规范

Specification Title
RFC 7231, section 5.3.3: Accept-Charset Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context

浏览器兼容性

Feature Chrome Edge Firefox Internet Explorer Opera Safari Servo
Accept-Charset(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)
Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
Accept-Charset(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)

参见

文档标签和贡献者

 此页面的贡献者: xgqfrms-GitHub
 最后编辑者: xgqfrms-GitHub,