mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
move to EncodingRef
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// import java.nio.charset.StandardCharsets;
|
||||
// import java.util.Random;
|
||||
|
||||
use encoding::Encoding;
|
||||
use encoding::{Encoding, EncodingRef};
|
||||
use rand::Rng;
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -102,7 +102,7 @@ fn test_utf16_le() {
|
||||
);
|
||||
}
|
||||
|
||||
fn do_test(bytes: &Vec<u8>, charset: &dyn Encoding, encoding: &str) {
|
||||
fn do_test(bytes: &Vec<u8>, charset: EncodingRef, encoding: &str) {
|
||||
let guessedCharset = StringUtils::guessCharset(bytes, &HashMap::new());
|
||||
let guessedEncoding = StringUtils::guessEncoding(bytes, &HashMap::new());
|
||||
assert_eq!(charset.name(), guessedCharset.name());
|
||||
|
||||
@@ -129,7 +129,7 @@ impl StringUtils {
|
||||
* or the platform default encoding if
|
||||
* none of these can possibly be correct
|
||||
*/
|
||||
pub fn guessCharset(bytes: &[u8], hints: &DecodingHintDictionary) -> &'static dyn Encoding {
|
||||
pub fn guessCharset(bytes: &[u8], hints: &DecodingHintDictionary) -> EncodingRef {
|
||||
match hints.get(&DecodeHintType::CHARACTER_SET) {
|
||||
Some(hint) => {
|
||||
if let DecodeHintValue::CharacterSet(cs_name) = hint {
|
||||
@@ -2565,7 +2565,7 @@ impl CharacterSetECI {
|
||||
* @return CharacterSetECI representing ECI for character encoding, or null if it is legal
|
||||
* but unsupported
|
||||
*/
|
||||
pub fn getCharacterSetECI(charset: &'static dyn Encoding) -> Option<CharacterSetECI> {
|
||||
pub fn getCharacterSetECI(charset: EncodingRef) -> Option<CharacterSetECI> {
|
||||
let name = if let Some(nm) = charset.whatwg_name() {
|
||||
nm
|
||||
} else {
|
||||
@@ -2712,7 +2712,7 @@ impl CharacterSetECI {
|
||||
pub struct ECIStringBuilder {
|
||||
current_bytes: Vec<u8>,
|
||||
result: String,
|
||||
current_charset: &'static dyn Encoding, //= StandardCharsets.ISO_8859_1;
|
||||
current_charset: EncodingRef, //= StandardCharsets.ISO_8859_1;
|
||||
}
|
||||
|
||||
impl ECIStringBuilder {
|
||||
|
||||
Reference in New Issue
Block a user