Skip to main content

unicode_from_cid

Function unicode_from_cid 

Source
pub fn unicode_from_cid(set: CidSet, cid: Cid) -> Option<char>
Expand description

The Unicode scalar a character collection assigns to a CID (ISO 32000-1 §9.10.2), or None when it assigns none.

CidSet::Unicode is the identity map. CID 0 is U+FFFD in every built-in table, so an unmapped character code extracts as the replacement character.

use pdfrum_cmap::{Cid, CidSet, unicode_from_cid};

assert_eq!(unicode_from_cid(CidSet::Gb1, Cid(0)), Some('\u{FFFD}'));
assert_eq!(unicode_from_cid(CidSet::Gb1, Cid(34)), Some('A'));
assert_eq!(unicode_from_cid(CidSet::Unicode, Cid(0x41)), Some('A'));
assert_eq!(unicode_from_cid(CidSet::Unknown, Cid(1)), None);