Function encode

Source
pub fn encode(input: &[u8]) -> Cow<'_, str>
Expand description

Encode the given input as a string, escaping any bytes that require it. If no bytes require escaping, then the result will be borrowed from the input.

ยงExample

let encoded = tick_encoding::encode(b"hello world!");
assert_eq!(encoded, "hello world!");

let encoded = tick_encoding::encode(&[0x00, 0xFF]);
assert_eq!(encoded, "`00`FF");