pub fn decode_text_string(bytes: &[u8]) -> StringExpand description
Decodes a PDF text string (§7.9.2.2) to Unicode.
- Bytes starting with
FE FFare UTF-16BE. Unpaired surrogates and a trailing odd byte become U+FFFD; language escape sequences (U+001B, a language code,U+001B, §7.9.2.2.1) are removed. - Bytes starting with
EF BB BFare UTF-8 (PDF 2.0); invalid sequences become U+FFFD. - Anything else is
PDFDocEncoding. An undefined code (a C0 control other than tab, line feed and carriage return, 0x7F, 0x9F, 0xAD) keeps its own scalar, U+0000–U+00FF, as pdf.js, qpdf and pypdf read it: nothing is lost, and a caller that shows the text can drop control characters (ADR 0003 §1).
Never fails: text strings are display data, and a damaged one is still worth showing.
Added in 0.2.0.