pub(crate) unsafe fn print_escaped(
stdout: &mut dyn Write,
str: *const u8,
length: u64,
) -> Result<()>
Expand description
Writes an escaped version of a byte slice to the given output.
This function handles proper escaping of special characters and preserves UTF-8 encoded characters.
§Safety
This function is unsafe because it works with raw pointers.
The caller must ensure that str
points to a valid memory location
containing at least length
bytes.
§Arguments
stdout
- A mutable reference to a type that implementsWrite
, to which the escaped output will be written.str
- A raw pointer to the start of the byte slice to be escaped.length
- The length of the byte slice.
§Returns
Returns Ok(())
if writing succeeds, or an io::Error
if any issues occur during writing.