encoding-0.2: A library for various character encodingsContentsIndex
Data.Encoding
Synopsis
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
= IllegalCharacter Word8
| UnexpectedEnd
| OutOfRange
data DynEncoding
encodingFromString :: String -> DynEncoding
Documentation
class Encoding enc where
Represents an encoding, supporting various methods of de- and encoding. Minimal complete definition: encode, decode
Methods
encode :: enc -> String -> ByteString
Encode a String into a strict ByteString. Throws the HasNoRepresentation-Exception if it encounters an unrepresentable character.
encodeLazy :: enc -> String -> ByteString
Encode a String into a lazy ByteString.
encodable :: enc -> Char -> Bool
Whether or not the given Char is representable in this encoding. Default: True.
decode :: enc -> ByteString -> String
Decode a strict ByteString into a String. If the string is not decodable, a DecodingException is thrown.
decodeLazy :: enc -> ByteString -> String
decodable :: enc -> ByteString -> Bool
Whether or no a given ByteString is decodable. Default: True.
show/hide Instances
data EncodingException
This exception type is thrown whenever something went wrong during the encoding-process.
Constructors
HasNoRepresentation CharThrown if a specific character is not representable in an encoding.
show/hide Instances
data DecodingException
This exception type is thrown whenever something went wrong during the decoding-process.
Constructors
IllegalCharacter Word8The sequence contained an illegal byte that couldn't be decoded.
UnexpectedEndmore bytes were needed to allow a successfull decoding.
OutOfRangethe decoded value was out of the unicode range
show/hide Instances
data DynEncoding
An untyped encoding. Used in getSystemEncoding.
show/hide Instances
encodingFromString :: String -> DynEncoding
Takes the name of an encoding and creates a dynamic encoding from it.
Produced by Haddock version 0.8