application/* Content-Type and charset attributes

别说谁变了你拦得住时间么 提交于 2019-12-05 16:14:36

RFC 2616 was obsoleted in June 2014 by a set of RFCs, where the one containing the general HTTP specifications is RFC 7213. Please use the RFC editor to check the current status of RFCs.

RFC 7213 explicitly says (in Appendix B):

The default charset of ISO-8859-1 for text media types has been
removed; the default is now whatever the media type definition says.

On the other hand, RFC 6657, while anticipating such changes, declares:

The default "charset" parameter value for "text/plain" is unchanged from [RFC2046] and remains as "US-ASCII".

Thus, if your data is not ASCII (= US-ASCII), you should keep declaring the charset parameter explicitly.

The XML specification, clause 4.3.3, specifies:

In the absence of external character encoding information (such as MIME headers), parsed entities which are stored in an encoding other than UTF-8 or UTF-16 MUST begin with a text declaration [...] containing an encoding declaration

So for XML transmitted over HTTP, irrespective of content type, the encoding MUST be explicitly set either in an HTTP header or in an encoding declaration, e.g. <?xml encoding='UTF-8'?>.

For application types in general, type-specific rules may apply. Character encoding is irrelevant to most application types, as the types define their own encoding schemes, including the encoding of any embedded character data.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!