Skip to content

Commit

Permalink
handle double quotes in dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
shevernitskiy committed Mar 14, 2024
1 parent 77f6304 commit cc6df81
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ impl Dictionary {
let mut contents: Vec<u8> = Vec::new();
file.read_to_end(&mut contents);
let mut map = HashMap::<Vec<u8>, Vec<u8>>::new();
let quote = &b"\""[0];
for item in regex::bytes::Regex::new(r#"(?-u)"(.+)","(.+)""#)?.captures_iter(&contents) {
let mut k = item[1].to_vec();
let mut v = item[2].to_vec();
v.push(0);
map.insert(item[1].to_vec(), v);
k.dedup_by(|a, b| a == quote && b == quote);
v.dedup_by(|a, b| a == quote && b == quote);
map.insert(k, v);
}
Ok(map)
}
Expand Down

0 comments on commit cc6df81

Please sign in to comment.