The registration information for text/xml is in all respects the same
as that given for application/xml above (Section 9.1), except that
the "Type name" is "text".
4.1.2. Charset Parameter
A critical parameter that may be specified in the Content-Type field
for "text/plain" data is the character set. This is specified with a
"charset" parameter, as in:
Content-type: text/plain; charset=iso-8859-1
Unlike some other parameter values, the values of the charset
parameter are NOT case sensitive. The default character set, which
must be assumed in the absence of a charset parameter, is US-ASCII.
The specification for any future subtypes of "text" must specify
whether or not they will also utilize a "charset" parameter, and may
possibly restrict its values as well. For other subtypes of "text"
than "text/plain", the semantics of the "charset" parameter should be
defined to be identical to those specified here for "text/plain",
i.e., the body consists entirely of characters in the given charset.
In particular, definers of future "text" subtypes should pay close
attention to the implications of multioctet character sets for their
subtype definitions.
根据他们的说法,使用 application/xml MIME类型时可以避免这种困难 . 是否's true or not, I wouldn' t尽量避免 text/xml . 恕我直言,最好只是遵循人类可读性(不可读性)的语义,并始终记住指定字符集 .
5 回答
来自RFC(3023),在第3节下,XML媒体类型:
(强调我的)
这是一个老问题,但是经常访问的一个问题和明确的建议现在可以从RFC7303获得,它废弃了RFC3023 . 简而言之(第9.2节):
根据this article application / xml是首选 .
编辑
我对这篇文章做了一些跟进 .
作者声称在XML处理指令中声明的编码,如:
使用
text/xml
媒体类型时可以忽略 .他们在RFC 2046中定义
text/*
MIME类型系列规范支持论文,具体如下:根据他们的说法,使用
application/xml
MIME类型时可以避免这种困难 . 是否's true or not, I wouldn' t尽量避免text/xml
. 恕我直言,最好只是遵循人类可读性(不可读性)的语义,并始终记住指定字符集 .application/xml
被svn
视为 binary 类型而text/xml
视为 text 文件,可以显示差异 .不回答你的问题,而是提供简单的生活:
当你生活在.NET框架生态系统中时 - >看看https://referencesource.microsoft.com/#system.web/MimeMapping.cs line~430:
所以你总能这样做
正确地获取你的mimetype