Skip to main content

encode_text

Function encode_text 

Source
pub fn encode_text(text: &str) -> Vec<u8> 
Expand description

Write text back out as a text string’s bytes (ISO 32000-1 §7.9.2.2).

PDFDocEncoding when every character has a byte in the table (the first matching byte wins, so U+0000 encodes as 0x00), otherwise FE FF followed by UTF-16BE.

use pdfrum_object::encode_text;

assert_eq!(encode_text("the quick\tfox"), b"the quick\tfox");
assert_eq!(encode_text("\u{0330}\u{0331}"), b"\xFE\xFF\x03\x30\x03\x31");