The Accept-Charset
request HTTP header advertises which character set the client is able to understand. 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 |
Syntax
Accept-Charset: <charset> // Multiple types, weighted with the quality value syntax: Accept-Charset: utf-8, iso-8859-1;q=0.5
Directives
<charset>
- A character set like
utf-8
oriso-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.
Examples
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
Specifications
Specification | Title |
---|---|
RFC 7231, section 5.3.3: Accept-Charset | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature | Chrome | Firefox | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
See also
- HTTP content negotiation
- Header with the result of the content negotiation:
Content-Type
- Other similar headers:
TE
,Accept-Encoding
,Accept-Language
,Accept