module

Alumna::SMTP::QuotedPrintable

Quoted-printable body encoder (RFC 2045, section 6.7). Writes straight to the IO. It does not build a String.

Rules:

  • CRLF, LF, and a lone CR in the input become one CRLF (a hard line break).
  • Printable ASCII is literal, except "=".
  • Space and tab are literal, except before a line break or at the end (then =20 / =09).
  • Any other byte is =XX (upper-case hex). UTF-8 text becomes =XX triplets.
  • A "." at the start of a line is =2E. So no output line starts with ".", and the SMTP DATA phase needs no dot-stuffing.
  • A line has at most 75 characters, then a soft break ("=" CRLF). A soft break never splits an =XX triplet.

The output always ends at the start of a line (CRLF last), or is empty.

Constants

CR = 13_u8
DOT = 46_u8
EQUAL = 61_u8
HEX = "0123456789ABCDEF".to_slice
LF = 10_u8
MAX_LINE = 75

Characters on one line before the soft break "=". 75 + "=" = 76 (RFC 2045 limit).

SPACE = 32_u8
TAB = 9_u8

Class methods

write(io : IO, text : String) : Nil
Source