mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
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:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
common::{BitSource, CharacterSet, DecoderRXingResult, ECIStringBuilder, Result},
|
||||
common::{BitSource, CharacterSet, DecoderRXingResult, ECIStringBuilder, Result, Eci},
|
||||
Exceptions,
|
||||
};
|
||||
|
||||
@@ -739,19 +739,19 @@ fn decodeBase256Segment(
|
||||
fn decodeECISegment(bits: &mut BitSource, result: &mut ECIStringBuilder) -> Result<bool> {
|
||||
let firstByte = bits.readBits(8)?;
|
||||
if firstByte <= 127 {
|
||||
result.appendECI(firstByte - 1)?;
|
||||
result.appendECI(Eci::from(firstByte - 1))?;
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
let secondByte = bits.readBits(8)?;
|
||||
if firstByte <= 191 {
|
||||
result.appendECI((firstByte - 128) * 254 + 127 + secondByte - 1)?;
|
||||
result.appendECI(Eci::from((firstByte - 128) * 254 + 127 + secondByte - 1))?;
|
||||
return Ok((firstByte - 128) * 254 + 127 + secondByte - 1 > 900);
|
||||
}
|
||||
|
||||
let thirdByte = bits.readBits(8)?;
|
||||
|
||||
result.appendECI((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1)?;
|
||||
result.appendECI(Eci::from((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1))?;
|
||||
Ok((firstByte - 192) * 64516 + 16383 + (secondByte - 1) * 254 + thirdByte - 1 > 900)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::{fmt, rc::Rc};
|
||||
|
||||
use crate::{
|
||||
common::{CharacterSet, ECIInput, MinimalECIInput, Result},
|
||||
common::{CharacterSet, ECIInput, MinimalECIInput, Result, Eci},
|
||||
Exceptions,
|
||||
};
|
||||
|
||||
@@ -1441,7 +1441,7 @@ impl Input {
|
||||
fn isFNC1(&self, index: usize) -> Result<bool> {
|
||||
self.internal.isFNC1(index)
|
||||
}
|
||||
fn getECIValue(&self, index: usize) -> Result<i32> {
|
||||
fn getECIValue(&self, index: usize) -> Result<Eci> {
|
||||
self.internal.getECIValue(index)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user