Skip to main content

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 encoding = table.encoding.get_code_to_sid_table(&table.charset);
15    for (cid, sid) in encoding.iter() {
16        println!("{}: {:?}", cid, string_by_id(&table, *sid));
17    }
18
19}