rfc2047.txt 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  1. Network Working Group K. Moore
  2. Request for Comments: 2047 University of Tennessee
  3. Obsoletes: 1521, 1522, 1590 November 1996
  4. Category: Standards Track
  5. MIME (Multipurpose Internet Mail Extensions) Part Three:
  6. Message Header Extensions for Non-ASCII Text
  7. Status of this Memo
  8. This document specifies an Internet standards track protocol for the
  9. Internet community, and requests discussion and suggestions for
  10. improvements. Please refer to the current edition of the "Internet
  11. Official Protocol Standards" (STD 1) for the standardization state
  12. and status of this protocol. Distribution of this memo is unlimited.
  13. Abstract
  14. STD 11, RFC 822, defines a message representation protocol specifying
  15. considerable detail about US-ASCII message headers, and leaves the
  16. message content, or message body, as flat US-ASCII text. This set of
  17. documents, collectively called the Multipurpose Internet Mail
  18. Extensions, or MIME, redefines the format of messages to allow for
  19. (1) textual message bodies in character sets other than US-ASCII,
  20. (2) an extensible set of different formats for non-textual message
  21. bodies,
  22. (3) multi-part message bodies, and
  23. (4) textual header information in character sets other than US-ASCII.
  24. These documents are based on earlier work documented in RFC 934, STD
  25. 11, and RFC 1049, but extends and revises them. Because RFC 822 said
  26. so little about message bodies, these documents are largely
  27. orthogonal to (rather than a revision of) RFC 822.
  28. This particular document is the third document in the series. It
  29. describes extensions to RFC 822 to allow non-US-ASCII text data in
  30. Internet mail header fields.
  31. Moore Standards Track [Page 1]
  32. RFC 2047 Message Header Extensions November 1996
  33. Other documents in this series include:
  34. + RFC 2045, which specifies the various headers used to describe
  35. the structure of MIME messages.
  36. + RFC 2046, which defines the general structure of the MIME media
  37. typing system and defines an initial set of media types,
  38. + RFC 2048, which specifies various IANA registration procedures
  39. for MIME-related facilities, and
  40. + RFC 2049, which describes MIME conformance criteria and
  41. provides some illustrative examples of MIME message formats,
  42. acknowledgements, and the bibliography.
  43. These documents are revisions of RFCs 1521, 1522, and 1590, which
  44. themselves were revisions of RFCs 1341 and 1342. An appendix in RFC
  45. 2049 describes differences and changes from previous versions.
  46. 1. Introduction
  47. RFC 2045 describes a mechanism for denoting textual body parts which
  48. are coded in various character sets, as well as methods for encoding
  49. such body parts as sequences of printable US-ASCII characters. This
  50. memo describes similar techniques to allow the encoding of non-ASCII
  51. text in various portions of a RFC 822 [2] message header, in a manner
  52. which is unlikely to confuse existing message handling software.
  53. Like the encoding techniques described in RFC 2045, the techniques
  54. outlined here were designed to allow the use of non-ASCII characters
  55. in message headers in a way which is unlikely to be disturbed by the
  56. quirks of existing Internet mail handling programs. In particular,
  57. some mail relaying programs are known to (a) delete some message
  58. header fields while retaining others, (b) rearrange the order of
  59. addresses in To or Cc fields, (c) rearrange the (vertical) order of
  60. header fields, and/or (d) "wrap" message headers at different places
  61. than those in the original message. In addition, some mail reading
  62. programs are known to have difficulty correctly parsing message
  63. headers which, while legal according to RFC 822, make use of
  64. backslash-quoting to "hide" special characters such as "<", ",", or
  65. ":", or which exploit other infrequently-used features of that
  66. specification.
  67. While it is unfortunate that these programs do not correctly
  68. interpret RFC 822 headers, to "break" these programs would cause
  69. severe operational problems for the Internet mail system. The
  70. extensions described in this memo therefore do not rely on little-
  71. used features of RFC 822.
  72. Moore Standards Track [Page 2]
  73. RFC 2047 Message Header Extensions November 1996
  74. Instead, certain sequences of "ordinary" printable ASCII characters
  75. (known as "encoded-words") are reserved for use as encoded data. The
  76. syntax of encoded-words is such that they are unlikely to
  77. "accidentally" appear as normal text in message headers.
  78. Furthermore, the characters used in encoded-words are restricted to
  79. those which do not have special meanings in the context in which the
  80. encoded-word appears.
  81. Generally, an "encoded-word" is a sequence of printable ASCII
  82. characters that begins with "=?", ends with "?=", and has two "?"s in
  83. between. It specifies a character set and an encoding method, and
  84. also includes the original text encoded as graphic ASCII characters,
  85. according to the rules for that encoding method.
  86. A mail composer that implements this specification will provide a
  87. means of inputting non-ASCII text in header fields, but will
  88. translate these fields (or appropriate portions of these fields) into
  89. encoded-words before inserting them into the message header.
  90. A mail reader that implements this specification will recognize
  91. encoded-words when they appear in certain portions of the message
  92. header. Instead of displaying the encoded-word "as is", it will
  93. reverse the encoding and display the original text in the designated
  94. character set.
  95. NOTES
  96. This memo relies heavily on notation and terms defined RFC 822 and
  97. RFC 2045. In particular, the syntax for the ABNF used in this memo
  98. is defined in RFC 822, as well as many of the terminal or nonterminal
  99. symbols from RFC 822 are used in the grammar for the header
  100. extensions defined here. Among the symbols defined in RFC 822 and
  101. referenced in this memo are: 'addr-spec', 'atom', 'CHAR', 'comment',
  102. 'CTLs', 'ctext', 'linear-white-space', 'phrase', 'quoted-pair'.
  103. 'quoted-string', 'SPACE', and 'word'. Successful implementation of
  104. this protocol extension requires careful attention to the RFC 822
  105. definitions of these terms.
  106. When the term "ASCII" appears in this memo, it refers to the "7-Bit
  107. American Standard Code for Information Interchange", ANSI X3.4-1986.
  108. The MIME charset name for this character set is "US-ASCII". When not
  109. specifically referring to the MIME charset name, this document uses
  110. the term "ASCII", both for brevity and for consistency with RFC 822.
  111. However, implementors are warned that the character set name must be
  112. spelled "US-ASCII" in MIME message and body part headers.
  113. Moore Standards Track [Page 3]
  114. RFC 2047 Message Header Extensions November 1996
  115. This memo specifies a protocol for the representation of non-ASCII
  116. text in message headers. It specifically DOES NOT define any
  117. translation between "8-bit headers" and pure ASCII headers, nor is
  118. any such translation assumed to be possible.
  119. 2. Syntax of encoded-words
  120. An 'encoded-word' is defined by the following ABNF grammar. The
  121. notation of RFC 822 is used, with the exception that white space
  122. characters MUST NOT appear between components of an 'encoded-word'.
  123. encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
  124. charset = token ; see section 3
  125. encoding = token ; see section 4
  126. token = 1*<Any CHAR except SPACE, CTLs, and especials>
  127. especials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "
  128. <"> / "/" / "[" / "]" / "?" / "." / "="
  129. encoded-text = 1*<Any printable ASCII character other than "?"
  130. or SPACE>
  131. ; (but see "Use of encoded-words in message
  132. ; headers", section 5)
  133. Both 'encoding' and 'charset' names are case-independent. Thus the
  134. charset name "ISO-8859-1" is equivalent to "iso-8859-1", and the
  135. encoding named "Q" may be spelled either "Q" or "q".
  136. An 'encoded-word' may not be more than 75 characters long, including
  137. 'charset', 'encoding', 'encoded-text', and delimiters. If it is
  138. desirable to encode more text than will fit in an 'encoded-word' of
  139. 75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may
  140. be used.
  141. While there is no limit to the length of a multiple-line header
  142. field, each line of a header field that contains one or more
  143. 'encoded-word's is limited to 76 characters.
  144. The length restrictions are included both to ease interoperability
  145. through internetwork mail gateways, and to impose a limit on the
  146. amount of lookahead a header parser must employ (while looking for a
  147. final ?= delimiter) before it can decide whether a token is an
  148. "encoded-word" or something else.
  149. Moore Standards Track [Page 4]
  150. RFC 2047 Message Header Extensions November 1996
  151. IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's
  152. by an RFC 822 parser. As a consequence, unencoded white space
  153. characters (such as SPACE and HTAB) are FORBIDDEN within an
  154. 'encoded-word'. For example, the character sequence
  155. =?iso-8859-1?q?this is some text?=
  156. would be parsed as four 'atom's, rather than as a single 'atom' (by
  157. an RFC 822 parser) or 'encoded-word' (by a parser which understands
  158. 'encoded-words'). The correct way to encode the string "this is some
  159. text" is to encode the SPACE characters as well, e.g.
  160. =?iso-8859-1?q?this=20is=20some=20text?=
  161. The characters which may appear in 'encoded-text' are further
  162. restricted by the rules in section 5.
  163. 3. Character sets
  164. The 'charset' portion of an 'encoded-word' specifies the character
  165. set associated with the unencoded text. A 'charset' can be any of
  166. the character set names allowed in an MIME "charset" parameter of a
  167. "text/plain" body part, or any character set name registered with
  168. IANA for use with the MIME text/plain content-type.
  169. Some character sets use code-switching techniques to switch between
  170. "ASCII mode" and other modes. If unencoded text in an 'encoded-word'
  171. contains a sequence which causes the charset interpreter to switch
  172. out of ASCII mode, it MUST contain additional control codes such that
  173. ASCII mode is again selected at the end of the 'encoded-word'. (This
  174. rule applies separately to each 'encoded-word', including adjacent
  175. 'encoded-word's within a single header field.)
  176. When there is a possibility of using more than one character set to
  177. represent the text in an 'encoded-word', and in the absence of
  178. private agreements between sender and recipients of a message, it is
  179. recommended that members of the ISO-8859-* series be used in
  180. preference to other character sets.
  181. 4. Encodings
  182. Initially, the legal values for "encoding" are "Q" and "B". These
  183. encodings are described below. The "Q" encoding is recommended for
  184. use when most of the characters to be encoded are in the ASCII
  185. character set; otherwise, the "B" encoding should be used.
  186. Nevertheless, a mail reader which claims to recognize 'encoded-word's
  187. MUST be able to accept either encoding for any character set which it
  188. supports.
  189. Moore Standards Track [Page 5]
  190. RFC 2047 Message Header Extensions November 1996
  191. Only a subset of the printable ASCII characters may be used in
  192. 'encoded-text'. Space and tab characters are not allowed, so that
  193. the beginning and end of an 'encoded-word' are obvious. The "?"
  194. character is used within an 'encoded-word' to separate the various
  195. portions of the 'encoded-word' from one another, and thus cannot
  196. appear in the 'encoded-text' portion. Other characters are also
  197. illegal in certain contexts. For example, an 'encoded-word' in a
  198. 'phrase' preceding an address in a From header field may not contain
  199. any of the "specials" defined in RFC 822. Finally, certain other
  200. characters are disallowed in some contexts, to ensure reliability for
  201. messages that pass through internetwork mail gateways.
  202. The "B" encoding automatically meets these requirements. The "Q"
  203. encoding allows a wide range of printable characters to be used in
  204. non-critical locations in the message header (e.g., Subject), with
  205. fewer characters available for use in other locations.
  206. 4.1. The "B" encoding
  207. The "B" encoding is identical to the "BASE64" encoding defined by RFC
  208. 2045.
  209. 4.2. The "Q" encoding
  210. The "Q" encoding is similar to the "Quoted-Printable" content-
  211. transfer-encoding defined in RFC 2045. It is designed to allow text
  212. containing mostly ASCII characters to be decipherable on an ASCII
  213. terminal without decoding.
  214. (1) Any 8-bit value may be represented by a "=" followed by two
  215. hexadecimal digits. For example, if the character set in use
  216. were ISO-8859-1, the "=" character would thus be encoded as
  217. "=3D", and a SPACE by "=20". (Upper case should be used for
  218. hexadecimal digits "A" through "F".)
  219. (2) The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be
  220. represented as "_" (underscore, ASCII 95.). (This character may
  221. not pass through some internetwork mail gateways, but its use
  222. will greatly enhance readability of "Q" encoded data with mail
  223. readers that do not support this encoding.) Note that the "_"
  224. always represents hexadecimal 20, even if the SPACE character
  225. occupies a different code position in the character set in use.
  226. (3) 8-bit values which correspond to printable ASCII characters other
  227. than "=", "?", and "_" (underscore), MAY be represented as those
  228. characters. (But see section 5 for restrictions.) In
  229. particular, SPACE and TAB MUST NOT be represented as themselves
  230. within encoded words.
  231. Moore Standards Track [Page 6]
  232. RFC 2047 Message Header Extensions November 1996
  233. 5. Use of encoded-words in message headers
  234. An 'encoded-word' may appear in a message header or body part header
  235. according to the following rules:
  236. (1) An 'encoded-word' may replace a 'text' token (as defined by RFC 822)
  237. in any Subject or Comments header field, any extension message
  238. header field, or any MIME body part field for which the field body
  239. is defined as '*text'. An 'encoded-word' may also appear in any
  240. user-defined ("X-") message or body part header field.
  241. Ordinary ASCII text and 'encoded-word's may appear together in the
  242. same header field. However, an 'encoded-word' that appears in a
  243. header field defined as '*text' MUST be separated from any adjacent
  244. 'encoded-word' or 'text' by 'linear-white-space'.
  245. (2) An 'encoded-word' may appear within a 'comment' delimited by "(" and
  246. ")", i.e., wherever a 'ctext' is allowed. More precisely, the RFC
  247. 822 ABNF definition for 'comment' is amended as follows:
  248. comment = "(" *(ctext / quoted-pair / comment / encoded-word) ")"
  249. A "Q"-encoded 'encoded-word' which appears in a 'comment' MUST NOT
  250. contain the characters "(", ")" or "
  251. 'encoded-word' that appears in a 'comment' MUST be separated from
  252. any adjacent 'encoded-word' or 'ctext' by 'linear-white-space'.
  253. It is important to note that 'comment's are only recognized inside
  254. "structured" field bodies. In fields whose bodies are defined as
  255. '*text', "(" and ")" are treated as ordinary characters rather than
  256. comment delimiters, and rule (1) of this section applies. (See RFC
  257. 822, sections 3.1.2 and 3.1.3)
  258. (3) As a replacement for a 'word' entity within a 'phrase', for example,
  259. one that precedes an address in a From, To, or Cc header. The ABNF
  260. definition for 'phrase' from RFC 822 thus becomes:
  261. phrase = 1*( encoded-word / word )
  262. In this case the set of characters that may be used in a "Q"-encoded
  263. 'encoded-word' is restricted to: <upper and lower case ASCII
  264. letters, decimal digits, "!", "*", "+", "-", "/", "=", and "_"
  265. (underscore, ASCII 95.)>. An 'encoded-word' that appears within a
  266. 'phrase' MUST be separated from any adjacent 'word', 'text' or
  267. 'special' by 'linear-white-space'.
  268. Moore Standards Track [Page 7]
  269. RFC 2047 Message Header Extensions November 1996
  270. These are the ONLY locations where an 'encoded-word' may appear. In
  271. particular:
  272. + An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'.
  273. + An 'encoded-word' MUST NOT appear within a 'quoted-string'.
  274. + An 'encoded-word' MUST NOT be used in a Received header field.
  275. + An 'encoded-word' MUST NOT be used in parameter of a MIME
  276. Content-Type or Content-Disposition field, or in any structured
  277. field body except within a 'comment' or 'phrase'.
  278. The 'encoded-text' in an 'encoded-word' must be self-contained;
  279. 'encoded-text' MUST NOT be continued from one 'encoded-word' to
  280. another. This implies that the 'encoded-text' portion of a "B"
  281. 'encoded-word' will be a multiple of 4 characters long; for a "Q"
  282. 'encoded-word', any "=" character that appears in the 'encoded-text'
  283. portion will be followed by two hexadecimal characters.
  284. Each 'encoded-word' MUST encode an integral number of octets. The
  285. 'encoded-text' in each 'encoded-word' must be well-formed according
  286. to the encoding specified; the 'encoded-text' may not be continued in
  287. the next 'encoded-word'. (For example, "=?charset?Q?=?=
  288. =?charset?Q?AB?=" would be illegal, because the two hex digits "AB"
  289. must follow the "=" in the same 'encoded-word'.)
  290. Each 'encoded-word' MUST represent an integral number of characters.
  291. A multi-octet character may not be split across adjacent 'encoded-
  292. word's.
  293. Only printable and white space character data should be encoded using
  294. this scheme. However, since these encoding schemes allow the
  295. encoding of arbitrary octet values, mail readers that implement this
  296. decoding should also ensure that display of the decoded data on the
  297. recipient's terminal will not cause unwanted side-effects.
  298. Use of these methods to encode non-textual data (e.g., pictures or
  299. sounds) is not defined by this memo. Use of 'encoded-word's to
  300. represent strings of purely ASCII characters is allowed, but
  301. discouraged. In rare cases it may be necessary to encode ordinary
  302. text that looks like an 'encoded-word'.
  303. Moore Standards Track [Page 8]
  304. RFC 2047 Message Header Extensions November 1996
  305. 6. Support of 'encoded-word's by mail readers
  306. 6.1. Recognition of 'encoded-word's in message headers
  307. A mail reader must parse the message and body part headers according
  308. to the rules in RFC 822 to correctly recognize 'encoded-word's.
  309. 'encoded-word's are to be recognized as follows:
  310. (1) Any message or body part header field defined as '*text', or any
  311. user-defined header field, should be parsed as follows: Beginning
  312. at the start of the field-body and immediately following each
  313. occurrence of 'linear-white-space', each sequence of up to 75
  314. printable characters (not containing any 'linear-white-space')
  315. should be examined to see if it is an 'encoded-word' according to
  316. the syntax rules in section 2. Any other sequence of printable
  317. characters should be treated as ordinary ASCII text.
  318. (2) Any header field not defined as '*text' should be parsed
  319. according to the syntax rules for that header field. However,
  320. any 'word' that appears within a 'phrase' should be treated as an
  321. 'encoded-word' if it meets the syntax rules in section 2.
  322. Otherwise it should be treated as an ordinary 'word'.
  323. (3) Within a 'comment', any sequence of up to 75 printable characters
  324. (not containing 'linear-white-space'), that meets the syntax
  325. rules in section 2, should be treated as an 'encoded-word'.
  326. Otherwise it should be treated as normal comment text.
  327. (4) A MIME-Version header field is NOT required to be present for
  328. 'encoded-word's to be interpreted according to this
  329. specification. One reason for this is that the mail reader is
  330. not expected to parse the entire message header before displaying
  331. lines that may contain 'encoded-word's.
  332. 6.2. Display of 'encoded-word's
  333. Any 'encoded-word's so recognized are decoded, and if possible, the
  334. resulting unencoded text is displayed in the original character set.
  335. NOTE: Decoding and display of encoded-words occurs *after* a
  336. structured field body is parsed into tokens. It is therefore
  337. possible to hide 'special' characters in encoded-words which, when
  338. displayed, will be indistinguishable from 'special' characters in the
  339. surrounding text. For this and other reasons, it is NOT generally
  340. possible to translate a message header containing 'encoded-word's to
  341. an unencoded form which can be parsed by an RFC 822 mail reader.
  342. Moore Standards Track [Page 9]
  343. RFC 2047 Message Header Extensions November 1996
  344. When displaying a particular header field that contains multiple
  345. 'encoded-word's, any 'linear-white-space' that separates a pair of
  346. adjacent 'encoded-word's is ignored. (This is to allow the use of
  347. multiple 'encoded-word's to represent long strings of unencoded text,
  348. without having to separate 'encoded-word's where spaces occur in the
  349. unencoded text.)
  350. In the event other encodings are defined in the future, and the mail
  351. reader does not support the encoding used, it may either (a) display
  352. the 'encoded-word' as ordinary text, or (b) substitute an appropriate
  353. message indicating that the text could not be decoded.
  354. If the mail reader does not support the character set used, it may
  355. (a) display the 'encoded-word' as ordinary text (i.e., as it appears
  356. in the header), (b) make a "best effort" to display using such
  357. characters as are available, or (c) substitute an appropriate message
  358. indicating that the decoded text could not be displayed.
  359. If the character set being used employs code-switching techniques,
  360. display of the encoded text implicitly begins in "ASCII mode". In
  361. addition, the mail reader must ensure that the output device is once
  362. again in "ASCII mode" after the 'encoded-word' is displayed.
  363. 6.3. Mail reader handling of incorrectly formed 'encoded-word's
  364. It is possible that an 'encoded-word' that is legal according to the
  365. syntax defined in section 2, is incorrectly formed according to the
  366. rules for the encoding being used. For example:
  367. (1) An 'encoded-word' which contains characters which are not legal
  368. for a particular encoding (for example, a "-" in the "B"
  369. encoding, or a SPACE or HTAB in either the "B" or "Q" encoding),
  370. is incorrectly formed.
  371. (2) Any 'encoded-word' which encodes a non-integral number of
  372. characters or octets is incorrectly formed.
  373. A mail reader need not attempt to display the text associated with an
  374. 'encoded-word' that is incorrectly formed. However, a mail reader
  375. MUST NOT prevent the display or handling of a message because an
  376. 'encoded-word' is incorrectly formed.
  377. 7. Conformance
  378. A mail composing program claiming compliance with this specification
  379. MUST ensure that any string of non-white-space printable ASCII
  380. characters within a '*text' or '*ctext' that begins with "=?" and
  381. ends with "?=" be a valid 'encoded-word'. ("begins" means: at the
  382. Moore Standards Track [Page 10]
  383. RFC 2047 Message Header Extensions November 1996
  384. start of the field-body, immediately following 'linear-white-space',
  385. or immediately following a "(" for an 'encoded-word' within '*ctext';
  386. "ends" means: at the end of the field-body, immediately preceding
  387. 'linear-white-space', or immediately preceding a ")" for an
  388. 'encoded-word' within '*ctext'.) In addition, any 'word' within a
  389. 'phrase' that begins with "=?" and ends with "?=" must be a valid
  390. 'encoded-word'.
  391. A mail reading program claiming compliance with this specification
  392. must be able to distinguish 'encoded-word's from 'text', 'ctext', or
  393. 'word's, according to the rules in section 6, anytime they appear in
  394. appropriate places in message headers. It must support both the "B"
  395. and "Q" encodings for any character set which it supports. The
  396. program must be able to display the unencoded text if the character
  397. set is "US-ASCII". For the ISO-8859-* character sets, the mail
  398. reading program must at least be able to display the characters which
  399. are also in the ASCII set.
  400. 8. Examples
  401. The following are examples of message headers containing 'encoded-
  402. word's:
  403. From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>
  404. To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
  405. CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
  406. Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
  407. =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
  408. Note: In the first 'encoded-word' of the Subject field above, the
  409. last "=" at the end of the 'encoded-text' is necessary because each
  410. 'encoded-word' must be self-contained (the "=" character completes a
  411. group of 4 base64 characters representing 2 octets). An additional
  412. octet could have been encoded in the first 'encoded-word' (so that
  413. the encoded-word would contain an exact multiple of 3 encoded
  414. octets), except that the second 'encoded-word' uses a different
  415. 'charset' than the first one.
  416. From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se>
  417. To: ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se
  418. Subject: Time for ISO 10646?
  419. To: Dave Crocker <dcrocker@mordor.stanford.edu>
  420. Cc: ietf-822@dimacs.rutgers.edu, paf@comsol.se
  421. From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se>
  422. Subject: Re: RFC-HDR care and feeding
  423. Moore Standards Track [Page 11]
  424. RFC 2047 Message Header Extensions November 1996
  425. From: Nathaniel Borenstein <nsb@thumper.bellcore.com>
  426. (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)
  427. To: Greg Vaudreuil <gvaudre@NRI.Reston.VA.US>, Ned Freed
  428. <ned@innosoft.com>, Keith Moore <moore@cs.utk.edu>
  429. Subject: Test of new header generator
  430. MIME-Version: 1.0
  431. Content-type: text/plain; charset=ISO-8859-1
  432. The following examples illustrate how text containing 'encoded-word's
  433. which appear in a structured field body. The rules are slightly
  434. different for fields defined as '*text' because "(" and ")" are not
  435. recognized as 'comment' delimiters. [Section 5, paragraph (1)].
  436. In each of the following examples, if the same sequence were to occur
  437. in a '*text' field, the "displayed as" form would NOT be treated as
  438. encoded words, but be identical to the "encoded form". This is
  439. because each of the encoded-words in the following examples is
  440. adjacent to a "(" or ")" character.
  441. encoded form displayed as
  442. ---------------------------------------------------------------------
  443. (=?ISO-8859-1?Q?a?=) (a)
  444. (=?ISO-8859-1?Q?a?= b) (a b)
  445. Within a 'comment', white space MUST appear between an
  446. 'encoded-word' and surrounding text. [Section 5,
  447. paragraph (2)]. However, white space is not needed between
  448. the initial "(" that begins the 'comment', and the
  449. 'encoded-word'.
  450. (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab)
  451. White space between adjacent 'encoded-word's is not
  452. displayed.
  453. (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab)
  454. Even multiple SPACEs between 'encoded-word's are ignored
  455. for the purpose of display.
  456. (=?ISO-8859-1?Q?a?= (ab)
  457. =?ISO-8859-1?Q?b?=)
  458. Any amount of linear-space-white between 'encoded-word's,
  459. even if it includes a CRLF followed by one or more SPACEs,
  460. is ignored for the purposes of display.
  461. Moore Standards Track [Page 12]
  462. RFC 2047 Message Header Extensions November 1996
  463. (=?ISO-8859-1?Q?a_b?=) (a b)
  464. In order to cause a SPACE to be displayed within a portion
  465. of encoded text, the SPACE MUST be encoded as part of the
  466. 'encoded-word'.
  467. (=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) (a b)
  468. In order to cause a SPACE to be displayed between two strings
  469. of encoded text, the SPACE MAY be encoded as part of one of
  470. the 'encoded-word's.
  471. 9. References
  472. [RFC 822] Crocker, D., "Standard for the Format of ARPA Internet Text
  473. Messages", STD 11, RFC 822, UDEL, August 1982.
  474. [RFC 2049] Borenstein, N., and N. Freed, "Multipurpose Internet Mail
  475. Extensions (MIME) Part Five: Conformance Criteria and Examples",
  476. RFC 2049, November 1996.
  477. [RFC 2045] Borenstein, N., and N. Freed, "Multipurpose Internet Mail
  478. Extensions (MIME) Part One: Format of Internet Message Bodies",
  479. RFC 2045, November 1996.
  480. [RFC 2046] Borenstein N., and N. Freed, "Multipurpose Internet Mail
  481. Extensions (MIME) Part Two: Media Types", RFC 2046,
  482. November 1996.
  483. [RFC 2048] Freed, N., Klensin, J., and J. Postel, "Multipurpose
  484. Internet Mail Extensions (MIME) Part Four: Registration
  485. Procedures", RFC 2048, November 1996.
  486. Moore Standards Track [Page 13]
  487. RFC 2047 Message Header Extensions November 1996
  488. 10. Security Considerations
  489. Security issues are not discussed in this memo.
  490. 11. Acknowledgements
  491. The author wishes to thank Nathaniel Borenstein, Issac Chan, Lutz
  492. Donnerhacke, Paul Eggert, Ned Freed, Andreas M. Kirchwitz, Olle
  493. Jarnefors, Mike Rosin, Yutaka Sato, Bart Schaefer, and Kazuhiko
  494. Yamamoto, for their helpful advice, insightful comments, and
  495. illuminating questions in response to earlier versions of this
  496. specification.
  497. 12. Author's Address
  498. Keith Moore
  499. University of Tennessee
  500. 107 Ayres Hall
  501. Knoxville TN 37996-1301
  502. EMail: moore@cs.utk.edu
  503. Moore Standards Track [Page 14]
  504. RFC 2047 Message Header Extensions November 1996
  505. Appendix - changes since RFC 1522 (in no particular order)
  506. + explicitly state that the MIME-Version is not requried to use
  507. 'encoded-word's.
  508. + add explicit note that SPACEs and TABs are not allowed within
  509. 'encoded-word's, explaining that an 'encoded-word' must look like an
  510. 'atom' to an RFC822 parser.values, to be precise).
  511. + add examples from Olle Jarnefors (thanks!) which illustrate how
  512. encoded-words with adjacent linear-white-space are displayed.
  513. + explicitly list terms defined in RFC822 and referenced in this memo
  514. + fix transcription typos that caused one or two lines and a couple of
  515. characters to disappear in the resulting text, due to nroff quirks.
  516. + clarify that encoded-words are allowed in '*text' fields in both
  517. RFC822 headers and MIME body part headers, but NOT as parameter
  518. values.
  519. + clarify the requirement to switch back to ASCII within the encoded
  520. portion of an 'encoded-word', for any charset that uses code switching
  521. sequences.
  522. + add a note about 'encoded-word's being delimited by "(" and ")"
  523. within a comment, but not in a *text (how bizarre!).
  524. + fix the Andre Pirard example to get rid of the trailing "_" after
  525. the =E9. (no longer needed post-1342).
  526. + clarification: an 'encoded-word' may appear immediately following
  527. the initial "(" or immediately before the final ")" that delimits a
  528. comment, not just adjacent to "(" and ")" *within* *ctext.
  529. + add a note to explain that a "B" 'encoded-word' will always have a
  530. multiple of 4 characters in the 'encoded-text' portion.
  531. + add note about the "=" in the examples
  532. + note that processing of 'encoded-word's occurs *after* parsing, and
  533. some of the implications thereof.
  534. + explicitly state that you can't expect to translate between
  535. 1522 and either vanilla 822 or so-called "8-bit headers".
  536. + explicitly state that 'encoded-word's are not valid within a
  537. 'quoted-string'.
  538. Moore Standards Track [Page 15]