Skip to main content

2. Encoding

The RFC 822 EBNF meta notation is used. Any EBNF definitions taken from RFC 822 are prefixed by the string "822.".

The following EBNF is specified.

      atom-encoded    = *( a-char / a-encoded-char )
a-char = <any CHAR except specials (other than "@"
and "."), SPACE,
CTL, "_", and "#">
a-encoded-char = "_" ; (space)
/ "#u#" ; (_)
/ "#l#" ; <(>
/ "#r#" ; <)>
/ "#m#" ; (,)
/ "#c#" ; (:)
/ "#b#" ; (\)
/ "#h#" ; (#)
/ "#e#" ; (=)
/ "#s#" ; (/)
/ "#" 3DIGIT "#"

The 822.3DIGIT in EBNF.a-encoded-char must have range 0-127, and is interpreted in decimal as the corresponding ASCII character. The choice of special abbreviations (as opposed to decimal encoding) provided is based on the manner in which this mapping is most frequently used. There are special encodings for each of the PrintableString characters not in EBNF.a-char, except ".". Space is given a single character encoding, due to its (expected) frequency of use, and backslash as the RFC 822 single quote character.

This mapping is used to transform between the two forms of 822.word: 822.quoted-string (restricted RFC 822) and 822.atom (restricted RFC 822). To encode (full RFC 822 -> restricted RFC 822), first remove any quoting from any 822.quoted-string. Then, all EBNF.a-char are used directly and all other CHAR are encoded as EBNF.a-encoded-char.

To decode (restricted RFC 822 -> full RFC 822): if the address can be parsed as EBNF.encoded-atom reverse the previous mapping. If it cannot be so parsed, map the characters directly.