base62-0.1.1.2: Base62 encoding and decoding
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Word.Base62

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.

Synopsis

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.

builder64 :: Word64 -> Builder 11 Source #

Base62 encode a 64-bit word as a builder.

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.

text128 :: Word128 -> Text Source #

Base62 encode a 128-bit word as Text.

builder128 :: Word128 -> Builder 22 Source #

Base62 encode a 128-bit word as a builder.

decode128 :: Bytes -> Maybe Word128 Source #

Decode a base62-encoded 128-bit word. This rejects the empty string rather than decoding it as zero. This also rejects encoded numbers greater than or equal to 2^128.