cargo fmt

This commit is contained in:
Henry Schimke
2023-01-29 16:07:49 -06:00
parent fb8d534f9e
commit 12007fdde0
2 changed files with 93 additions and 53 deletions

View File

@@ -107,7 +107,11 @@ impl ECIStringBuilder {
self.encodeCurrentBytesIfAny(); self.encodeCurrentBytesIfAny();
if let Ok(character_set_eci) = CharacterSetECI::getCharacterSetECIByValue(value) { if let Ok(character_set_eci) = CharacterSetECI::getCharacterSetECIByValue(value) {
dbg!(character_set_eci, CharacterSetECI::getCharset(&character_set_eci).name(), CharacterSetECI::getCharset(&character_set_eci).whatwg_name()); dbg!(
character_set_eci,
CharacterSetECI::getCharset(&character_set_eci).name(),
CharacterSetECI::getCharset(&character_set_eci).whatwg_name()
);
self.current_charset = Some(CharacterSetECI::getCharset(&character_set_eci)); self.current_charset = Some(CharacterSetECI::getCharset(&character_set_eci));
} else { } else {
self.current_charset = None self.current_charset = None
@@ -125,8 +129,9 @@ impl ECIStringBuilder {
// result = currentBytes; // result = currentBytes;
// currentBytes = new StringBuilder(); // currentBytes = new StringBuilder();
// } else { // } else {
self.result self.result.push_str(
.push_str(&String::from_utf8(std::mem::take(&mut self.current_bytes)).unwrap()); &String::from_utf8(std::mem::take(&mut self.current_bytes)).unwrap(),
);
self.current_bytes.clear(); self.current_bytes.clear();
// } // }
} }

View File

@@ -223,7 +223,7 @@ fn decodeAsciiSegment(
} }
result.append_char(char::from_u32(oneByte - 1).unwrap()); result.append_char(char::from_u32(oneByte - 1).unwrap());
return Ok(Mode::ASCII_ENCODE); return Ok(Mode::ASCII_ENCODE);
}, }
129 => return Ok(Mode::PAD_ENCODE), // Pad 129 => return Ok(Mode::PAD_ENCODE), // Pad
129..=229 => { 129..=229 => {
// 2-digit data 00-99 (Numeric Value + 130) // 2-digit data 00-99 (Numeric Value + 130)
@@ -234,57 +234,92 @@ fn decodeAsciiSegment(
} }
//result.append_char(char::from_u32(value).unwrap()); //result.append_char(char::from_u32(value).unwrap());
result.append_string(&format!("{value}")); result.append_string(&format!("{value}"));
}, }
230=> // Latch to C40 encodation 230 =>
return Ok(Mode::C40_ENCODE), // Latch to C40 encodation
231=> // Latch to Base 256 encodation
return Ok(Mode::BASE256_ENCODE),
232=> {// FNC1
if bits.getByteOffset() == firstFNC1Position
{/*result.symbology.modifier = '2';*/} // GS1
else if bits.getByteOffset() == firstFNC1Position + 1
{/*result.symbology.modifier = '3';*/} // AIM, note no AIM Application Indicator format defined, ISO 16022:2006 11.2
else
{fnc1positions.push(result.len());
result.append_char( 29 as char); }// translate as ASCII 29
},
233 => // Structured Append
{ {
if !firstCodeword // Must be first ISO 16022:2006 5.6.1 return Ok(Mode::C40_ENCODE)
{return Err(Exceptions::FormatException(Some("structured append tag must be first code word".to_owned())));} }
231 =>
// Latch to Base 256 encodation
{
return Ok(Mode::BASE256_ENCODE)
}
232 => {
// FNC1
if bits.getByteOffset() == firstFNC1Position { /*result.symbology.modifier = '2';*/
}
// GS1
else if bits.getByteOffset() == firstFNC1Position + 1 { /*result.symbology.modifier = '3';*/
}
// AIM, note no AIM Application Indicator format defined, ISO 16022:2006 11.2
else {
fnc1positions.push(result.len());
result.append_char(29 as char);
} // translate as ASCII 29
}
233 =>
// Structured Append
{
if !firstCodeword
// Must be first ISO 16022:2006 5.6.1
{
return Err(Exceptions::FormatException(Some(
"structured append tag must be first code word".to_owned(),
)));
}
parse_structured_append(bits, &mut sai)?; parse_structured_append(bits, &mut sai)?;
firstFNC1Position = 5; firstFNC1Position = 5;
}, }
234=> // Reader Programming 234 =>
// Reader Programming
// Ignore these symbols for now // Ignore these symbols for now
//throw ReaderException.getInstance(); //throw ReaderException.getInstance();
{}, {}
235=> // Upper Shift (shift to Extended ASCII) 235 =>
upperShift = true, // Upper Shift (shift to Extended ASCII)
236=> {// 05 Macro {
upperShift = true
}
236 => {
// 05 Macro
result.append_string(VALUE_236); result.append_string(VALUE_236);
resultTrailer.replace_range(0..0, INSERT_STRING_CONST); resultTrailer.replace_range(0..0, INSERT_STRING_CONST);
// resultTrailer.insert(0, "\u{001E}\u{0004}"); // resultTrailer.insert(0, "\u{001E}\u{0004}");
}, }
237=>{ // 06 Macro 237 => {
// 06 Macro
result.append_string(VALUE_237); result.append_string(VALUE_237);
resultTrailer.replace_range(0..0, INSERT_STRING_CONST); resultTrailer.replace_range(0..0, INSERT_STRING_CONST);
// resultTrailer.insert(0, "\u{001E}\u{0004}"); // resultTrailer.insert(0, "\u{001E}\u{0004}");
}, }
238=> // Latch to ANSI X12 encodation 238 =>
return Ok(Mode::ANSIX12_ENCODE), // Latch to ANSI X12 encodation
239=> // Latch to Text encodation {
return Ok(Mode::TEXT_ENCODE), return Ok(Mode::ANSIX12_ENCODE)
240=> // Latch to EDIFACT encodation }
return Ok(Mode::EDIFACT_ENCODE), 239 =>
241=> // ECI Character // Latch to Text encodation
return Ok(Mode::ECI_ENCODE), {
return Ok(Mode::TEXT_ENCODE)
}
240 =>
// Latch to EDIFACT encodation
{
return Ok(Mode::EDIFACT_ENCODE)
}
241 =>
// ECI Character
{
return Ok(Mode::ECI_ENCODE)
}
_ => { _ => {
// Not to be used in ASCII encodation // Not to be used in ASCII encodation
// but work around encoders that end with 254, latch back to ASCII // but work around encoders that end with 254, latch back to ASCII
if oneByte != 254 || bits.available() != 0 { if oneByte != 254 || bits.available() != 0 {
return Err(Exceptions::FormatException(None)) return Err(Exceptions::FormatException(None));
}}, }
}
} }
if bits.available() == 0 { if bits.available() == 0 {