|Maintaineremail@example.com, firstname.lastname@example.org, email@example.com|
Types and functions for dealing with encoding and decoding errors in Unicode text.
The standard functions for encoding and decoding text are strict,
which is to say that they throw exceptions on invalid input. This
is often unhelpful on real world input, so alternative functions
exist that accept custom handlers for dealing with invalid inputs.
OnError handlers are normal Haskell functions. You can use
one of the presupplied functions in this module, or you can write a
custom handler of your own.
- data UnicodeException
- type OnError a b = String -> Maybe a -> Maybe b
- type OnDecodeError = OnError Word8 Char
- type OnEncodeError = OnError Char Word8
- lenientDecode :: OnError Word8 Char
- strictDecode :: OnError Word8 Char
- strictEncode :: OnError Char Word8
- ignore :: OnError a b
- replace :: b -> OnError a b
Error handling types
An exception type for representing Unicode encoding errors.
|DecodeError String (Maybe Word8)|
Could not decode a byte sequence because it was invalid under the given encoding, or ran out of input in mid-decode.
|EncodeError String (Maybe Char)|
Tried to encode a character that could not be represented under the given encoding, or ran out of input in mid-encode.
Function type for handling a coding error. It is supplied with two inputs:
Stringthat describes the error.
- The input value that caused the error. If the error arose
because the end of input was reached or could not be identified
precisely, this value will be
Useful error handling functions
Replace an invalid input byte with the Unicode replacement character U+FFFD.