Quoted-printable

Quoted-printable is one of the two transfer encodings used in MIME e-mail messages to encode binary data entirely in characters of the 7-bit ASCII range so that it could be safely transmitted even through systems not supporting anything else (which was more of an issue in the 1970s when e-mail protocols were defined than at present). The other encoding is Base64, which is best suited for binary data. Quoted-printable is designed for data that is mostly ASCII text but may have a few "unsafe" characters needing encoding. It leaves normal "printable" ASCII alone, so that a quoted-printable text file is mostly readable without decoding; only the non-ASCII characters (and a few other special cases) are specially encoded.

A Quoted-printable-encoded message part is indicated in its MIME headers (following the Content-type header giving the type of data) with the line:

Content-Transfer-Encoding: Quoted-Printable

The equal sign (=) is used as the "escape" character to indicated encoded sequences. It is followed by two hexadecimal digits (0-9, A-F) which represent the value of an encoded 8-bit byte. Any sequence of bytes can be encoded in this manner, including binary files, but quoted-printable is mostly used for text files (which might be in any number of encodings, such as UTF-8 or ISO 8859-1).

Normal printable characters (ASCII 33-126 decimal) are represented by themselves, escept for the equal sign (ASCII 61 decimal) which is represented by =3D.

Line breaks are represented by CR+LF (as raw characters). A line break immediately preceded by = (at the end of the previous line) is considered a soft line break, removed in decoding. (Soft line breaks are always inserted to keep the quoted-printable lines no more than 76 characters to avoid problems with transmission through programs that limit line length.) An encoded CR or LF (=0D or =0A) indicates use of those control characters in the original document for a purpose other than normal line breaks (e.g., as part of a binary file).

Spaces and tabs at the end of a line need to be encoded as =20 and =09 respectively, since otherwise, whitespace in such a position is ignored.