mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
cargo clippy && fmt
This commit is contained in:
@@ -23,7 +23,8 @@ use crate::{
|
||||
encoder::HighLevelEncoder,
|
||||
shared_test_methods::{stripSpace, toBitArray, toBooleanArray},
|
||||
},
|
||||
BarcodeFormat, EncodeHintType, EncodeHintValue, Point, common::CharacterSetECI,
|
||||
common::CharacterSetECI,
|
||||
BarcodeFormat, EncodeHintType, EncodeHintValue, Point,
|
||||
};
|
||||
|
||||
use super::{encoder::aztec_encoder, AztecWriter};
|
||||
@@ -137,8 +138,8 @@ X X X X X X X X X X X X X
|
||||
#[test]
|
||||
fn testAztecWriter() {
|
||||
let shift_jis: CharacterSetECI =
|
||||
CharacterSetECI::getCharacterSetECIByName("Shift_JIS").expect("must exist");
|
||||
|
||||
CharacterSetECI::getCharacterSetECIByName("Shift_JIS").expect("must exist");
|
||||
|
||||
testWriter("Espa\u{00F1}ol", None, 25, true, 1); // Without ECI (implicit ISO-8859-1)
|
||||
testWriter("Espa\u{00F1}ol", Some(ISO_8859_1), 25, true, 1); // Explicit ISO-8859-1
|
||||
testWriter("\u{20AC} 1 sample data.", Some(WINDOWS_1252), 25, true, 2); // ISO-8859-1 can't encode Euro; Windows-1252 can
|
||||
@@ -817,7 +818,9 @@ fn testStuffBits(wordSize: usize, bits: &str, expected: &str) {
|
||||
|
||||
fn testHighLevelEncodeStringUtf8(s: &str, expectedBits: &str) {
|
||||
let bits = HighLevelEncoder::with_charset(
|
||||
CharacterSetECI::UTF8.encode(s).expect("should encode to bytes"),
|
||||
CharacterSetECI::UTF8
|
||||
.encode(s)
|
||||
.expect("should encode to bytes"),
|
||||
CharacterSetECI::UTF8,
|
||||
)
|
||||
.encode()
|
||||
@@ -838,7 +841,9 @@ fn testHighLevelEncodeStringUtf8(s: &str, expectedBits: &str) {
|
||||
|
||||
fn testHighLevelEncodeString(s: &str, expectedBits: &str) {
|
||||
let bits = HighLevelEncoder::new(
|
||||
CharacterSetECI::ISO8859_1.encode(s).expect("should encode to bytes"),
|
||||
CharacterSetECI::ISO8859_1
|
||||
.encode(s)
|
||||
.expect("should encode to bytes"),
|
||||
)
|
||||
.encode()
|
||||
.expect("high level ok");
|
||||
@@ -857,7 +862,9 @@ fn testHighLevelEncodeString(s: &str, expectedBits: &str) {
|
||||
|
||||
fn testHighLevelEncodeStringCount(s: &str, expectedReceivedBits: u32) {
|
||||
let bits = HighLevelEncoder::new(
|
||||
CharacterSetECI::ISO8859_1.encode(s).expect("should encode to bytes"),
|
||||
CharacterSetECI::ISO8859_1
|
||||
.encode(s)
|
||||
.expect("should encode to bytes"),
|
||||
)
|
||||
.encode()
|
||||
.expect("high level ok");
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result, CharacterSetECI},
|
||||
common::{BitMatrix, CharacterSetECI, Result},
|
||||
exceptions::Exceptions,
|
||||
BarcodeFormat, EncodeHintType, EncodeHintValue, Writer,
|
||||
};
|
||||
|
||||
@@ -113,7 +113,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String> {
|
||||
// Intermediary buffer of decoded bytes, which is decoded into a string and flushed
|
||||
// when character encoding changes (ECI) or input ends.
|
||||
let mut decoded_bytes: Vec<u8> = Vec::new();
|
||||
|
||||
|
||||
let mut encdr: CharacterSetECI = CharacterSetECI::ISO8859_1;
|
||||
|
||||
let mut index = 0;
|
||||
@@ -159,10 +159,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String> {
|
||||
let mut n = read_code(corrected_bits, index, 3);
|
||||
index += 3;
|
||||
// flush bytes, FLG changes state
|
||||
result.push_str(
|
||||
&encdr
|
||||
.decode(&decoded_bytes)?,
|
||||
);
|
||||
result.push_str(&encdr.decode(&decoded_bytes)?);
|
||||
|
||||
decoded_bytes.clear();
|
||||
match n {
|
||||
@@ -206,7 +203,7 @@ fn get_encoded_data(corrected_bits: &[bool]) -> Result<String> {
|
||||
}
|
||||
} else {
|
||||
// Though stored as a table of strings for convenience, codes actually represent 1 or 2 *bytes*.
|
||||
|
||||
|
||||
let b = str.as_bytes();
|
||||
//let b = str.getBytes(StandardCharsets.US_ASCII);
|
||||
//decodedBytes.write(b, 0, b.length);
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
reedsolomon::{
|
||||
get_predefined_genericgf, GenericGFRef, PredefinedGenericGF, ReedSolomonEncoder,
|
||||
},
|
||||
BitArray, BitMatrix, Result, CharacterSetECI,
|
||||
BitArray, BitMatrix, CharacterSetECI, Result,
|
||||
},
|
||||
exceptions::Exceptions,
|
||||
};
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, CharacterSetECI, Result},
|
||||
exceptions::Exceptions,
|
||||
};
|
||||
use crate::common::{BitArray, CharacterSetECI, Result};
|
||||
|
||||
use super::{State, Token};
|
||||
|
||||
@@ -243,10 +240,10 @@ impl HighLevelEncoder {
|
||||
pub fn encode(&self) -> Result<BitArray> {
|
||||
let mut initial_state = State::new(Token::new(), Self::MODE_UPPER as u32, 0, 0);
|
||||
//if let Some(eci) = CharacterSetECI::getCharacterSetECI(self.charset) {
|
||||
if self.charset != CharacterSetECI::ISO8859_1 {
|
||||
//} && eci != CharacterSetECI::Cp1252 {
|
||||
initial_state = initial_state.appendFLGn(self.charset.getValue())?;
|
||||
}
|
||||
if self.charset != CharacterSetECI::ISO8859_1 {
|
||||
//} && eci != CharacterSetECI::Cp1252 {
|
||||
initial_state = initial_state.appendFLGn(self.charset.getValue())?;
|
||||
}
|
||||
// } else {
|
||||
// return Err(Exceptions::illegal_argument_with(
|
||||
// "No ECI code for character set",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result, CharacterSetECI},
|
||||
common::{BitArray, CharacterSetECI, Result},
|
||||
exceptions::Exceptions,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user