Skip to main content

encode_string_literal

Function encode_string_literal 

Source
pub fn encode_string_literal(bytes: &[u8]) -> Vec<u8> 
Expand description

Spell bytes as a literal string: (…) with \n, \r, \(, \) and \\ escaped and every other byte verbatim.

use pdfrum_object::encode_string_literal;

assert_eq!(encode_string_literal(b"a(b)c"), b"(a\\(b\\)c)");
assert_eq!(encode_string_literal(b"line\n"), b"(line\\n)");