base16-bytestring-0.1.1.1: Fast base16 (hex) encoding and deconding for ByteStrings

PortabilityGHC
Stabilityexperimental
Maintainerbos@mailrank.com

Data.ByteString.Base16.Lazy

Description

Fast and efficient encoding and decoding of base16-encoded strings.

Synopsis

Documentation

encode :: ByteString -> ByteStringSource

Encode a string into base16 form. The result will always be a multiple of 2 bytes in length.

Example:

 encode "foo"  == "666f6f"

decode :: ByteString -> (ByteString, ByteString)Source

Decode a string from base16 form. The first element of the returned tuple contains the decoded data. The second element starts at the first invalid base16 sequence in the original string.

This function operates as lazily as possible over the input chunks. The only instance in which it is non-lazy is if an odd-length chunk ends with a byte that is valid base16.

Examples:

 decode "666f6f"  == ("foo", "")
 decode "66quux"  == ("f", "quux")
 decode "666quux" == ("f", "6quux")