fix errant has_eci

This commit is contained in:
Henry Schimke
2023-04-24 18:16:48 -05:00
parent 483539a194
commit 31413b3044
3 changed files with 20 additions and 3 deletions

View File

@@ -22,11 +22,11 @@
// import java.nio.charset.StandardCharsets;
use std::{
collections::HashMap,
collections::{HashMap, HashSet},
fmt::{self, Display},
};
use crate::BarcodeFormat;
use crate::{pdf417::decoder::ec, BarcodeFormat};
use super::{CharacterSet, Eci, StringUtils};
@@ -125,6 +125,12 @@ impl ECIStringBuilder {
}
self.eci_positions.push((eci, self.bytes.len(), 0));
let ecis = self.list_ecis();
if ecis.len() <= 1 && (ecis.contains(&Eci::Unknown)) {
self.has_eci = false;
}
}
}
@@ -263,6 +269,14 @@ impl ECIStringBuilder {
self
}
pub fn list_ecis(&self) -> HashSet<Eci> {
let mut hs = HashSet::new();
self.eci_positions.iter().for_each(|pos| {
hs.insert(pos.0);
});
hs
}
}
impl fmt::Display for ECIStringBuilder {