dec_sixbit

Function decode_unchecked

Source
pub fn decode_unchecked(bytes: &[u8], len: usize) -> String
Expand description

This function performs decoding without validating whether the SIXBIT values are within the valid range or whether the resulting bytes form a valid UTF-8 string. Use this function only when you are certain the input is valid to avoid undefined behavior.

§Safety

The bytes slice must contain valid SIXBIT-encoded data:

  • The len must accurately reflect the number of original characters.

§Parameters

  • bytes: A slice of bytes containing SIXBIT-encoded data.
  • len: The length of the original string.

§Returns

The decoded string.

§Examples

use dec_sixbit::{encode, decode_unchecked};

let input = "HELLO";
let (encoded_bytes, length) = encode(input).unwrap();
let decoded_string = unsafe { decode_unchecked(&encoded_bytes, length) };
assert_eq!(decoded_string, input);