pub fn escape_control(text: &str) -> Cow<'_, str>Expand description
Make text from other processes safe to print: control characters become
visible escapes, as lsof and ps do. Names, command lines and paths are
set by whoever runs a process, and printed raw an ESC sequence could
recolour, retitle or rewrite the terminal of whoever runs proc (and a
newline would split a table row). Applied where process data is read, so
every view and the JSON show the same text.
Escaped: C0 controls and DEL (\x1b, with \n, \r, \t by name), C1
controls (\x9b), and bidirectional overrides that reorder text on screen
(\u{202e}). Everything else, non-ASCII included, is unchanged. Works on
chars, never byte offsets, so it can’t split a character.