[−][src]Function artichoke_backend::string::format_unicode_debug_into
pub fn format_unicode_debug_into<W>(
dest: W,
string: &[u8]
) -> Result<(), WriteError> where
W: Write,
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
.
Examples
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);
Errors
This method only returns an error when the given writer returns an error.