encoding-0.6.3: A library for various character encodings




class Encoding enc whereSource

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


decodeChar :: ByteSource m => enc -> m CharSource

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 StringSource

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 -> BoolSource

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 -> DynEncodingSource

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

encodingFromStringExplicit :: String -> Maybe DynEncodingSource

Like encodingFromString but returns Nothing instead of throwing an error