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

@@ -16,7 +16,7 @@
use unicode_segmentation::UnicodeSegmentation;
use super::CharacterSet;
use super::{CharacterSet, Eci};
use once_cell::sync::Lazy;
@@ -100,7 +100,7 @@ impl ECIEncoderSet {
neededEncoders.push(CharacterSet::ISO8859_1);
let mut needUnicodeEncoder = if let Some(pc) = priorityCharset {
//pc.name().starts_with("UTF") || pc.name().starts_with("utf")
pc == CharacterSet::UTF8 || pc == CharacterSet::UnicodeBigUnmarked
pc == CharacterSet::UTF8 || pc == CharacterSet::UTF16BE
} else {
false
};
@@ -157,7 +157,7 @@ impl ECIEncoderSet {
}
encoders.push(CharacterSet::UTF8);
encoders.push(CharacterSet::UnicodeBigUnmarked);
encoders.push(CharacterSet::UTF16BE);
}
//Compute priorityEncoderIndex by looking up priorityCharset in encoders
@@ -206,8 +206,8 @@ impl ECIEncoderSet {
}
}
pub fn getECIValue(&self, encoderIndex: usize) -> u32 {
self.encoders[encoderIndex].get_eci_value()
pub fn get_eci(&self, encoderIndex: usize) -> Eci {
self.encoders[encoderIndex].into()
// CharacterSetECI::getValue(
// &CharacterSetECI::getCharacterSetECI(self.encoders[encoderIndex]).unwrap(),
// )