encoding-0.8: A library for various character encodings

Safe HaskellNone
LanguageHaskell98

Data.Encoding

Synopsis

Documentation

class Encoding enc where Source

The base class for all encodings. At least decodeChar, encodeChar and encodeable must be implemented.

Minimal complete definition

decodeChar, encodeChar, encodeable

Methods

decodeChar :: ByteSource m => enc -> m Char Source

Read a single character of a ByteSource

encodeChar :: ByteSink m => enc -> Char -> m () Source

Encode a single character and write it to a ByteSink

decode :: ByteSource m => enc -> m String Source

Read characters from a ByteSource until it is empty

encode :: ByteSink m => enc -> String -> m () Source

Encode a String and write it to a ByteSink

encodeable :: enc -> Char -> Bool Source

Tests whether a given character is representable in the Encoding. If this yields True, encodeChar must not fail. If it yields False, encodeChar _must_ throw an exception.

data DynEncoding Source

Wraps all possible encoding types into one data type. Used when a function needs to return an encoding.

recode :: (Encoding enc1, Encoding enc2, ByteSource m, ByteSink m) => enc1 -> enc2 -> m () Source

encodingFromString :: String -> DynEncoding Source

Takes the name of an encoding and creates a dynamic encoding from it.

encodingFromStringExplicit :: String -> Maybe DynEncoding Source

Like encodingFromString but returns Nothing instead of throwing an error