mailio_mime_decode (mailio v0.2.0)
Low-level MIME decoders (pure, total).
Transfer decodings (quoted-printable, base64), RFC 2047 encoded-words, and charset conversion to UTF-8. Every function is total: malformed input is decoded best-effort rather than raising, matching the parser's "never throw on bad mail" policy.
Summary
Functions
Lenient base64 decode: ignores whitespace/newlines and tolerates missing padding. Never raises.
Body-mode quoted-printable decode. Underscores are literal here (only RFC 2047 Q-encoding maps _ to space).
Decode a leaf body according to its Content-Transfer-Encoding.
Decode all RFC 2047 encoded-words in a header value to a UTF-8 binary, leaving non-encoded runs intact. Adjacent encoded-words separated only by whitespace have that whitespace removed (RFC 2047 s6.2).
Map a charset label to a canonical atom understood by to_utf8/2.
Convert bytes in the named charset to a UTF-8 binary. Unknown or unconvertible charsets fall back to latin1 so text is never lost.
Functions
Lenient base64 decode: ignores whitespace/newlines and tolerates missing padding. Never raises.
Body-mode quoted-printable decode. Underscores are literal here (only RFC 2047 Q-encoding maps _ to space).
Decode a leaf body according to its Content-Transfer-Encoding.
Decode all RFC 2047 encoded-words in a header value to a UTF-8 binary, leaving non-encoded runs intact. Adjacent encoded-words separated only by whitespace have that whitespace removed (RFC 2047 s6.2).
Map a charset label to a canonical atom understood by to_utf8/2.
Convert bytes in the named charset to a UTF-8 binary. Unknown or unconvertible charsets fall back to latin1 so text is never lost.