| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Data.Word.Base62
Contents
Description
This module provides functions for encoding fixed-width words using the base-62 encoding scheme. The encoding functions in this module produce byte sequences that are ASCII-compatible text encodings (e.g. ISO-8859-1 and UTF-8). Similarly, the decoding functions only decode byte sequences that are an ASCII-compatible text encoding of characters in the class [A-Za-Z0-9]. Other encodings (notably UTF-16) are not supported but would be accepted in a pull request.
64-bit Word
encode64 :: Word64 -> ByteArray Source #
Base62 encode a 64-bit word. Leading zero bits are suppressed. Note that this will encode the number 0 as the character '0' rather than as the empty byte array.
decode64 :: Bytes -> Maybe Word64 Source #
Decode a base62-encoded 64-bit word. This rejects the empty string rather than decoding it as zero. This also rejects encoded numbers greater than or equal to 2^64.
128-bit Word
encode128 :: Word128 -> ByteArray Source #
Base62 encode a 128-bit word. Leading zero bits are suppressed.
shortText128 :: Word128 -> ShortText Source #
Base62 encode a 128-bit word as ShortText.
builder128 :: Word128 -> Builder 22 Source #
Base62 encode a 128-bit word as a builder.