Text/xml and application/xml behave differently when the charset@H_502_7@ parameter is not explicitly specified. If the default charset (i.e.,@H_502_7@ US-ASCII) for text/xml is inconvenient for some reason (e.g.,bad web@H_502_7@ servers),application/xml provides an alternative (see “Optional@H_502_7@ parameters” of application/xml registration in Section 3.2).
对于text/xml:
Conformant with [RFC2046],if a text/xml entity is received with@H_502_7@ the charset parameter omitted,MIME processors and XML processors@H_502_7@ MUST use the default charset value of “us-ascii”[ASCII]. In cases@H_502_7@ where the XML MIME entity is transmitted via HTTP,the default@H_502_7@ charset value is still “us-ascii”.
If an application/xml entity is received where the charset@H_502_7@ parameter is omitted,no information is being provided about the@H_502_7@ charset by the MIME Content-Type header. Conforming XML@H_502_7@ processors MUST follow the requirements in section 4.3.3 of [XML]@H_502_7@ that directly address this contingency. However,MIME processors@H_502_7@ that are not XML processors SHOULD NOT assume a default charset if@H_502_7@ the charset parameter is omitted from an application/xml entity.
因此,如果省略charset参数,则text / xml的字符编码为US-ASCII,而使用application / xml,可以在文档本身中指定字符编码。
现在在互联网上的一个经验法则是:“严格输出,但容忍输入。”这意味着确保在通过互联网传递数据时尽可能地满足标准。但是建立一些机制来忽略错误或在通过互联网接收和解释数据时猜测。
所以在你的情况下,只是选择两种类型之一(我推荐application / xml),并确保正确指定使用的字符编码(我建议使用相应的默认字符编码,以安全,所以在application / xml使用情况下UTF-8或UTF-16)。