move to using Eci enum

Decouples the Eci and CharacterSet concepts within the library. Character sets can now exist independently from Eci encodation schemes.
This commit is contained in:
Henry Schimke
2023-03-04 14:13:50 -06:00
parent 15859b9f10
commit 8a0744e534
21 changed files with 403 additions and 182 deletions

View File

@@ -242,7 +242,7 @@ impl HighLevelEncoder {
//if let Some(eci) = CharacterSetECI::getCharacterSetECI(self.charset) {
if self.charset != CharacterSet::ISO8859_1 {
//} && eci != CharacterSetECI::Cp1252 {
initial_state = initial_state.appendFLGn(self.charset.get_eci_value())?;
initial_state = initial_state.appendFLGn(self.charset.into())?;
}
// } else {
// return Err(Exceptions::illegal_argument_with(

View File

@@ -17,7 +17,7 @@
use std::fmt;
use crate::{
common::{BitArray, CharacterSet, Result},
common::{BitArray, CharacterSet, Result, Eci},
exceptions::Exceptions,
};
@@ -71,7 +71,7 @@ impl State {
self.bit_count
}
pub fn appendFLGn(self, eci: u32) -> Result<Self> {
pub fn appendFLGn(self, eci: Eci) -> Result<Self> {
let bit_count = self.bit_count;
let mode = self.mode;
let result = self.shiftAndAppend(HighLevelEncoder::MODE_PUNCT as u32, 0); // 0: FLG(n)
@@ -80,7 +80,7 @@ impl State {
/*if eci < 0 {
token.add(0, 3); // 0: FNC1
} else */
if eci > 999999 {
if eci as u32 > 999999 {
return Err(Exceptions::illegal_argument_with(
"ECI code must be between 0 and 999999",
));