📄 rfc1342.txt
字号:
Network Working Group K. MooreRequest for Comments: 1342 University of Tennessee June 1992 Representation of Non-ASCII Text in Internet Message HeadersStatus of this Memo This RFC specifies an IAB standards track protocol for the Internet community, and requests discussion and suggestions for improvements. Please refer to the current edition of the "IAB Official Protocol Standards" for the standardization state and status of this protocol. Distribution of this memo is unlimited.Abstract This memo describes an extension to the message format defined in [1] (known to the IETF Mail Extensions Working Group as "RFC 1341"), to allow the representation of character sets other than ASCII in RFC 822 message headers. The extensions described were designed to be highly compatible with existing Internet mail handling software, and to be easily implemented in mail readers that support RFC 1341.Introduction RFC 1341 describes a mechanism for denoting textual body parts which are coded in various character sets, as well as methods for encoding such body parts as sequences of printable ASCII characters. This memo describes similar techniques to allow the encoding of non-ASCII text in various portions of a RFC 822 [2] message header, in a manner which is unlikely to confuse existing message handling software. Like the encoding techniques described in RFC 1341, the techniques outlined here were designed to allow the use of non-ASCII characters in message headers in a way which is unlikely to be disturbed by the quirks of existing Internet mail handling programs. In particular, some mail relaying programs are known to (a) delete some message header fields while retaining others, (b) rearrange the order of addresses in To or Cc fields, (c) rearrange the (vertical) order of header fields, and/or (d) "wrap" message headers at different places than those in the original message. In addition, some mail reading programs are known to have difficulty correctly parsing message headers which, while legal according to RFC 822, make use of backslash-quoting to "hide" special characters such as "<", ",", or or which exploit other infrequently-used features of that specification.Moore [Page 1]RFC 1342 Non-ASCII Mail Headers June 1992 While it is unfortunate that these programs do not correctly interpret RFC 822 headers, to "break" these programs would cause severe operational problems for the Internet mail system. The extensions described in this memo therefore do not rely on little- used features of RFC 822. Instead, certain sequences of "ordinary" printable ASCII characters (which are assumed to be unlikely to otherwise appear in message headers) are reserved for use as encoded data. The characters used in these encodings are restricted to those which do not have special meanings in the context in which the encoded text appears.Encodings An "encoded-word" is a sequence of printable ASCII characters that begins with "=?", ends with "?=", and has two "?"s in between. It specifies a character set and an encoding method, and also includes the original text encoded as ASCII characters, according to the rules for that encoding method. A mail composer that implements this specification will provide a means of inputing non-ASCII text in header fields, but will translate these fields (or appropriate portions of these fields) into encoded- words before inserting them into the message header. A mail reader that implements this specification will recognize encoded-words when they appear in certain portions of the message header. Instead of displaying the encoded-word "as is", it will reverse the encoding and display the original text in the designated character set. An "encoded-word" is more precisely defined by the following EBNF grammar, using the notation of RFC 822: encoded-word = "=" "?" charset "?" encoding "?" encoded-text "?" "=" charset = token ; legal charsets defined by RFC 1341 encoding = token ; Either "B" or "Q" token = 1*<Any CHAR except SPACE, CTLs, and tspecials> tspecials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "\" / <"> / "/" / "[" / "]" / "?" / "." / "=" encoded-text = 1*<Any printable ASCII character other than "?" or ; SPACE> (but see "Use of encoded-words in message ; headers", below)Moore [Page 2]RFC 1342 Non-ASCII Mail Headers June 1992 An encoded-word may not be more than 75 characters long, including charset, encoding, encoded-text, and delimiters. If it is desirable to encode more text than will fit in an encoded-word of 75 characters, multiple encoded-words (separated by SPACE or newline) may be used. Message header lines that contain one or more encoded- words should be no more than 76 characters long. NOTE: These restrictions are included not only to ease interoperbility through internetwork mail gateways, but also to impose a limit on the amount of lookahead a header parser must employ (while looking for a final ?= delimiter) before it can decide whether a token is an encoded-word or something else. Initially, the legal values for "encoding" are "Q" and "B". These encodings are described below. The "Q" encoding is recommended for use with Latin character sets, and the "B" encoding for all others. Nevertheless, a mail reader which claims to recognize encoded-words MUST be able to accept either encoding for any character set which it supports. Only a subset of the printable ASCII characters may be used in encoded-text. The SPACE character is not allowed, so that the beginning and end of an encoded-word are obvious. The "?" character is used within an encoded-word to separate the various portions of the encoded-word from one another, and thus cannot appear in the encoded-text portion. Other characters are also illegal in certain contexts. For example, an encoded-word in a "phrase" preceeding an address in a From header field may not contain any of the "specials" defined in RFC 822. Finally, certain other characters are disallowed in some contexts, to ensure reliability for messages that pass through internetwork mail gateways. The "B" encoding automatically meets these requirements. The "Q" encoding allows a wide range of printable characters to be used in non-critical locations in the message header (e.g., Subject), with fewer characters available for use in other locations.The "B" encoding The "B" encoding is identical to the "BASE64" encoding defined by RFC 1341.The "Q" encoding The "Q" encoding is similar to the "Quoted-Printable" content- transfer-encoding defined in RFC 1341. It is designed to allow text containing mostly ASCII characters to be decipherable on an ASCII terminal without decoding.Moore [Page 3]RFC 1342 Non-ASCII Mail Headers June 1992 1. Any 8-bit value may be represented by a "=" followed by two hexadecimal digits. For example, if the character set in use were ISO-8859-1, the "=" character would thus be encoded as "=3D", and a SPACE by "=20". 2. The 8-bit hexadecimal value 20 (e.g., IS0-8859-1 SPACE) may be represented as "_" (underscore, ASCII 95.). (This character may not pass through some internetwork mail gateways, but its use will greatly enhance readability of "Q" encoded data with mail readers that do not support this encoding.) Note that the "_" always represents hexadecimal 20, even if the SPACE character occupies a different code position in the character set in use. 3. 8-bit values which correspond to printable ASCII characters other than "=", "?", "_" (underscore), and SPACE may be represented as those characters. (But see "Use of encoded-words in message headers", below).Character sets In an encoded-word, the character set associated with the unencoded text is specified by a charset. A charset can be any of the character set names allowed in an RFC 1341 "charset" parameter of a "text/plain" body part. (See section 7.1.1 of RFC 1341 for a list of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -