Function stfu8::encode_u8_pretty

source ·
pub fn encode_u8_pretty(v: &[u8]) -> String
Expand description

Encode text as STFU-8, escaping all non-printable or non UTF-8 bytes EXCEPT:

  • \t: tab
  • \n: line feed
  • \r: cariage return

This will allow the encoded text to print “pretilly” while still escaping invalid unicode and other non-printable characters.

Also check out:

Examples


let encoded = stfu8::encode_u8_pretty(b"foo\xFF\nbar");
assert_eq!(
    encoded,
    "foo\\xFF\nbar"
);