purebred-email-0.6: types and parser for email messages (including MIME)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.MIME.EncodedWord

Description

encoded-words for representing non-7bit ASCII data in headers (RFC 2047 and RFC 2231).

Synopsis

Documentation

decodeEncodedWord :: CharsetLookup -> EncodedWord -> Text Source #

Decode an EncodedWord. If transfer or charset decoding fails, returns the serialised encoded word.

decodeEncodedWords :: CharsetLookup -> ByteString -> Text Source #

RFC 2047 and RFC 2231 define the encoded-words mechanism for embedding non-ASCII data in headers. This function locates encoded-words and decodes them.

λ> T.putStrLn $ decodeEncodedWords defaultCharsets "hello =?utf-8?B?5LiW55WM?=!"
hello 世界!

If parsing fails or the encoding is unrecognised the encoded-word is left unchanged in the result.

λ> T.putStrLn $ decodeEncodedWords defaultCharsets "=?utf-8?B?bogus?="
=?utf-8?B?bogus?=

λ> T.putStrLn $ decodeEncodedWords defaultCharsets "=?utf-8?X?unrecognised_encoding?="
=?utf-8?X?unrecognised_encoding?=

Language specification is supported (the datum is discarded).

λ> T.putStrLn $ decodeEncodedWords defaultCharsets "=?utf-8*es?Q?hola_mundo!?="
hola mundo!

encodeEncodedWords :: Text -> ByteString Source #

This function encodes necessary parts of some text

Currently turns the whole text into a single encoded word, if necessary.