Encodes values for PDF output: string escaping, name encoding.
Summary
Functions
Escapes a string for use inside a PDF literal string (parentheses),
transliterating UTF-8 to WinAnsi (CP1252) on the way: the base-14
fonts are single-byte, so bullets, dashes, and curly quotes would
otherwise come out as mojibake. Unmappable codepoints become ?.
Encodes a PDF literal string: (escaped_content)
Encodes a PDF name (e.g. font resource). Leading / and special chars.
Format a number for PDF (integer or float).
Transliterates a UTF-8 string into WinAnsi (CP1252) bytes: ASCII and
Latin-1 pass through, the CP1252 punctuation block (bullet, en/em
dash, curly quotes, ellipsis, euro...) maps to its byte, anything
else becomes ?.
Functions
Escapes a string for use inside a PDF literal string (parentheses),
transliterating UTF-8 to WinAnsi (CP1252) on the way: the base-14
fonts are single-byte, so bullets, dashes, and curly quotes would
otherwise come out as mojibake. Unmappable codepoints become ?.
Encodes a PDF literal string: (escaped_content)
Encodes a PDF name (e.g. font resource). Leading / and special chars.
Format a number for PDF (integer or float).
Transliterates a UTF-8 string into WinAnsi (CP1252) bytes: ASCII and
Latin-1 pass through, the CP1252 punctuation block (bullet, en/em
dash, curly quotes, ellipsis, euro...) maps to its byte, anything
else becomes ?.