[][src]Function fixed_buffer::escape_ascii

pub fn escape_ascii(input: &[u8]) -> String

Convert a byte slice into a string. Includes printable ASCII characters as-is. Converts non-printable or non-ASCII characters to strings like "\n" and "\x19".

Uses std::ascii::escape_default internally to escape each byte.

This function is useful for printing byte slices to logs and comparing byte slices in tests.

Example test:

use fixed_buffer::{escape_ascii, FixedBuf};
let mut buf: FixedBuf<[u8; 16]> = FixedBuf::new([0u8; 16]);
buf.write_str("ab");
buf.write_str("cd");
assert_eq!("abcd", escape_ascii(buf.readable()));