- class Encoding enc where
- encode :: enc -> String -> ByteString
- encodeLazy :: enc -> String -> ByteString
- encodable :: enc -> Char -> Bool
- decode :: enc -> ByteString -> String
- decodeLazy :: enc -> ByteString -> String
- decodable :: enc -> ByteString -> Bool
- data EncodingException = HasNoRepresentation Char
- data DecodingException
- recode :: (Encoding from, Encoding to) => from -> to -> ByteString -> ByteString
- recodeLazy :: (Encoding from, Encoding to) => from -> to -> ByteString -> ByteString
- data DynEncoding
- encodingFromString :: String -> DynEncoding
Documentation
class Encoding enc whereSource
Represents an encoding, supporting various methods of de- and encoding. Minimal complete definition: encode, decode
encode :: enc -> String -> ByteStringSource
Encode a String
into a strict ByteString
. Throws the
HasNoRepresentation
-Exception if it encounters an unrepresentable
character.
encodeLazy :: enc -> String -> ByteStringSource
Encode a String
into a lazy Data.ByteString.Lazy.ByteString
.
encodable :: enc -> Char -> BoolSource
decode :: enc -> ByteString -> StringSource
Decode a strict ByteString
into a String
. If the string is not
decodable, a DecodingException
is thrown.
decodeLazy :: enc -> ByteString -> StringSource
decodable :: enc -> ByteString -> BoolSource
Whether or no a given ByteString
is decodable. Default: True
.
data EncodingException Source
This exception type is thrown whenever something went wrong during the encoding-process.
HasNoRepresentation Char | Thrown if a specific character is not representable in an encoding. |
data DecodingException Source
This exception type is thrown whenever something went wrong during the decoding-process.
IllegalCharacter Word8 | The sequence contained an illegal byte that couldn't be decoded. |
UnexpectedEnd | more bytes were needed to allow a successfull decoding. |
OutOfRange | the decoded value was out of the unicode range |
recode :: (Encoding from, Encoding to) => from -> to -> ByteString -> ByteStringSource
This decodes a string from one encoding and encodes it into another.
recodeLazy :: (Encoding from, Encoding to) => from -> to -> ByteString -> ByteStringSource
data DynEncoding Source
An untyped encoding. Used in System.IO.Encoding.getSystemEncoding
.
encodingFromString :: String -> DynEncodingSource
Takes the name of an encoding and creates a dynamic encoding from it.