Function fast32::decoder_map
source · pub const fn decoder_map<const B: usize, const N: usize>(
enc: &[u8; B],
from: &[u8; N],
to: &[u8; N]
) -> [u8; 256]
Expand description
Build a new decoder array for the given bits (encoder array size), with additional character translations
You should use fast32::make_base32_alpha
or fast32::make_base64_alpha
instead of this!
(Those macros invoke this function as appropriate.)
Example:
use fast32::decoder_map;
use fast32::base32::Alphabet32Nopad;
const ENC_CROCKFORD_LOWER: &'static [u8; 32] = b"0123456789abcdefghjkmnpqrstvwxyz";
const DEC_CROCKFORD_LOWER: [u8; 256] = decoder_map(
ENC_CROCKFORD_LOWER,
b"iloABCDEFGHIJKLMNOPQRSTVWXYZ",
b"110abcdefgh1jk1mn0pqrstvwxyz",
);
pub const CROCKFORD_LOWER: Alphabet32Nopad = Alphabet32Nopad::new(ENC_CROCKFORD_LOWER, &DEC_CROCKFORD_LOWER);
assert_eq!(CROCKFORD_LOWER.encode_u64(31), "z");
assert_eq!(CROCKFORD_LOWER.decode_u64_str("z").unwrap(), 31);
See more in tests/alphabet.rs