Skip to main content

name_decode

Function name_decode 

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

Resolve #xx escapes in a raw name token.

An escape needs both following bytes to be present and another byte after them, so a # in the last two positions stays literal: #4 decodes to #4, while #41 decodes to A and #411 to A1. A non-hexadecimal byte inside an escape counts as zero rather than aborting the escape.

use pdfrum_object::name_decode;

assert_eq!(name_decode(b"#41"), b"A");
assert_eq!(name_decode(b"#4"), b"#4");
assert_eq!(name_decode(b"#411"), b"A1");