Data.Bytes.Text.Utf8

byteslice-0.2.14.0: Slicing managed and unmanaged memory

Safe Haskell | None
Language | Haskell2010

Data.Bytes.Text.Utf8

Description

Convert `Bytes` to and from `Text` and `ShortText`.

Synopsis

- fromShortText :: ShortText -> Bytes
- toShortText :: Bytes -> Maybe ShortText
- fromText :: Text -> Bytes
- toText :: Bytes -> Maybe Text

# Documentation

fromShortText :: ShortText -> Bytes #

Encode `ShortText` using UTF-8. Since `ShortText` is backed by a UTF-8 byte sequence, this does not perform a copy.

toShortText :: Bytes -> Maybe ShortText #

Attempt to interpret the byte sequence as UTF-8 encoded text. Returns `Nothing` if the bytes are not UTF-8 encoded text.

fromText :: Text -> Bytes #

Encode `Text` using `UTF-8`. Only available when building with `text-2.0` and newer. Since `Text` is backed by a UTF-8 byte sequence, this does not perform a copy.

toText :: Bytes -> Maybe Text #

Attempt to interpret byte sequence as `UTF-8` encoded `Text`. Only available when building with `text-2.1` and newer. Since `Text` is backed by a UTF-8 byte sequence, this does not perform a copy.