tounicode/
tounicode.rs

1use std::io::Read;
2
3use cff_parser::{Table, string_by_id};
4
5fn main() {
6    // open the file passed on the comanmand line
7    let path = std::env::args().nth(1).expect("no file given");
8    let file = std::fs::File::open(&path).expect("could not open file");
9    let mut reader = std::io::BufReader::new(file);
10    let mut buffer = Vec::new();
11    reader.read_to_end(&mut buffer).expect("could not read file");
12    let table = Table::parse(&buffer).unwrap();
13
14    let charset = table.charset.get_table();
15    let encoding = table.encoding.get_table();
16    for i in 0..encoding.len() {
17        let cid = encoding[i];
18        let sid = charset[i];
19        println!("{}: {:?}", cid, string_by_id(&table, sid));
20    }
21
22}