purebred-email-0.1.0.0: types and parser for email messages (including MIME)

Safe HaskellNone
LanguageHaskell2010

Data.MIME.EncodedWord

Description

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

Synopsis

Documentation

decodeEncodedWords :: 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 "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 "=?utf-8?B?bogus?="
=?utf-8?B?bogus?=

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

Language specification is supported (the datum is discarded).

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