CualerID
Documentation for CualerID.
CualerID.BASE30_ALPHABETCualerID.ResultCodeCualerID.ResultCodeOptionCualerID.base30encodeCualerID.has_duplicateCualerID.has_fixedCualerID.has_not_fixableCualerID.has_validCualerID.rebase
CualerID.BASE30_ALPHABET — Constant
BASE30_ALPHABET::Vector{UInt8}An alphabet designed for unambiguous representation of values in either upper- or lower-case. The alphabet was formed by taking the numbers 0-9 and the Latin alphabet and removing characters that are considered easy to confuse. Excluded characters are
- $I$ => easily confused for lowercase $L$ or the digit $1$
- $L$ => easily confused for uppercase $I$ or the digit $1$
- $O$ => easily confused for the digit $0$
- $Q$ => easily confused with uppercase $O$ or lowercase $g$
- $V$ => easily confused with $U$
This array contains the ASCII index of the characters included in the base30 alphabet starting with 0 at position BASE30_ALPHABET[1]. Use String() to convert an array of these indices to a base30 string.
CualerID.ResultCode — Type
ResultCode::UInt8Encodes a result of attempting to correct a CualerID
The valid codes are
- D: duplicate
- F: fixed
- N: not fixable
- V: valid (no need for correction)
CualerID.ResultCodeOption — Type
ResultCodeOptionEncodes potential corrected id codes.
The valid codes are
- D: duplicate
- F: fixed
- N: not fixable
- V: valid (no need for correction)
The codes are implemented exactly as from cual-id and in that order
Constructors
ResultCodeOption(str::AbstractString)Create a ResultCodeOption based on a the character codes contained within str. str is case insensitive, may contain an arbitrary number of valid codes (as specified above), and may contain duplicates. A ResultCodeOption cannot be constructed from a combination of strings and bitmasks/integers.
Extended help
The struct stores values as a bitmask
| Bit (Int) | Bit (UInt) | Description |
|---|---|---|
| 1 | 0x01 | D - duplicate |
| 2 | 0x02 | F - fixed |
| 4 | 0x04 | N - not fixable |
| 8 | 0x08 | V - valid |
CualerID.base30encode — Method
base30encode(v::Integer)
-base30encode(v::UUID)Creates a base30 representation of v. If v is a UUID, then the UInt128 value of the UUID is passed directly into the method.
Examples
julia> base30encode(30)
-"10"
-
-julia> using UUIDs
-
-julia> base30encode(UUIDs.uuid1())
-"7ZK00JECBDF2H7GNBXN59C6S9S"Just like rebase, this method is not tested on negative integers and may produce incorrect output when passed negative numbers
CualerID.has_duplicate — Method
has_duplicate(r::ResultCodeOption)Determines if r contains a duplicate result (ResultCode D)
CualerID.has_fixed — Method
has_fixed(r::ResultCodeOption)Determines if r contains a fixed result (ResultCode F)
CualerID.has_not_fixable — Method
has_not_fixable(r::ResultCodeOption)Determines if r contains a not fixable result (ResultCode N)
CualerID.has_valid — Method
has_valid(r::ResultCodeOption)Determines if r contains a valid (not corrected) result (ResultCode V)
CualerID.rebase — Method
rebase(v::Integer, base::Integer)Rebase v into the base system of base. v can be any integer type, and can be represented in base 10 (decimal) or base 16 (hexadecimal) based on Julia's treatment of that integer type. Returns a Vector{UInt8} containing the indices of each digit in the rebased number. Since Julia is 1-indexed, this means that rebase(0, base)[1] actually returns a value of UInt8[1], since the first index of a numeral system's alphabet is assumed to be its $0$ value.
Examples
julia> rebase(0, 10)
-1-element Vector{UInt8}:
- 0x01
-
-julia> # Two plus two is ten... IN BASE FOUR! I'M FINE!
-
-julia> rebase(2 + 2, 4)
-2-element Vector{UInt8}:
- 0x02
- 0x01
-
-julia> base_4_alphabet = ['0', '1', '2', '3'];
-
-julia> String([base_4_alphabet[i] for i in rebase(2 + 2, 4)])
-"10"