pub fn format_unicode_debug_into<W>(
    dest: W,
    string: &[u8]
) -> Result<(), WriteError> where
    W: Write
Expand description

Write a UTF-8 debug representation of a byte slice into the given writer.

This method encodes a bytes slice into a UTF-8 valid representation by writing invalid sequences as \xXX escape codes.

This method also escapes UTF-8 valid characters like \n and \t.


Basic usage:

let mut message = String::from("cannot load such file -- ");
let filename = b"utf8-invalid-name-\xFF";
format_unicode_debug_into(&mut message, &filename[..]);
assert_eq!(r"cannot load such file -- utf8-invalid-name-\xFF", message);


This method only returns an error when the given writer returns an error.