mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
repurpose CharacterSetECI as encoding abstraction
This commit is contained in:
@@ -16,16 +16,14 @@
|
||||
|
||||
use std::{fmt, rc::Rc};
|
||||
|
||||
use encoding::{self, EncodingRef};
|
||||
|
||||
use crate::{
|
||||
common::{ECIInput, MinimalECIInput, Result},
|
||||
common::{ECIInput, MinimalECIInput, Result, CharacterSetECI},
|
||||
Exceptions,
|
||||
};
|
||||
|
||||
use super::{high_level_encoder, SymbolShapeHint};
|
||||
|
||||
const ISO_8859_1_ENCODER: EncodingRef = encoding::all::ISO_8859_1;
|
||||
const ISO_8859_1_ENCODER: CharacterSetECI = CharacterSetECI::ISO8859_1;
|
||||
|
||||
/**
|
||||
* Encoder that encodes minimally
|
||||
@@ -153,7 +151,7 @@ pub fn encodeHighLevel(msg: &str) -> Result<String> {
|
||||
*/
|
||||
pub fn encodeHighLevelWithDetails(
|
||||
msg: &str,
|
||||
priorityCharset: Option<EncodingRef>,
|
||||
priorityCharset: Option<CharacterSetECI>,
|
||||
fnc1: Option<char>,
|
||||
shape: SymbolShapeHint,
|
||||
) -> Result<String> {
|
||||
@@ -174,8 +172,8 @@ pub fn encodeHighLevelWithDetails(
|
||||
}
|
||||
Ok(ISO_8859_1_ENCODER
|
||||
.decode(
|
||||
&encode(msg, priorityCharset, fnc1, shape, macroId)?,
|
||||
encoding::DecoderTrap::Strict,
|
||||
&encode(msg, priorityCharset, fnc1, shape, macroId)?
|
||||
|
||||
)
|
||||
.expect("should decode"))
|
||||
// return new String(encode(msg, priorityCharset, fnc1, shape, macroId), StandardCharsets.ISO_8859_1);
|
||||
@@ -197,7 +195,7 @@ pub fn encodeHighLevelWithDetails(
|
||||
*/
|
||||
fn encode(
|
||||
input: &str,
|
||||
priorityCharset: Option<EncodingRef>,
|
||||
priorityCharset: Option<CharacterSetECI>,
|
||||
fnc1: Option<char>,
|
||||
shape: SymbolShapeHint,
|
||||
macroId: i32,
|
||||
@@ -1398,7 +1396,7 @@ struct Input {
|
||||
impl Input {
|
||||
pub fn new(
|
||||
stringToEncode: &str,
|
||||
priorityCharset: Option<EncodingRef>,
|
||||
priorityCharset: Option<CharacterSetECI>,
|
||||
fnc1: Option<char>,
|
||||
shape: SymbolShapeHint,
|
||||
macroId: i32,
|
||||
|
||||
Reference in New Issue
Block a user