Content-Transfer-Encoding decoding and charset conversion for email body parts.
Decodes base64 and quoted-printable transfer encodings as specified in RFC 2045, and converts common charsets to UTF-8 using only OTP stdlib.
Examples
# Decode base64 content
{:ok, binary} = Plover.Content.decode(raw, "BASE64")
# Decode quoted-printable with charset conversion
{:ok, text} = Plover.Content.decode(raw, "QUOTED-PRINTABLE", "ISO-8859-1")
# Decode and convert in one step
{:ok, utf8_text} = Plover.Content.decode(raw, "BASE64", "Windows-1252")
Summary
Functions
Convert binary data from the given charset to UTF-8.
Decode content using the specified transfer encoding.
Decode content using the specified transfer encoding, then convert from the given charset to UTF-8.
Decode base64 encoded data. Whitespace (line breaks) is ignored.
Decode RFC 2047 encoded-words in a header value.
Decode quoted-printable encoded data per RFC 2045 Section 6.7.
Functions
Convert binary data from the given charset to UTF-8.
Supported charsets: UTF-8, US-ASCII, ISO-8859-1 (Latin-1), Windows-1252. Unknown charsets return the data unchanged.
Decode content using the specified transfer encoding.
Supported encodings: "BASE64", "QUOTED-PRINTABLE", "7BIT", "8BIT", "BINARY".
Encoding names are case-insensitive.
Decode content using the specified transfer encoding, then convert from the given charset to UTF-8.
Decode base64 encoded data. Whitespace (line breaks) is ignored.
Decode RFC 2047 encoded-words in a header value.
Encoded-words have the form =?charset?encoding?text?= where encoding is
B (base64) or Q (quoted-printable with _ for space). Adjacent
encoded-words separated only by whitespace are concatenated per RFC 2047
Section 6.2.
Returns the decoded string. Passes through nil and plain strings
that contain no encoded-words.
Decode quoted-printable encoded data per RFC 2045 Section 6.7.
=XXhex pairs are decoded to the corresponding byte- Soft line breaks (
=\r\nor=\n) are removed - All other characters pass through unchanged