Function torut::utils::quote_string[][src]

pub fn quote_string(text: &[u8]) -> String
Expand description

quote_string takes arbitrary binary data and encodes it using octal encoding. For \n \t and \r it uses these backslash notation rather than octal encoding.

It’s reverse function to unquote_string. According to torCP docs it creates QuotedString token.

Example

use torut::utils::quote_string;
assert_eq!(quote_string(b"asdf"), r#""asdf""#);
assert_eq!(quote_string("ŁŁ".as_bytes()), r#""\305\201\305\201""#);
assert_eq!(quote_string("\n\r\t".as_bytes()), r#""\n\r\t""#);
assert_eq!(quote_string("\0\0\0".as_bytes()), r#""\0\0\0""#);