Skip to main content

winansi_byte

Function winansi_byte 

pub fn winansi_byte(ch: char) -> Option<u8>
Expand description

Returns the PDF WinAnsiEncoding byte that encodes ch, or None if ch has no slot in WinAnsi.

The inverse of the byte→char mapping transcribed from PDF 1.7 Annex D.2 Table D.2 into winansi_char_map::WINANSI_CHAR_MAP. Returns None for:

  • Characters that have no glyph in WinAnsi (Cyrillic, CJK, most accented Vietnamese, etc.).
  • The six WinAnsi gap bytes (0x7F, 0x81, 0x8D, 0x8F, 0x90, 0x9D).

O(n) scan over 256 slots: fine for callers that touch it once per text run, sensible to memoize for hotter paths.

§Examples

use pdf_base14_metrics::winansi_byte;

assert_eq!(winansi_byte('A'), Some(b'A'));
assert_eq!(winansi_byte('Ж'), None);