streaming-commons-0.1.14.2: Common lower-level functions needed by various streaming data libraries

Safe Haskell | None
Language | Haskell98

Data.Streaming.Text

Contents

- Streaming
- Type

Description

Provides a stream-based approach to decoding Unicode data. Each function below works the same way: you give it a chunk of data, and it gives back a `DecodeResult`. If the parse was a success, then you get a chunk of `Text` (possibly empty) and a continuation parsing function. If the parse was a failure, you get a chunk of successfully decoded `Text` (possibly empty) and the unconsumed bytes.

In order to indicate end of stream, you pass an empty `ByteString` to the decode function. This call may result in a failure, if there were unused bytes left over from a previous step which formed part of a code sequence.

Synopsis

- decodeUtf8 :: ByteString -> DecodeResult
- decodeUtf8Pure :: ByteString -> DecodeResult
- decodeUtf16LE :: ByteString -> DecodeResult
- decodeUtf16BE :: ByteString -> DecodeResult
- decodeUtf32LE :: ByteString -> DecodeResult
- decodeUtf32BE :: ByteString -> DecodeResult
- data DecodeResult
  - = DecodeResultSuccess !Text !(ByteString -> DecodeResult)
  - | DecodeResultFailure !Text !ByteString

# Streaming

decodeUtf8 :: ByteString -> DecodeResult

O(n) Convert a `ByteString` into a 'Stream Char', using UTF-8 encoding.

decodeUtf8Pure :: ByteString -> DecodeResult

O(n) Convert a `ByteString` into a 'Stream Char', using UTF-8 encoding.

decodeUtf16LE :: ByteString -> DecodeResult

O(n) Convert a `ByteString` into a 'Stream Char', using little endian UTF-16 encoding.

decodeUtf16BE :: ByteString -> DecodeResult

O(n) Convert a `ByteString` into a 'Stream Char', using big endian UTF-16 encoding.

decodeUtf32LE :: ByteString -> DecodeResult

O(n) Convert a `ByteString` into a 'Stream Char', using little endian UTF-32 encoding.

decodeUtf32BE :: ByteString -> DecodeResult

O(n) Convert a `ByteString` into a 'Stream Char', using big endian UTF-32 encoding.

# Type

data DecodeResult

Constructors

DecodeResultSuccess !Text !(ByteString -> DecodeResult) |
DecodeResultFailure !Text !ByteString |