encode

Function encode 

Source
pub fn encode(data: &[u8], alphabet: &Alphabet) -> String
Expand description

Encodes binary data using the specified alphabet.

Automatically selects the appropriate encoding strategy based on the alphabet’s mode (BaseConversion, Chunked, or ByteRange).

§Arguments

  • data - The binary data to encode
  • alphabet - The alphabet to use for encoding

§Returns

A string containing the encoded data

§Examples

use base_d::{Alphabet, EncodingMode};

let chars: Vec<char> = "01".chars().collect();
let alphabet = Alphabet::new_with_mode(chars, EncodingMode::BaseConversion, None)?;
let encoded = base_d::encode(b"Hi", &alphabet);