Safe Haskell | None |
---|---|
Language | Haskell2010 |
encoded-word
s for representing non-7bit ASCII data in headers
(RFC 2047 and RFC 2231).
Synopsis
- decodeEncodedWord :: CharsetLookup -> EncodedWord -> Text
- decodeEncodedWords :: CharsetLookup -> ByteString -> Text
- data EncodedWord
- encodedWord :: Parser EncodedWord
- buildEncodedWord :: EncodedWord -> Builder
- encodeEncodedWords :: Text -> ByteString
- chooseEncodedWordEncoding :: ByteString -> Maybe (TransferEncodingName, TransferEncoding)
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!
data EncodedWord Source #
Instances
HasTransferEncoding EncodedWord Source # | |
Defined in Data.MIME.EncodedWord transferEncodingName :: Getter EncodedWord TransferEncodingName Source # transferEncodedData :: Getter EncodedWord ByteString Source # transferDecoded :: (AsTransferEncodingError e, Profunctor p, Contravariant f) => Optic' p f EncodedWord (Either e (TransferDecoded EncodedWord)) Source # transferDecoded' :: (Profunctor p, Contravariant f) => Optic' p f EncodedWord (Either TransferEncodingError (TransferDecoded EncodedWord)) Source # transferEncode :: TransferDecoded EncodedWord -> EncodedWord Source # | |
type TransferDecoded EncodedWord Source # | |
Defined in Data.MIME.EncodedWord |
encodeEncodedWords :: Text -> ByteString Source #
This function encodes necessary parts of some text
Currently turns the whole text into a single encoded word, if necessary.