pub fn byte_array_from_basenb_utf8(input: &[u8]) -> Result<Vec<u8>>Expand description
Decode a Basenb UTF-8 byte sequence into the original byte array.
This replicates the JS byteArrayFromBasenbUtf8(intArrayIn) logic:
- Determines the encoded remainder-length indicator (either a distinct 3‑byte remainder char or a generic 4‑byte packed char).
- For a distinct remainder char (3 bytes): remainder = 63497 - unpack32 (last3)
- For a generic (4 bytes) remainder char: decode that char as an 8‑bit
value, then
remainder = decoded_byte - 2 - If the full input length is exactly (or smaller than) the remainder char length, returns the sentinel UUID bytes to indicate invalid input (legacy behavior).
Remainder length (in bits) is passed to int_bit_array_from_basenb_string
which reconstructs the concatenated bit array; that is then converted back
to bytes.
Returns:
Ok(Vec<u8>)with decoded bytes (or sentinel bytes if invalid input).