Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
MIME character sets.
Recognised charsets:
us-ascii
/iso646-us
utf-8
iso-8859-1
See also the purebred-icu plugin, which adds support for many character sets.
Synopsis
- class HasCharset a where
- type Decoded a
- charsetName :: Getter a (Maybe CharsetName)
- charsetData :: Getter a ByteString
- charsetDecoded :: AsCharsetError e => CharsetLookup -> forall p f. (Profunctor p, Contravariant f) => Optic' p f a (Either e (Decoded a))
- charsetDecoded' :: CharsetLookup -> forall p f. (Profunctor p, Contravariant f) => Optic' p f a (Either CharsetError (Decoded a))
- charsetEncode :: Decoded a -> a
- type CharsetName = CI ByteString
- charsetText :: (HasCharset a, AsCharsetError e, Profunctor p, Contravariant f) => CharsetLookup -> Optic' p f a (Either e Text)
- charsetText' :: (HasCharset a, Profunctor p, Contravariant f) => CharsetLookup -> Optic' p f a (Either CharsetError Text)
- data CharsetError
- class AsCharsetError s where
- charsetPrism :: forall a. HasCharset a => CharsetLookup -> Prism' a (Decoded a)
- type CharsetLookup = CI ByteString -> Maybe Charset
- defaultCharsets :: CharsetLookup
- decodeLenient :: ByteString -> Text
Documentation
class HasCharset a where Source #
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 -> forall p f. (Profunctor p, Contravariant f) => Optic' p f a (Either e (Decoded a)) Source #
Structure with the encoded data replaced with Text
charsetDecoded' :: CharsetLookup -> forall p f. (Profunctor p, Contravariant f) => Optic' p f a (Either CharsetError (Decoded a)) Source #
Structure with the encoded data replaced with Text
(monomorphic error type)
charsetEncode :: Decoded a -> a Source #
Encode the data
Instances
HasCharset EncodedParameterValue Source # | The default charset 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). |
Defined in Data.MIME.Parameter charsetName :: Getter EncodedParameterValue (Maybe CharsetName) Source # charsetData :: Getter EncodedParameterValue ByteString Source # charsetDecoded :: AsCharsetError e => CharsetLookup -> forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Contravariant f) => Optic' p f EncodedParameterValue (Either e (Decoded EncodedParameterValue)) Source # charsetDecoded' :: CharsetLookup -> forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Contravariant f) => Optic' p f EncodedParameterValue (Either CharsetError (Decoded EncodedParameterValue)) Source # charsetEncode :: Decoded EncodedParameterValue -> EncodedParameterValue Source # | |
HasCharset ByteEntity Source # | RFC 6657
specifies that each subtype of the
|
Defined in Data.MIME type Decoded ByteEntity Source # charsetName :: Getter ByteEntity (Maybe CharsetName) Source # charsetData :: Getter ByteEntity ByteString Source # charsetDecoded :: AsCharsetError e => CharsetLookup -> forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Contravariant f) => Optic' p f ByteEntity (Either e (Decoded ByteEntity)) Source # charsetDecoded' :: CharsetLookup -> forall (p :: Type -> Type -> Type) (f :: Type -> Type). (Profunctor p, Contravariant f) => Optic' p f ByteEntity (Either CharsetError (Decoded ByteEntity)) Source # |
type CharsetName = CI ByteString Source #
charsetText :: (HasCharset a, AsCharsetError e, Profunctor p, Contravariant f) => CharsetLookup -> Optic' p f a (Either e Text) Source #
Decode the object according to the declared charset.
charsetText' :: (HasCharset a, Profunctor p, Contravariant f) => CharsetLookup -> Optic' p f a (Either CharsetError Text) Source #
Monomorphic in error type
data CharsetError Source #
Instances
Show CharsetError Source # | |
Defined in Data.MIME.Charset showsPrec :: Int -> CharsetError -> ShowS # show :: CharsetError -> String # showList :: [CharsetError] -> ShowS # | |
AsCharsetError CharsetError Source # | |
class AsCharsetError s where Source #
_CharsetError :: Prism' s CharsetError Source #
_CharsetUnspecified :: Prism' s () Source #
Instances
charsetPrism :: forall a. HasCharset a => CharsetLookup -> Prism' a (Decoded a) Source #
Prism for charset decoded/encoded data. Information about decoding failures is discarded.
type CharsetLookup = CI ByteString -> Maybe Charset Source #
defaultCharsets :: CharsetLookup Source #
Supports US-ASCII, UTF-8 and ISO-8859-1, UTF-16[BE|LE] and UTF-32[BE|LE]. The purebred-icu package provides support for more charsets.
decodeLenient :: ByteString -> Text Source #
Decode as UTF-8, replacing invalid sequences with placeholders.