Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- encodeHex :: ByteString -> Text
- decodeHex :: Text -> Maybe ByteString
- lazilyEncodeHex :: LazyByteString -> LazyText
- type Text = Text
- type LazyText = Text
- type ByteString = ByteString
- type LazyByteString = ByteString
- lazyText :: Text -> LazyText
- strictText :: LazyText -> Text
- lazyByteString :: ByteString -> LazyByteString
- strictByteString :: LazyByteString -> ByteString
Encoding and decoding
encodeHex :: ByteString -> Text Source #
Encodes a byte string as hexadecimal number represented in text
Each byte of the input is converted into two characters in the resulting text.
>>>
(encodeHex . ByteString.singleton) 192
"c0"
>>>
(encodeHex . ByteString.singleton) 168
"a8"
>>>
(encodeHex . ByteString.pack) [192, 168, 1, 2]
"c0a80102"
Text
produced by encodeHex
can be converted back to a
ByteString
using decodeHex
.
The lazy variant of encodeHex
is lazilyEncodeHex
.
lazilyEncodeHex :: LazyByteString -> LazyText Source #
The lazy variant of encodeHex
With laziness, it is possible to encode byte strings of infinite length:
>>>
(LazyText.take 8 . lazilyEncodeHex . LazyByteString.pack . cycle) [1, 2, 3]
"01020301"
Types
type ByteString = ByteString Source #
Strict byte string
type LazyByteString = ByteString Source #
Lazy byte string
Type conversions
strictText :: LazyText -> Text Source #