mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
fix errant has_eci
This commit is contained in:
@@ -51,6 +51,9 @@ where
|
||||
pub fn with_eci_string_builder(src: ECIStringBuilder) -> Self {
|
||||
let mut new_self = Self::default();
|
||||
new_self.content = src;
|
||||
|
||||
|
||||
|
||||
new_self
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::CharacterSet;
|
||||
|
||||
use crate::common::Result;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum Eci {
|
||||
Unknown = -1,
|
||||
Cp437 = 2, // obsolete
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user