that other MIME headers may be present, and the XML entity may
RFC 2376 XML Media Types July 1998
contain other data in addition to the XML declaration; the examples
focus on the Content-type header and the encoding declaration for
clarity.
6.1 text/xml with UTF-8 Charset
Content-type: text/xml; charset="utf-8"
<?xml version="1.0" encoding="utf-8"?>
This is the recommended charset value for use with text/xml. Since
the charset parameter is provided, MIME and XML processors must treat
the enclosed entity as UTF-8 encoded.
If sent using a 7-bit transport (e.g. SMTP), the XML entity must use
a content-transfer-encoding of either quoted-printable or base64.
For an 8-bit clean transport (e.g., ESMTP, 8BITMIME, or NNTP), or a
binary clean transport (e.g., HTTP) no content-transfer-encoding is
necessary.
6.2 text/xml with UTF-16 Charset
Content-type: text/xml; charset="utf-16"
{BOM}<?xml version='1.0' encoding='utf-16'?>
This is possible only when the XML entity is transmitted via HTTP,
which uses a MIME-like mechanism and is a binary-clean protocol,
hence does not perform CR and LF transformations and allows NUL
octets. This differs from typical text MIME type processing (see
section 19.4.1 of HTTP 1.1 [RFC-2068] for details).
Since HTTP is binary clean, no content-transfer-encoding is
necessary.
6.3 text/xml with ISO-2022-KR Charset
Content-type: text/xml; charset="iso-2022-kr"
<?xml version="1.0" encoding='iso-2022-kr'?>
This example shows text/xml with a Korean charset (e.g., Hangul)
encoded following the specification in [RFC-1557]. Since the charset
parameter is provided, MIME and XML processors must treat the
enclosed entity as encoded per [RFC-1557].
Since ISO-2022-KR has been defined to use only 7 bits of data, no
content-transfer-encoding is necessary with any transport.
RFC 2376 XML Media Types July 1998
6.4 text/xml with Omitted Charset
Content-type: text/xml
{BOM}<?xml version="1.0" encoding="utf-16"?>
This example shows text/xml with the charset parameter omitted. In
this case, MIME and XML processors must assume the charset is "us-
ascii", the default charset value for text media types specified in
[RFC-2046]. The default of "us-ascii" holds even if the text/xml
entity is transported using HTTP.
Omitting the charset parameter is NOT RECOMMENDED for text/xml. For
example, even if the contents of the XML entity are UTF-16 or UTF-8,
or the XML entity has an explicit encoding declaration, XML and MIME
processors must assume the charset is "us-ascii".
6.5 application/xml with UTF-16 Charset
Content-type: application/xml; charset="utf-16"
{BOM}<?xml version="1.0"?>
This is a recommended charset value for use with application/xml.
Since the charset parameter is provided, MIME and XML processors must
treat the enclosed entity as UTF-16 encoded.
If sent using a 7-bit transport (e.g., SMTP) or an 8-bit clean
transport (e.g., ESMTP, 8BITMIME, or NNTP), the XML entity must be
encoded in quoted-printable or base64. For a binary clean transport
(e.g., HTTP), no content-transfer-encoding is necessary.
6.6 application/xml with ISO-2022-KR Charset
=6= |