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

Safe HaskellSafe
LanguageHaskell2010

Data.MIME.Charset

Description

MIME character sets.

Recognised charsets:

  • us-ascii / iso646-us
  • utf-8
  • iso-8859-1
Synopsis

Documentation

class HasCharset a where Source #

Associated Types

type Decoded a Source #

Methods

charsetName :: Getter a (Maybe CharsetName) Source #

Get the declared (or default) character set name. There is no guarantee that it corresponds to a registered or supported charset.

charsetData :: Getter a ByteString Source #

Return the encoded data in the structure

charsetDecoded :: AsCharsetError e => CharsetLookup -> Getter a (Either e (Decoded a)) Source #

Structure with the encoded data replaced with Text

charsetEncode :: Decoded a -> a Source #

Encode the data

Instances
HasCharset EncodedParameterValue Source #

The default charset us-ascii is implied by the abstract of RFC 2231 which states: /This memo defines … a means to specify parameter values in character sets other than US-ASCII/.

When encoding, 'utf-8' is always used, but if the whole string contains only ASCII characters then the charset declaration is omitted (so that it can be encoded as a non-extended parameter).

Instance details

Defined in Data.MIME.Parameter

Associated Types

type Decoded EncodedParameterValue :: Type Source #

HasCharset ByteEntity Source #

RFC 2046 §4.1.2. defines the default character set to be US-ASCII.

Instance details

Defined in Data.MIME

Associated Types

type Decoded ByteEntity :: Type Source #

charsetText :: (HasCharset a, AsCharsetError e) => CharsetLookup -> Getter a (Either e Text) Source #

Decode the object according to the declared charset.

charsetText' :: HasCharset a => CharsetLookup -> Getter a (Either CharsetError Text) Source #

Monomorphic in error type

charsetPrism :: forall a. HasCharset a => CharsetLookup -> Prism' a (Decoded a) Source #

Prism for charset decoded/encoded data. Information about decoding failures is discarded.

defaultCharsets :: CharsetLookup Source #

Supports US-ASCII, UTF-8 and ISO-8859-1.

decodeLenient :: ByteString -> Text Source #

Decode as UTF-8, replacing invalid sequences with placeholders.