Data.Bytes.Text.Ascii

byteslice-0.2.14.0: Slicing managed and unmanaged memory

Safe Haskell | None
Language | Haskell2010

Data.Bytes.Text.Ascii

Description

This module treats `Bytes` data as holding ASCII text. Providing bytes outside the ASCII range (`U+0000` -- `U+007F`) may cause a failure or unspecified results, but such bytes will never be inspected.

For functions that can operate on ASCII-compatible encodings, see `AsciiExt`.

Synopsis

- fromString :: String -> Bytes
- decodeDecWord :: Bytes -> Maybe Word
- equalsCStringCaseInsensitive :: CString -> Bytes -> Bool
- toShortText :: Bytes -> Maybe ShortText
- toShortTextU :: ByteArray -> Maybe ShortText
- toText :: Bytes -> Maybe Text

# Documentation

fromString :: String -> Bytes #

Convert a `String` consisting of only characters in the ASCII block to a byte sequence. Any character with a codepoint above `U+007F` is replaced by `U+0000`.

decodeDecWord :: Bytes -> Maybe Word #

Decode machine-sized word from decimal representation. Returns Nothing on overflow. Allows any number of leading zeros. Trailing non-digit bytes cause Nothing to be returned.

equalsCStringCaseInsensitive :: CString -> Bytes -> Bool #

Is the byte sequence equal to the `NUL`-terminated C String? The C string must be a constant.

toShortText :: Bytes -> Maybe ShortText #

toShortTextU :: ByteArray -> Maybe ShortText #

toText :: Bytes -> Maybe Text #

Interpret byte sequence as ASCII codepoints. Only available when building with `text-2.0` and newer. Returns `Nothing` if any of the bytes are outside of the range `0x00-0x7F`