Decode a ByteString containing Latin-1 (aka ISO-8859-1) encoded text.
Moduletext-2.1.3Haskell2010
Data.Text.Lazy.Encoding
Functions for converting lazy Text values to and from lazy
ByteString, using several standard encodings.
To gain access to a much larger family of encodings, use the text-icu package.
- 20 values
- Packagetext-2.1.3
- Exports20
- LanguageHaskell2010
- LicenceBSD-2-Clause
- SourceEncoding.hs
Decoding ByteStrings to Text
0 declarationsAll of the single-parameter functions for decoding bytestrings encoded in one of the Unicode Transformation Formats (UTF) operate in a strict mode: each will throw an exception if given invalid input.
Each function has a variant, whose name is suffixed with -With,
that gives greater control over the handling of decoding errors.
For instance, decodeUtf8 will throw an exception, but
decodeUtf8With allows the programmer to determine what to do on a
decoding error.
Total Functions
These functions facilitate total decoding and should be preferred over their partial counterparts.
Catchable failure
Decode a ByteString containing UTF-8 encoded text..
If the input contains any invalid UTF-8 data, the relevant exception will be returned, otherwise the decoded text.
Note: this function is not lazy, as it must decode its entire input before it can return a result. If you need lazy (streaming) decoding, use decodeUtf8With in lenient mode.
Controllable error handling
Decode a ByteString containing UTF-8 encoded text.
Decode text from little endian UTF-16 encoding.
Decode text from big endian UTF-16 encoding.
Decode text from little endian UTF-32 encoding.
Decode text from big endian UTF-32 encoding.
Partial Functions
These functions are partial and should only be used with great caution
(preferably not at all). See Data.Text.Lazy.Encoding#g:total for better
solutions.
Decode a ByteString containing 7-bit ASCII
encoded text.
Decode a ByteString containing UTF-8 encoded text that is known
to be valid.
If the input contains any invalid UTF-8 data, an exception will be thrown that cannot be caught in pure code. For more control over the handling of invalid data, use decodeUtf8' or decodeUtf8With.
Decode text from little endian UTF-16 encoding.
If the input contains any invalid little endian UTF-16 data, an exception will be thrown. For more control over the handling of invalid data, use decodeUtf16LEWith.
Decode text from big endian UTF-16 encoding.
If the input contains any invalid big endian UTF-16 data, an exception will be thrown. For more control over the handling of invalid data, use decodeUtf16BEWith.
Decode text from little endian UTF-32 encoding.
If the input contains any invalid little endian UTF-32 data, an exception will be thrown. For more control over the handling of invalid data, use decodeUtf32LEWith.
Decode text from big endian UTF-32 encoding.
If the input contains any invalid big endian UTF-32 data, an exception will be thrown. For more control over the handling of invalid data, use decodeUtf32BEWith.
Encoding Text to ByteStrings
5 declarationsEncode text using UTF-8 encoding.
Encode text using little endian UTF-16 encoding.
Encode text using big endian UTF-16 encoding.
Encode text using little endian UTF-32 encoding.
Encode text using big endian UTF-32 encoding.
Encoding Text using ByteString Builders
2 declarationsEncode text to a ByteString Builder using UTF-8 encoding.
Encode text using UTF-8 encoding and escape the ASCII characters using a BoundedPrim.
Use this function is to implement efficient encoders for text-based formats like JSON or HTML.