From c5ed27bb12f6aa3e162827ebaad1e88ecb15abd8 Mon Sep 17 00:00:00 2001 From: Maurus Decimus Date: Sun, 3 Oct 2021 16:45:16 +0000 Subject: [PATCH] First commit --- .gitignore | 2 + Cargo.lock | 7 + Cargo.toml | 8 + src/decoders/base64.rs | 329 +++++++ src/decoders/charsets/mod.rs | 1282 ++++++++++++++++++++++++++ src/decoders/charsets/single_byte.rs | 491 ++++++++++ src/decoders/mod.rs | 14 + src/decoders/quoted_printable.rs | 182 ++++ src/main.rs | 223 +++++ src/parsers/address.rs | 15 + src/parsers/header.rs | 144 +++ src/parsers/message_stream.rs | 92 ++ src/parsers/mod.rs | 5 + src/parsers/rfc2047.rs | 118 +++ 14 files changed, 2912 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/decoders/base64.rs create mode 100644 src/decoders/charsets/mod.rs create mode 100644 src/decoders/charsets/single_byte.rs create mode 100644 src/decoders/mod.rs create mode 100644 src/decoders/quoted_printable.rs create mode 100644 src/main.rs create mode 100644 src/parsers/address.rs create mode 100644 src/parsers/header.rs create mode 100644 src/parsers/message_stream.rs create mode 100644 src/parsers/mod.rs create mode 100644 src/parsers/rfc2047.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..94067ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/test diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..2533815 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "stalwart" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..cdbdf4d --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "stalwart" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/decoders/base64.rs b/src/decoders/base64.rs new file mode 100644 index 0000000..833c1ce --- /dev/null +++ b/src/decoders/base64.rs @@ -0,0 +1,329 @@ +use super::{Decoder, DecoderResult}; + +pub struct Base64Decoder { + chunk: Base64Chunk, + count: u8, +} + +#[repr(C)] +union Base64Chunk { + val: u32, + bytes: [u8; std::mem::size_of::()], +} + +impl Base64Decoder { + pub fn new() -> Base64Decoder { + Base64Decoder { + chunk: Base64Chunk { val: 0 }, + count: 0, + } + } +} + +impl Decoder for Base64Decoder { + fn ingest(&mut self, ch: u8) -> DecoderResult { + if ch != b'=' { + let val = unsafe { + BASE64_MAP + .get_unchecked(self.count as usize) + .get_unchecked(ch as usize) + }; + if *val >= 0x01ffffff { + return DecoderResult::Error; + } + + self.count = (self.count + 1) & 3; + + if self.count == 1 { + self.chunk.val = *val; + } else { + self.chunk.val = unsafe { self.chunk.val } | *val; + + if self.count == 0 { + return DecoderResult::ByteArray(unsafe { + &self.chunk.bytes.get_unchecked(0..3) + }); + } + } + } else { + match self.count { + 1 | 2 => { + self.count = 0; + return DecoderResult::Byte(unsafe { *self.chunk.bytes.get_unchecked(0) }); + } + 3 => { + self.count = 0; + return DecoderResult::ByteArray(unsafe { + &self.chunk.bytes.get_unchecked(0..2) + }); + } + 0 => (), + _ => { + return DecoderResult::Error; + } + } + } + + DecoderResult::NeedData + } +} + +#[cfg(test)] +mod tests { + use super::Base64Decoder; + use crate::decoders::{Decoder, DecoderResult}; + + #[test] + fn decode_success() { + let inputs = [ + ("VGVzdA==".as_bytes(), "Test".as_bytes()), + ("WWU=".as_bytes(), "Ye".as_bytes()), + ("QQ==".as_bytes(), "A".as_bytes()), + ("cm8=".as_bytes(), "ro".as_bytes()), + ( + "QXJlIHlvdSBhIFNoaW1hbm8gb3IgQ2FtcGFnbm9sbyBwZXJzb24/".as_bytes(), + "Are you a Shimano or Campagnolo person?".as_bytes(), + ), + ( + "PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8Ym9keT4KPC9ib2R5Pgo8L2h0bWw+Cg==".as_bytes(), + "\n\n\n\n\n".as_bytes(), + ), + ("w6HDqcOtw7PDug==".as_bytes(), "áéíóú".as_bytes()), + ]; + + for input in inputs { + let mut decoder = Base64Decoder::new(); + let mut output = Vec::new(); + + for ch in input.0 { + match decoder.ingest(*ch) { + DecoderResult::Byte(v) => { + output.push(v); + } + DecoderResult::ByteArray(v) => { + output.extend_from_slice(v); + } + DecoderResult::NeedData => (), + DecoderResult::Error => { + panic!( + "Failed to decode Base64: {}", + std::str::from_utf8(&input.0).unwrap() + ); + } + } + } + //println!("'{}'", std::str::from_utf8(&output).unwrap()); + assert_eq!(output, input.1); + } + } + + #[test] + fn decode_invalid() { + let inputs = [ + "====".as_bytes(), + "w6HDq!cOtw7PDug=".as_bytes(), + "w6 HD".as_bytes(), + "cmáé".as_bytes(), + "áé".as_bytes(), + ]; + + for input in inputs { + let mut decoder = Base64Decoder::new(); + let mut failed = false; + let mut is_empty = true; + + for ch in input { + match decoder.ingest(*ch) { + DecoderResult::Byte(_) => { + is_empty = false; + } + DecoderResult::ByteArray(_) => { + is_empty = false; + } + DecoderResult::NeedData => (), + DecoderResult::Error => { + failed = true; + break; + } + } + } + + assert!( + failed || is_empty, + "Test failed on '{}'", + std::str::from_utf8(input).unwrap() + ); + } + } +} + +/* + * Table adapted from Nick Galbreath's "High performance base64 encoder / decoder" + * + * Copyright 2005, 2006, 2007 Nick Galbreath -- nickg [at] modp [dot] com + * All rights reserved. + * + * http://code.google.com/p/stringencoders/ + * + * Released under bsd license. + * + */ + +static BASE64_MAP: &'static [&[u32]] = &[ + &[ + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x000000f8, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x000000fc, 0x000000d0, + 0x000000d4, 0x000000d8, 0x000000dc, 0x000000e0, 0x000000e4, 0x000000e8, 0x000000ec, + 0x000000f0, 0x000000f4, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x00000000, 0x00000004, 0x00000008, 0x0000000c, 0x00000010, + 0x00000014, 0x00000018, 0x0000001c, 0x00000020, 0x00000024, 0x00000028, 0x0000002c, + 0x00000030, 0x00000034, 0x00000038, 0x0000003c, 0x00000040, 0x00000044, 0x00000048, + 0x0000004c, 0x00000050, 0x00000054, 0x00000058, 0x0000005c, 0x00000060, 0x00000064, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x00000068, + 0x0000006c, 0x00000070, 0x00000074, 0x00000078, 0x0000007c, 0x00000080, 0x00000084, + 0x00000088, 0x0000008c, 0x00000090, 0x00000094, 0x00000098, 0x0000009c, 0x000000a0, + 0x000000a4, 0x000000a8, 0x000000ac, 0x000000b0, 0x000000b4, 0x000000b8, 0x000000bc, + 0x000000c0, 0x000000c4, 0x000000c8, 0x000000cc, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + ], + &[ + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x0000e003, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x0000f003, 0x00004003, + 0x00005003, 0x00006003, 0x00007003, 0x00008003, 0x00009003, 0x0000a003, 0x0000b003, + 0x0000c003, 0x0000d003, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x00000000, 0x00001000, 0x00002000, 0x00003000, 0x00004000, + 0x00005000, 0x00006000, 0x00007000, 0x00008000, 0x00009000, 0x0000a000, 0x0000b000, + 0x0000c000, 0x0000d000, 0x0000e000, 0x0000f000, 0x00000001, 0x00001001, 0x00002001, + 0x00003001, 0x00004001, 0x00005001, 0x00006001, 0x00007001, 0x00008001, 0x00009001, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x0000a001, + 0x0000b001, 0x0000c001, 0x0000d001, 0x0000e001, 0x0000f001, 0x00000002, 0x00001002, + 0x00002002, 0x00003002, 0x00004002, 0x00005002, 0x00006002, 0x00007002, 0x00008002, + 0x00009002, 0x0000a002, 0x0000b002, 0x0000c002, 0x0000d002, 0x0000e002, 0x0000f002, + 0x00000003, 0x00001003, 0x00002003, 0x00003003, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + ], + &[ + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x00800f00, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x00c00f00, 0x00000d00, + 0x00400d00, 0x00800d00, 0x00c00d00, 0x00000e00, 0x00400e00, 0x00800e00, 0x00c00e00, + 0x00000f00, 0x00400f00, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x00000000, 0x00400000, 0x00800000, 0x00c00000, 0x00000100, + 0x00400100, 0x00800100, 0x00c00100, 0x00000200, 0x00400200, 0x00800200, 0x00c00200, + 0x00000300, 0x00400300, 0x00800300, 0x00c00300, 0x00000400, 0x00400400, 0x00800400, + 0x00c00400, 0x00000500, 0x00400500, 0x00800500, 0x00c00500, 0x00000600, 0x00400600, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x00800600, + 0x00c00600, 0x00000700, 0x00400700, 0x00800700, 0x00c00700, 0x00000800, 0x00400800, + 0x00800800, 0x00c00800, 0x00000900, 0x00400900, 0x00800900, 0x00c00900, 0x00000a00, + 0x00400a00, 0x00800a00, 0x00c00a00, 0x00000b00, 0x00400b00, 0x00800b00, 0x00c00b00, + 0x00000c00, 0x00400c00, 0x00800c00, 0x00c00c00, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + ], + &[ + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x003e0000, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x003f0000, 0x00340000, + 0x00350000, 0x00360000, 0x00370000, 0x00380000, 0x00390000, 0x003a0000, 0x003b0000, + 0x003c0000, 0x003d0000, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x00000000, 0x00010000, 0x00020000, 0x00030000, 0x00040000, + 0x00050000, 0x00060000, 0x00070000, 0x00080000, 0x00090000, 0x000a0000, 0x000b0000, + 0x000c0000, 0x000d0000, 0x000e0000, 0x000f0000, 0x00100000, 0x00110000, 0x00120000, + 0x00130000, 0x00140000, 0x00150000, 0x00160000, 0x00170000, 0x00180000, 0x00190000, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x001a0000, + 0x001b0000, 0x001c0000, 0x001d0000, 0x001e0000, 0x001f0000, 0x00200000, 0x00210000, + 0x00220000, 0x00230000, 0x00240000, 0x00250000, 0x00260000, 0x00270000, 0x00280000, + 0x00290000, 0x002a0000, 0x002b0000, 0x002c0000, 0x002d0000, 0x002e0000, 0x002f0000, + 0x00300000, 0x00310000, 0x00320000, 0x00330000, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + 0x01ffffff, 0x01ffffff, 0x01ffffff, 0x01ffffff, + ], +]; diff --git a/src/decoders/charsets/mod.rs b/src/decoders/charsets/mod.rs new file mode 100644 index 0000000..f3ae4c5 --- /dev/null +++ b/src/decoders/charsets/mod.rs @@ -0,0 +1,1282 @@ +use self::single_byte::SingleByteDecoder; + +pub mod single_byte; +pub trait CharsetDecoder { + fn ingest(&mut self, ch: u8) -> (); + fn ingest_slice(&mut self, chs: &[u8]) -> () { + for ch in chs { + self.ingest(*ch); + } + } + fn to_string(&self) -> Option<&str>; +} + +fn get_decoder(charset: &[u8], capacity: usize) -> Option> { + let len = charset.len(); + + if len < 2 || len > 45 { + return None; + } + + let mut hash: u32 = len as u32 + + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(0) as usize) } + + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(1) as usize + 1) } + + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(len - 1) as usize) }; + + if len >= 22 { + hash = + hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(21) as usize) }; + } + if len >= 11 { + hash = hash + + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(10) as usize + 1) }; + } + if len >= 10 { + hash = hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(9) as usize) }; + } + if len >= 9 { + hash = hash + + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(8) as usize + 1) }; + } + if len >= 8 { + hash = hash + + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(7) as usize + 3) }; + } + if len >= 7 { + hash = hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(6) as usize) }; + } + if len >= 6 { + hash = hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(5) as usize) }; + } + if len >= 5 { + hash = hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(4) as usize) }; + } + if len >= 4 { + hash = hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(3) as usize) }; + } + if len >= 3 { + hash = hash + unsafe { charset_hash.get_unchecked(*charset.get_unchecked(2) as usize) }; + } + + if hash < 30 || hash > 5355 { + return None; + } + + match hash - 30 { + // US-ASCII + 1788 if charset == b"us-ascii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 503 if charset == b"iso-ir-6" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 2695 if charset == b"ansi_x3.4-1968" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 2770 if charset == b"ansi_x3.4-1986" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 1916 if charset == b"iso_646.irv:1991" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 1095 if charset == b"iso646-us" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 442 if charset == b"us" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 986 if charset == b"ibm367" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 1210 if charset == b"cp367" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 762 if charset == b"csascii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + + // ISO_8859-1:1987 + 1399 if charset == b"iso-8859-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 3227 if charset == b"iso_8859-1:1987" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 140 if charset == b"iso-ir-100" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 2114 if charset == b"iso_8859-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 1596 if charset == b"latin1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 622 if charset == b"l1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 841 if charset == b"ibm819" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 1065 if charset == b"cp819" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + 2891 if charset == b"csisolatin1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_1, capacity))), + + // ISO_8859-2:1987 + 1389 if charset == b"iso-8859-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3222 if charset == b"iso_8859-2:1987" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 40 if charset == b"iso-ir-101" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2104 if charset == b"iso_8859-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1586 if charset == b"latin2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1052 if charset == b"l2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3321 if charset == b"csisolatin2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + + // ISO_8859-3:1988 + 2259 if charset == b"iso-8859-3" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + 3537 if charset == b"iso_8859-3:1988" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + 770 if charset == b"iso-ir-109" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + 2974 if charset == b"iso_8859-3" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + 2456 if charset == b"latin3" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + 1087 if charset == b"l3" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + 3356 if charset == b"csisolatin3" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_3, capacity))), + + // ISO_8859-4:1988 + 1459 if charset == b"iso-8859-4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + 3137 if charset == b"iso_8859-4:1988" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + 135 if charset == b"iso-ir-110" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + 2174 if charset == b"iso_8859-4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + 1656 if charset == b"latin4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + 672 if charset == b"l4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + 2941 if charset == b"csisolatin4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_4, capacity))), + + // ISO_8859-5:1988 + 1429 if charset == b"iso-8859-5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_5, capacity))), + 3122 if charset == b"iso_8859-5:1988" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_5, capacity))), + 115 if charset == b"iso-ir-144" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_5, capacity))), + 2144 if charset == b"iso_8859-5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_5, capacity))), + 1483 if charset == b"cyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_5, capacity))), + 3228 if charset == b"csisolatincyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_5, capacity))), + + // ISO_8859-6:1987 + 1679 if charset == b"iso-8859-6" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 3367 if charset == b"iso_8859-6:1987" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 840 if charset == b"iso-ir-127" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 2394 if charset == b"iso_8859-6" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 1448 if charset == b"ecma-114" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 1926 if charset == b"asmo-708" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 1766 if charset == b"arabic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + 3241 if charset == b"csisolatinarabic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_6, capacity))), + + // ISO_8859-7:1987 + 1769 if charset == b"iso-8859-7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 3412 if charset == b"iso_8859-7:1987" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 750 if charset == b"iso-ir-126" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 2484 if charset == b"iso_8859-7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 2291 if charset == b"elot_928" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 2216 if charset == b"ecma-118" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 2952 if charset == b"greek" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 2177 if charset == b"greek8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + 4612 if charset == b"csisolatingreek" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_7, capacity))), + + // ISO_8859-8:1988 + 1529 if charset == b"iso-8859-8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_8, capacity))), + 3172 if charset == b"iso_8859-8:1988" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_8, capacity))), + 200 if charset == b"iso-ir-138" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_8, capacity))), + 2244 if charset == b"iso_8859-8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_8, capacity))), + 1692 if charset == b"hebrew" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_8, capacity))), + 3066 if charset == b"csisolatinhebrew" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_8, capacity))), + + // ISO_8859-9:1989 + 2129 if charset == b"iso-8859-9" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + 3772 if charset == b"iso_8859-9:1989" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + 185 if charset == b"iso-ir-148" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + 2844 if charset == b"iso_8859-9" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + 1626 if charset == b"latin5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + 782 if charset == b"l5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + 3051 if charset == b"csisolatin5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_9, capacity))), + + // ISO-8859-10 + 1455 if charset == b"iso-8859-10" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_10, capacity))), + 550 if charset == b"iso-ir-157" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_10, capacity))), + 952 if charset == b"l6" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_10, capacity))), + 2120 if charset == b"iso_8859-10:1992" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_10, capacity))), + 3221 if charset == b"csisolatin6" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_10, capacity))), + 1876 if charset == b"latin6" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_10, capacity))), + + // ISO-8859-13 + 1865 if charset == b"iso-8859-13" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_13, capacity))), + 844 if charset == b"csiso885913" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_13, capacity))), + + // ISO-8859-14 + 1450 if charset == b"iso-8859-14" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 853 if charset == b"iso-ir-199" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 2205 if charset == b"iso_8859-14:1998" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 2165 if charset == b"iso_8859-14" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 1726 if charset == b"latin8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 1735 if charset == b"iso-celtic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 1057 if charset == b"l8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + 429 if charset == b"csiso885914" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_14, capacity))), + + // ISO-8859-15 + 1560 if charset == b"iso-8859-15" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_15, capacity))), + 2275 if charset == b"iso_8859-15" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_15, capacity))), + 2327 if charset == b"latin-9" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_15, capacity))), + 539 if charset == b"csiso885915" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_15, capacity))), + + // ISO-8859-16 + 1730 if charset == b"iso-8859-16" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + 735 if charset == b"iso-ir-226" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + 2310 if charset == b"iso_8859-16:2001" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + 2445 if charset == b"iso_8859-16" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + 1702 if charset == b"latin10" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + 728 if charset == b"l10" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + 709 if charset == b"csiso885916" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_16, capacity))), + + _ => None + + } +} + +static charset_hash: &'static [u32] = &[ + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 0, 5356, 5356, 5356, 0, 1184, 20, 55, 5, + 0, 435, 35, 20, 145, 190, 70, 370, 88, 923, 60, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 715, 0, 675, 340, 10, 325, 200, 30, + 670, 806, 5, 705, 916, 645, 35, 620, 0, 65, 265, 0, 75, 0, 395, 930, 170, 711, 0, 155, 0, 0, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, 5356, + 5356, 5356, 5356, 5356, 5356, 5356 +]; + +#[cfg(test)] +mod tests { + use super::{get_decoder}; + + #[test] + fn decode() { + let inputs = [ + ("iso-8859-1".as_bytes(), b"\xe1\xe9\xed\xf3\xfa".to_vec(), "áéíóú"), + ("iso-8859-5".as_bytes(), b"\xbf\xe0\xd8\xd2\xd5\xe2, \xdc\xd8\xe0".to_vec(), "Привет, мир"), + ("iso-8859-6".as_bytes(), b"\xe5\xd1\xcd\xc8\xc7 \xc8\xc7\xe4\xd9\xc7\xe4\xe5".to_vec(),"مرحبا بالعالم"), + ("iso-8859-7".as_bytes(), b"\xc3\xe5\xe9\xdc \xf3\xef\xf5 \xca\xfc\xf3\xec\xe5".to_vec(),"Γειά σου Κόσμε"), + ("iso-8859-8".as_bytes(), b"\xf9\xec\xe5\xed \xf2\xe5\xec\xed".to_vec(),"שלום עולם"), + //("iso-8859-6".as_bytes(), b"".to_vec(),""), + //("iso-8859-6".as_bytes(), b"".to_vec(),""), + //("iso-8859-6".as_bytes(), b"".to_vec(),""), + ]; + + for input in inputs { + let mut decoder = get_decoder(input.0, 50).unwrap(); + decoder.ingest_slice(&input.1); + let result = decoder.to_string().unwrap(); + println!("{}", result); + assert_eq!(result, input.2); + } + } +} + +/* + + Keep for future use. + + // ISO_6937-2-ADD + 4435 if charset == b"iso_6937-2-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 45 if charset == b"iso-ir-142" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 778 if charset == b"csisotextcomm" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_X0201 + 3385 if charset == b"jis_x0201" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 756 if charset == b"x0201" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3850 if charset == b"cshalfwidthkatakana" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_ENCODING + 3887 if charset == b"jis_encoding" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3393 if charset == b"csjisencoding" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // SHIFT_JIS + 2234 if charset == b"shift_jis" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4294 if charset == b"ms_kanji" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1796 if charset == b"csshiftjis" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE + 1951 if charset == b"euc-jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2835 if charset == b"extended_unix_code_packed_format_for_japanese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3555 if charset == b"cseucpkdfmtjapanese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EXTENDED_UNIX_CODE_FIXED_WIDTH_FOR_JAPANESE + 3534 if charset == b"extended_unix_code_fixed_width_for_japanese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1755 if charset == b"cseucfixwidjapanese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // BS_4730 + 1802 if charset == b"bs_4730" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 213 if charset == b"iso-ir-4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1364 if charset == b"iso646-gb" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 992 if charset == b"gb" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1928 if charset == b"uk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1544 if charset == b"csiso4unitedkingdom" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // SEN_850200_C + 1657 if charset == b"sen_850200_c" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 29 if charset == b"iso-ir-11" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1270 if charset == b"iso646-se2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 78 if charset == b"se2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2283 if charset == b"csiso11swedishfornames" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IT + 372 if charset == b"it" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 189 if charset == b"iso-ir-15" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1349 if charset == b"iso646-it" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2469 if charset == b"csiso15italian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ES + 247 if charset == b"es" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 284 if charset == b"iso-ir-17" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1190 if charset == b"iso646-es" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2945 if charset == b"csiso17spanish" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // DIN_66003 + 3594 if charset == b"din_66003" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 14 if charset == b"iso-ir-21" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 527 if charset == b"de" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1209 if charset == b"iso646-de" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2053 if charset == b"csiso21german" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NS_4551-1 + 1454 if charset == b"ns_4551-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 419 if charset == b"iso-ir-60" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 639 if charset == b"iso646-no" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 657 if charset == b"no" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3857 if charset == b"csiso60danishnorwegian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1323 if charset == b"csiso60norwegian1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NF_Z_62-010 + 3126 if charset == b"nf_z_62-010" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 817 if charset == b"iso-ir-69" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 389 if charset == b"iso646-fr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 77 if charset == b"fr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1674 if charset == b"csiso69french" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-10646-UTF-1 + 1510 if charset == b"iso-10646-utf-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1604 if charset == b"csiso10646utf1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_646.BASIC:1983 + 2158 if charset == b"iso_646.basic:1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 63 if charset == b"ref" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1747 if charset == b"csiso646basic1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // INVARIANT + 2929 if charset == b"invariant" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4221 if charset == b"csinvariant" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_646.IRV:1983 + 2346 if charset == b"iso_646.irv:1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 8 if charset == b"iso-ir-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1913 if charset == b"irv" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2085 if charset == b"csiso2intlrefversion" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NATS-SEFI + 2004 if charset == b"nats-sefi" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2107 if charset == b"iso-ir-8-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2921 if charset == b"csnatssefi" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NATS-SEFI-ADD + 2668 if charset == b"nats-sefi-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2097 if charset == b"iso-ir-8-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3584 if charset == b"csnatssefiadd" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NATS-DANO + 2344 if charset == b"nats-dano" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1244 if charset == b"iso-ir-9-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2010 if charset == b"csnatsdano" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NATS-DANO-ADD + 3013 if charset == b"nats-dano-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1234 if charset == b"iso-ir-9-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2678 if charset == b"csnatsdanoadd" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // SEN_850200_B + 1987 if charset == b"sen_850200_b" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 84 if charset == b"iso-ir-10" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 712 if charset == b"fi" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1024 if charset == b"iso646-fi" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1469 if charset == b"iso646-se" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 277 if charset == b"se" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2981 if charset == b"csiso10swedish" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // KS_C_5601-1987 + 3130 if charset == b"ks_c_5601-1987" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 785 if charset == b"iso-ir-149" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3310 if charset == b"ks_c_5601-1989" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1879 if charset == b"ksc_5601" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3072 if charset == b"korean" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1877 if charset == b"csksc56011987" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-2022-KR + 2236 if charset == b"iso-2022-kr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1572 if charset == b"csiso2022kr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EUC-KR + 2032 if charset == b"euc-kr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1508 if charset == b"cseuckr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-2022-JP + 2280 if charset == b"iso-2022-jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1616 if charset == b"csiso2022jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-2022-JP-2 + 2217 if charset == b"iso-2022-jp-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1552 if charset == b"csiso2022jp2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6220-1969-JP + 2432 if charset == b"jis_c6220-1969-jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2734 if charset == b"jis_c6220-1969" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 494 if charset == b"iso-ir-13" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 5120 if charset == b"katakana" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1133 if charset == b"x0201-7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1722 if charset == b"csiso13jisc6220jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6220-1969-RO + 2367 if charset == b"jis_c6220-1969-ro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 79 if charset == b"iso-ir-14" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1007 if charset == b"jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 674 if charset == b"iso646-jp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1257 if charset == b"csiso14jisc6220ro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // PT + 432 if charset == b"pt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 359 if charset == b"iso-ir-16" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 779 if charset == b"iso646-pt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 962 if charset == b"csiso16portuguese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GREEK7-OLD + 2916 if charset == b"greek7-old" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 464 if charset == b"iso-ir-18" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1486 if charset == b"csiso18greek7old" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // LATIN-GREEK + 4447 if charset == b"latin-greek" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 482 if charset == b"iso-ir-19" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2413 if charset == b"csiso19latingreek" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NF_Z_62-010_(1973) + 3078 if charset == b"nf_z_62-010_(1973)" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 174 if charset == b"iso-ir-25" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 400 if charset == b"iso646-fr1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1179 if charset == b"csiso25french" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // LATIN-GREEK-1 + 3538 if charset == b"latin-greek-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 269 if charset == b"iso-ir-27" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1318 if charset == b"csiso27latingreek1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_5427 + 1031 if charset == b"iso_5427" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 394 if charset == b"iso-ir-37" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 397 if charset == b"csiso5427cyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6226-1978 + 2619 if charset == b"jis_c6226-1978" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 614 if charset == b"iso-ir-42" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1324 if charset == b"csiso42jisc62261978" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // BS_VIEWDATA + 4366 if charset == b"bs_viewdata" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 439 if charset == b"iso-ir-47" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2812 if charset == b"csiso47bsviewdata" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // INIS + 134 if charset == b"inis" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 637 if charset == b"iso-ir-49" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1201 if charset == b"csiso49inis" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // INIS-8 + 201 if charset == b"inis-8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 119 if charset == b"iso-ir-50" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 867 if charset == b"csiso50inis8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // INIS-CYRILLIC + 1868 if charset == b"inis-cyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 64 if charset == b"iso-ir-51" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 764 if charset == b"csiso51iniscyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_5427:1981 + 1867 if charset == b"iso_5427:1981" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 114 if charset == b"iso-ir-54" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1134 if charset == b"iso5427cyrillic1981" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 316 if charset == b"csiso54271981" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_5428:1980 + 2752 if charset == b"iso_5428:1980" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 224 if charset == b"iso-ir-55" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2180 if charset == b"csiso5428greek" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GB_1988-80 + 2425 if charset == b"gb_1988-80" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 319 if charset == b"iso-ir-57" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 602 if charset == b"cn" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 959 if charset == b"iso646-cn" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1161 if charset == b"csiso57gb1988" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GB_2312-80 + 2350 if charset == b"gb_2312-80" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 499 if charset == b"iso-ir-58" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1292 if charset == b"chinese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 970 if charset == b"csiso58gb231280" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NS_4551-2 + 1884 if charset == b"ns_4551-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 640 if charset == b"iso646-no2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 364 if charset == b"iso-ir-61" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 658 if charset == b"no2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1268 if charset == b"csiso61norwegian2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // VIDEOTEX-SUPPL + 5178 if charset == b"videotex-suppl" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 137 if charset == b"iso-ir-70" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1390 if charset == b"csiso70videotexsupp1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // PT2 + 433 if charset == b"pt2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 967 if charset == b"iso-ir-84" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 780 if charset == b"iso646-pt2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 718 if charset == b"csiso84portuguese2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ES2 + 173 if charset == b"es2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1077 if charset == b"iso-ir-85" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1116 if charset == b"iso646-es2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2035 if charset == b"csiso85spanish2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // MSZ_7795.3 + 2595 if charset == b"msz_7795.3" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1247 if charset == b"iso-ir-86" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2550 if charset == b"iso646-hu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2103 if charset == b"hu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4183 if charset == b"csiso86hungarian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6226-1983 + 2984 if charset == b"jis_c6226-1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1172 if charset == b"iso-ir-87" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 886 if charset == b"x0208" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4190 if charset == b"jis_x0208-1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1220 if charset == b"csiso87jisx0208" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GREEK7 + 2417 if charset == b"greek7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1352 if charset == b"iso-ir-88" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1413 if charset == b"csiso88greek7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ASMO_449 + 1903 if charset == b"asmo_449" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2073 if charset == b"iso_9036" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2137 if charset == b"arabic7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1370 if charset == b"iso-ir-89" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1309 if charset == b"csiso89asmo449" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-IR-90 + 109 if charset == b"iso-ir-90" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 547 if charset == b"csiso90" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6229-1984-A + 3124 if charset == b"jis_c6229-1984-a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 54 if charset == b"iso-ir-91" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1958 if charset == b"jp-ocr-a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2270 if charset == b"csiso91jisc62291984a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6229-1984-B + 2789 if charset == b"jis_c6229-1984-b" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 484 if charset == b"iso-ir-92" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1020 if charset == b"iso646-jp-ocr-b" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1498 if charset == b"jp-ocr-b" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1930 if charset == b"csiso92jisc62991984b" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6229-1984-B-ADD + 2778 if charset == b"jis_c6229-1984-b-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 519 if charset == b"iso-ir-93" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3546 if charset == b"jp-ocr-b-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2542 if charset == b"csiso93jis62291984badd" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6229-1984-HAND + 2777 if charset == b"jis_c6229-1984-hand" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 104 if charset == b"iso-ir-94" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3362 if charset == b"jp-ocr-hand" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2142 if charset == b"csiso94jis62291984hand" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6229-1984-HAND-ADD + 3106 if charset == b"jis_c6229-1984-hand-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 214 if charset == b"iso-ir-95" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3366 if charset == b"jp-ocr-hand-add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2130 if charset == b"csiso95jis62291984handadd" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_C6229-1984-KANA + 3127 if charset == b"jis_c6229-1984-kana" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 384 if charset == b"iso-ir-96" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3033 if charset == b"csiso96jisc62291984kana" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_2033-1983 + 3050 if charset == b"iso_2033-1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 489 if charset == b"iso-ir-98" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1289 if charset == b"e13b" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 739 if charset == b"csiso2033" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ANSI_X3.110-1983 + 3052 if charset == b"ansi_x3.110-1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 507 if charset == b"iso-ir-99" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3605 if charset == b"csa_t500-1983" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1861 if charset == b"naplps" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1593 if charset == b"csiso99naplps" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // T.61-7BIT + 1719 if charset == b"t.61-7bit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 30 if charset == b"iso-ir-102" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 695 if charset == b"csiso102t617bit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // T.61-8BIT + 1599 if charset == b"t.61-8bit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 149 if charset == b"t.61" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 900 if charset == b"iso-ir-103" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 820 if charset == b"csiso103t618bit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ECMA-CYRILLIC + 3018 if charset == b"ecma-cyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 35 if charset == b"iso-ir-111" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1432 if charset == b"koi8-e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 795 if charset == b"csiso111ecmacyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CSA_Z243.4-1985-1 + 2966 if charset == b"csa_z243.4-1985-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 470 if charset == b"iso-ir-121" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1354 if charset == b"iso646-ca" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 861 if charset == b"csa7-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 860 if charset == b"csa71" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 997 if charset == b"ca" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1122 if charset == b"csiso121canadian1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CSA_Z243.4-1985-2 + 2961 if charset == b"csa_z243.4-1985-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 460 if charset == b"iso-ir-122" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 680 if charset == b"iso646-ca2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 851 if charset == b"csa7-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 850 if charset == b"csa72" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1102 if charset == b"csiso122canadian2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CSA_Z243.4-1985-GR + 2962 if charset == b"csa_z243.4-1985-gr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1330 if charset == b"iso-ir-123" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 972 if charset == b"csiso123csaz24341985gr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_8859-6-E + 2920 if charset == b"iso-8859-6-e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3635 if charset == b"iso_8859-6-e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 744 if charset == b"csiso88596e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_8859-6-I + 2725 if charset == b"iso-8859-6-i" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3440 if charset == b"iso_8859-6-i" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1224 if charset == b"csiso88596i" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // T.101-G2 + 753 if charset == b"t.101-g2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 600 if charset == b"iso-ir-128" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1407 if charset == b"csiso128t101g2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_8859-8-E + 2845 if charset == b"iso-8859-8-e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3560 if charset == b"iso_8859-8-e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 669 if charset == b"csiso88598e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_8859-8-I + 2650 if charset == b"iso-8859-8-i" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3365 if charset == b"iso_8859-8-i" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1149 if charset == b"csiso88598i" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CSN_369103 + 3185 if charset == b"csn_369103" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 800 if charset == b"iso-ir-139" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1412 if charset == b"csiso139csn369103" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JUS_I.B1.002 + 4051 if charset == b"jus_i.b1.002" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 55 if charset == b"iso-ir-141" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1634 if charset == b"iso646-yu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 752 if charset == b"js" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1297 if charset == b"yu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1463 if charset == b"csiso141jusib1002" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IEC_P27-1 + 1054 if charset == b"iec_p27-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 915 if charset == b"iso-ir-143" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1495 if charset == b"csiso143iecp271" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JUS_I.B1.003-SERB + 4396 if charset == b"jus_i.b1.003-serb" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 335 if charset == b"iso-ir-146" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2342 if charset == b"serbian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1380 if charset == b"csiso146serbian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JUS_I.B1.003-MAC + 4065 if charset == b"jus_i.b1.003-mac" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3735 if charset == b"macedonian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 425 if charset == b"iso-ir-147" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2446 if charset == b"csiso147macedonian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GREEK-CCITT + 3182 if charset == b"greek-ccitt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 280 if charset == b"iso-ir-150" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 583 if charset == b"csiso150" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1374 if charset == b"csiso150greekccitt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // NC_NC00-10:81 + 3421 if charset == b"nc_nc00-10:81" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2604 if charset == b"cuba" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 180 if charset == b"iso-ir-151" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1664 if charset == b"iso646-cu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1537 if charset == b"csiso151cuba" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_6937-2-25 + 4129 if charset == b"iso_6937-2-25" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 170 if charset == b"iso-ir-152" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2002 if charset == b"csiso6937add" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GOST_19768-74 + 3450 if charset == b"gost_19768-74" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4702 if charset == b"st_sev_358-88" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1040 if charset == b"iso-ir-153" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1090 if charset == b"csiso153gost1976874" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_8859-SUPP + 3177 if charset == b"iso_8859-supp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 240 if charset == b"iso-ir-154" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2839 if charset == b"latin1-2-5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1441 if charset == b"csiso8859supp" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO_10367-BOX + 2359 if charset == b"iso_10367-box" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 210 if charset == b"iso-ir-155" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1379 if charset == b"csiso10367box" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // LATIN-LAP + 2889 if charset == b"latin-lap" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1088 if charset == b"lap" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 310 if charset == b"iso-ir-158" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2059 if charset == b"csiso158lap" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // JIS_X0212-1990 + 3475 if charset == b"jis_x0212-1990" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 696 if charset == b"x0212" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 910 if charset == b"iso-ir-159" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1141 if charset == b"csiso159jisx02121990" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // DS_2089 + 1882 if charset == b"ds_2089" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1166 if charset == b"ds2089" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2540 if charset == b"iso646-dk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1858 if charset == b"dk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2305 if charset == b"csiso646danish" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // US-DK + 2527 if charset == b"us-dk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2613 if charset == b"csusdk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // DK-US + 1490 if charset == b"dk-us" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1772 if charset == b"csdkus" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // KSC5636 + 1793 if charset == b"ksc5636" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1004 if charset == b"iso646-kr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1635 if charset == b"csksc5636" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UNICODE-1-1-UTF-7 + 1167 if charset == b"unicode-1-1-utf-7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1920 if charset == b"csunicode11utf7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-2022-CN + 1875 if charset == b"iso-2022-cn" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1211 if charset == b"csiso2022cn" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-2022-CN-EXT + 1259 if charset == b"iso-2022-cn-ext" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 594 if charset == b"csiso2022cnext" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-8 + 935 if charset == b"utf-8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 551 if charset == b"csutf8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + + // GBK + 2485 if charset == b"gbk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1345 if charset == b"cp936" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1105 if charset == b"ms936" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2959 if charset == b"windows-936" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2827 if charset == b"csgbk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GB18030 + 1332 if charset == b"gb18030" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1334 if charset == b"csgb18030" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // OSD_EBCDIC_DF04_15 + 2983 if charset == b"osd_ebcdic_df04_15" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1517 if charset == b"csosdebcdicdf0415" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // OSD_EBCDIC_DF03_IRV + 3894 if charset == b"osd_ebcdic_df03_irv" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2428 if charset == b"csosdebcdicdf03irv" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // OSD_EBCDIC_DF04_1 + 2967 if charset == b"osd_ebcdic_df04_1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1501 if charset == b"csosdebcdicdf041" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-11548-1 + 581 if charset == b"iso-11548-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1296 if charset == b"iso_11548-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1499 if charset == b"iso_tr_11548-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 246 if charset == b"csiso115481" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // KZ-1048 + 1128 if charset == b"kz-1048" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3576 if charset == b"strk1048-2002" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 856 if charset == b"rk1048" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2147 if charset == b"cskz1048" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-10646-UCS-2 + 1505 if charset == b"iso-10646-ucs-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1919 if charset == b"csunicode" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-10646-UCS-4 + 1540 if charset == b"iso-10646-ucs-4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 536 if charset == b"csucs4" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-10646-UCS-BASIC + 1519 if charset == b"iso-10646-ucs-basic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2404 if charset == b"csunicodeascii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-10646-UNICODE-LATIN1 + 1524 if charset == b"iso-10646-unicode-latin1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2715 if charset == b"csunicodelatin1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 714 if charset == b"iso-10646" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-10646-J-1 + 1494 if charset == b"iso-10646-j-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2972 if charset == b"csunicodejapanese" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-UNICODE-IBM-1261 + 1470 if charset == b"iso-unicode-ibm-1261" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1746 if charset == b"csunicodeibm1261" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-UNICODE-IBM-1268 + 1535 if charset == b"iso-unicode-ibm-1268" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1811 if charset == b"csunicodeibm1268" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-UNICODE-IBM-1276 + 1610 if charset == b"iso-unicode-ibm-1276" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1886 if charset == b"csunicodeibm1276" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-UNICODE-IBM-1264 + 1500 if charset == b"iso-unicode-ibm-1264" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1776 if charset == b"csunicodeibm1264" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-UNICODE-IBM-1265 + 1485 if charset == b"iso-unicode-ibm-1265" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1761 if charset == b"csunicodeibm1265" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UNICODE-1-1 + 976 if charset == b"unicode-1-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1731 if charset == b"csunicode11" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // SCSU + 1239 if charset == b"scsu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 936 if charset == b"csscsu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-7 + 1175 if charset == b"utf-7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 791 if charset == b"csutf7" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-16BE + 2294 if charset == b"utf-16be" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 994 if charset == b"csutf16be" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-16LE + 2599 if charset == b"utf-16le" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 794 if charset == b"csutf16le" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-16 + 1091 if charset == b"utf-16" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 707 if charset == b"csutf16" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CESU-8 + 626 if charset == b"cesu-8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 807 if charset == b"cscesu8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1661 if charset == b"cscesu-8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-32 + 1231 if charset == b"utf-32" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 847 if charset == b"csutf32" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-32BE + 2579 if charset == b"utf-32be" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1279 if charset == b"csutf32be" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-32LE + 2884 if charset == b"utf-32le" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1079 if charset == b"csutf32le" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // BOCU-1 + 796 if charset == b"bocu-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 742 if charset == b"csbocu1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 773 if charset == b"csbocu-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UTF-7-IMAP + 1530 if charset == b"utf-7-imap" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1145 if charset == b"csutf7imap" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-8859-1-WINDOWS-3.0-LATIN-1 + 2658 if charset == b"iso-8859-1-windows-3.0-latin-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1717 if charset == b"cswindows30latin1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-8859-1-WINDOWS-3.1-LATIN-1 + 2608 if charset == b"iso-8859-1-windows-3.1-latin-1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1712 if charset == b"cswindows31latin1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-8859-2-WINDOWS-LATIN-2 + 2589 if charset == b"iso-8859-2-windows-latin-2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1707 if charset == b"cswindows31latin2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ISO-8859-9-WINDOWS-LATIN-5 + 2979 if charset == b"iso-8859-9-windows-latin-5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1727 if charset == b"cswindows31latin5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // HP-ROMAN8 + 2465 if charset == b"hp-roman8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1511 if charset == b"roman8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 412 if charset == b"r8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1361 if charset == b"cshproman8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ADOBE-STANDARD-ENCODING + 4103 if charset == b"adobe-standard-encoding" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4833 if charset == b"csadobestandardencoding" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // VENTURA-US + 3765 if charset == b"ventura-us" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3341 if charset == b"csventuraus" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // VENTURA-INTERNATIONAL + 5061 if charset == b"ventura-international" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4177 if charset == b"csventurainternational" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // DEC-MCS + 537 if charset == b"dec-mcs" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 348 if charset == b"dec" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1573 if charset == b"csdecmcs" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM850 + 226 if charset == b"ibm850" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 450 if charset == b"cp850" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 298 if charset == b"850" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2899 if charset == b"cspc850multilingual" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // PC8-DANISH-NORWEGIAN + 5325 if charset == b"pc8-danish-norwegian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2815 if charset == b"cspc8danishnorwegian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM862 + 241 if charset == b"ibm862" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 465 if charset == b"cp862" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 233 if charset == b"862" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1503 if charset == b"cspc862latinhebrew" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // PC8-TURKISH + 3047 if charset == b"pc8-turkish" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2383 if charset == b"cspc8turkish" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM-SYMBOLS + 1126 if charset == b"ibm-symbols" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 632 if charset == b"csibmsymbols" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM-THAI + 2159 if charset == b"ibm-thai" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2210 if charset == b"csibmthai" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // HP-LEGAL + 3884 if charset == b"hp-legal" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3380 if charset == b"cshplegal" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // HP-PI-FONT + 1151 if charset == b"hp-pi-font" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 961 if charset == b"cshppifont" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // HP-MATH8 + 3558 if charset == b"hp-math8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2926 if charset == b"cshpmath8" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // ADOBE-SYMBOL-ENCODING + 3176 if charset == b"adobe-symbol-encoding" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3368 if charset == b"cshppsmath" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // HP-DESKTOP + 2932 if charset == b"hp-desktop" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2807 if charset == b"cshpdesktop" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // VENTURA-MATH + 5183 if charset == b"ventura-math" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 4054 if charset == b"csventuramath" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // MICROSOFT-PUBLISHING + 2150 if charset == b"microsoft-publishing" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2141 if charset == b"csmicrosoftpublishing" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-31J + 3762 if charset == b"windows-31j" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2407 if charset == b"cswindows31j" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // GB2312 + 1096 if charset == b"gb2312" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1458 if charset == b"csgb2312" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // BIG5 + 1729 if charset == b"big5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1041 if charset == b"csbig5" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // MACINTOSH + 2730 if charset == b"macintosh" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 368 if charset == b"mac" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2457 if charset == b"csmacintosh" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM037 + 896 if charset == b"ibm037" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1120 if charset == b"cp037" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1842 if charset == b"ebcdic-cp-us" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1837 if charset == b"ebcdic-cp-ca" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1548 if charset == b"ebcdic-cp-wt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1482 if charset == b"ebcdic-cp-nl" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1136 if charset == b"csibm037" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM038 + 656 if charset == b"ibm038" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1185 if charset == b"ebcdic-int" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 880 if charset == b"cp038" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1851 if charset == b"csibm038" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM273 + 1086 if charset == b"ibm273" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1310 if charset == b"cp273" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1138 if charset == b"csibm273" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM274 + 286 if charset == b"ibm274" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 969 if charset == b"ebcdic-be" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 510 if charset == b"cp274" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 783 if charset == b"csibm274" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM275 + 256 if charset == b"ibm275" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 814 if charset == b"ebcdic-br" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 480 if charset == b"cp275" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 648 if charset == b"csibm275" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM277 + 596 if charset == b"ibm277" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1953 if charset == b"ebcdic-cp-dk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 837 if charset == b"ebcdic-cp-no" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 836 if charset == b"csibm277" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM278 + 356 if charset == b"ibm278" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 580 if charset == b"cp278" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1512 if charset == b"ebcdic-cp-fi" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1037 if charset == b"ebcdic-cp-se" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1551 if charset == b"csibm278" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM280 + 206 if charset == b"ibm280" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 430 if charset == b"cp280" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1542 if charset == b"ebcdic-cp-it" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 928 if charset == b"csibm280" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM281 + 106 if charset == b"ibm281" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1071 if charset == b"ebcdic-jp-e" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 330 if charset == b"cp281" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 478 if charset == b"csibm281" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM284 + 166 if charset == b"ibm284" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 390 if charset == b"cp284" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 942 if charset == b"ebcdic-cp-es" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 663 if charset == b"csibm284" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM285 + 136 if charset == b"ibm285" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 360 if charset == b"cp285" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1983 if charset == b"ebcdic-cp-gb" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 528 if charset == b"csibm285" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM290 + 506 if charset == b"ibm290" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 730 if charset == b"cp290" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2164 if charset == b"ebcdic-jp-kana" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1228 if charset == b"csibm290" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM297 + 776 if charset == b"ibm297" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1000 if charset == b"cp297" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1507 if charset == b"ebcdic-cp-fr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1016 if charset == b"csibm297" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM420 + 171 if charset == b"ibm420" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 395 if charset == b"cp420" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1183 if charset == b"ebcdic-cp-ar1" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 893 if charset == b"csibm420" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM423 + 931 if charset == b"ibm423" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1155 if charset == b"cp423" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1643 if charset == b"ebcdic-cp-gr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 983 if charset == b"csibm423" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM424 + 131 if charset == b"ibm424" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 355 if charset == b"cp424" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1042 if charset == b"ebcdic-cp-he" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 628 if charset == b"csibm424" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM437 + 876 if charset == b"ibm437" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1100 if charset == b"cp437" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 423 if charset == b"437" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1446 if charset == b"cspc8codepage437" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM500 + 211 if charset == b"ibm500" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 435 if charset == b"cp500" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1047 if charset == b"ebcdic-cp-be" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1968 if charset == b"ebcdic-cp-ch" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 933 if charset == b"csibm500" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM851 + 126 if charset == b"ibm851" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 350 if charset == b"cp851" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 198 if charset == b"851" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 498 if charset == b"csibm851" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM852 + 116 if charset == b"ibm852" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 340 if charset == b"cp852" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 188 if charset == b"852" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 238 if charset == b"cspcp852" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM855 + 156 if charset == b"ibm855" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 380 if charset == b"cp855" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 228 if charset == b"855" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 548 if charset == b"csibm855" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM857 + 496 if charset == b"ibm857" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 720 if charset == b"cp857" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 568 if charset == b"857" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 736 if charset == b"csibm857" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM860 + 351 if charset == b"ibm860" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 575 if charset == b"cp860" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 343 if charset == b"860" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1073 if charset == b"csibm860" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM861 + 251 if charset == b"ibm861" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 475 if charset == b"cp861" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 243 if charset == b"861" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 405 if charset == b"cp-is" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 623 if charset == b"csibm861" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM863 + 1111 if charset == b"ibm863" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1335 if charset == b"cp863" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1103 if charset == b"863" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1163 if charset == b"csibm863" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM864 + 311 if charset == b"ibm864" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 535 if charset == b"cp864" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 808 if charset == b"csibm864" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM865 + 281 if charset == b"ibm865" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 505 if charset == b"cp865" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 273 if charset == b"865" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 673 if charset == b"csibm865" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM868 + 381 if charset == b"ibm868" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 605 if charset == b"cp868" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 925 if charset == b"cp-ar" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1576 if charset == b"csibm868" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM869 + 981 if charset == b"ibm869" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1205 if charset == b"cp869" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 973 if charset == b"869" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 920 if charset == b"cp-gr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1013 if charset == b"csibm869" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM870 + 396 if charset == b"ibm870" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 620 if charset == b"cp870" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1115 if charset == b"ebcdic-cp-roece" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1387 if charset == b"ebcdic-cp-yu" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1118 if charset == b"csibm870" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM871 + 296 if charset == b"ibm871" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 520 if charset == b"cp871" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1617 if charset == b"ebcdic-cp-is" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 668 if charset == b"csibm871" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM880 + 276 if charset == b"ibm880" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 500 if charset == b"cp880" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1445 if charset == b"ebcdic-cyrillic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 998 if charset == b"csibm880" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM891 + 476 if charset == b"ibm891" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 700 if charset == b"cp891" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 848 if charset == b"csibm891" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM903 + 1321 if charset == b"ibm903" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1545 if charset == b"cp903" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1373 if charset == b"csibm903" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM904 + 521 if charset == b"ibm904" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 745 if charset == b"cp904" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 418 if charset == b"904" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1569 if charset == b"csibbm904" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM905 + 491 if charset == b"ibm905" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 715 if charset == b"cp905" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1232 if charset == b"ebcdic-cp-tr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 883 if charset == b"csibm905" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM918 + 541 if charset == b"ibm918" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 765 if charset == b"cp918" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1178 if charset == b"ebcdic-cp-ar2" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1736 if charset == b"csibm918" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM1026 + 377 if charset == b"ibm1026" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 601 if charset == b"cp1026" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 784 if charset == b"csibm1026" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-AT-DE + 1662 if charset == b"ebcdic-at-de" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1675 if charset == b"csibmebcdicatde" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-AT-DE-A + 2139 if charset == b"ebcdic-at-de-a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2118 if charset == b"csebcdicatdea" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-CA-FR + 1582 if charset == b"ebcdic-ca-fr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2572 if charset == b"csebcdiccafr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-DK-NO + 1857 if charset == b"ebcdic-dk-no" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2018 if charset == b"csebcdicdkno" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-DK-NO-A + 2534 if charset == b"ebcdic-dk-no-a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2694 if charset == b"csebcdicdknoa" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-FI-SE + 1452 if charset == b"ebcdic-fi-se" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1777 if charset == b"csebcdicfise" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-FI-SE-A + 1929 if charset == b"ebcdic-fi-se-a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2253 if charset == b"csebcdicfisea" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-FR + 619 if charset == b"ebcdic-fr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1570 if charset == b"csebcdicfr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-IT + 1579 if charset == b"ebcdic-it" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1605 if charset == b"csebcdicit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-PT + 1009 if charset == b"ebcdic-pt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1165 if charset == b"csebcdicpt" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-ES + 1420 if charset == b"ebcdic-es" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1080 if charset == b"csebcdices" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-ES-A + 2362 if charset == b"ebcdic-es-a" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2021 if charset == b"csebcdicesa" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-ES-S + 1422 if charset == b"ebcdic-es-s" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1081 if charset == b"csebcdicess" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-UK + 2811 if charset == b"ebcdic-uk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3662 if charset == b"csebcdicuk" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // EBCDIC-US + 1325 if charset == b"ebcdic-us" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1980 if charset == b"csebcdicus" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // UNKNOWN-8BIT + 4173 if charset == b"unknown-8bit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2779 if charset == b"csunknown8bit" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // MNEMONIC + 913 if charset == b"mnemonic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1870 if charset == b"csmnemonic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // MNEM + 279 if charset == b"mnem" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 911 if charset == b"csmnem" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // VISCII + 1711 if charset == b"viscii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1663 if charset == b"csviscii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // VIQR + 1874 if charset == b"viqr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1186 if charset == b"csviqr" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // KOI8-R + 1032 if charset == b"koi8-r" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 978 if charset == b"cskoi8r" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // HZ-GB-2312 + 1941 if charset == b"hz-gb-2312" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM866 + 531 if charset == b"ibm866" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 755 if charset == b"cp866" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 523 if charset == b"866" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1098 if charset == b"csibm866" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM775 + 446 if charset == b"ibm775" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 670 if charset == b"cp775" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2058 if charset == b"cspc775baltic" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // KOI8-U + 1822 if charset == b"koi8-u" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1768 if charset == b"cskoi8u" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM00858 + 1221 if charset == b"ibm00858" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2038 if charset == b"ccsid00858" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 592 if charset == b"cp00858" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2539 if charset == b"pc-multilingual-850+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1688 if charset == b"csibm00858" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM00924 + 733 if charset == b"ibm00924" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1395 if charset == b"ccsid00924" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 802 if charset == b"cp00924" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1594 if charset == b"ebcdic-latin9--euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1045 if charset == b"csibm00924" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01140 + 618 if charset == b"ibm01140" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 945 if charset == b"ccsid01140" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 462 if charset == b"cp01140" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1293 if charset == b"ebcdic-us-37+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 595 if charset == b"csibm01140" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01141 + 168 if charset == b"ibm01141" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 845 if charset == b"ccsid01141" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 362 if charset == b"cp01141" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1683 if charset == b"ebcdic-de-273+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 495 if charset == b"csibm01141" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01142 + 148 if charset == b"ibm01142" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 835 if charset == b"ccsid01142" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 352 if charset == b"cp01142" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2298 if charset == b"ebcdic-dk-277+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1313 if charset == b"ebcdic-no-277+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 485 if charset == b"csibm01142" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01143 + 708 if charset == b"ibm01143" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1705 if charset == b"ccsid01143" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1222 if charset == b"cp01143" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1693 if charset == b"ebcdic-fi-278+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1943 if charset == b"ebcdic-se-278+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1355 if charset == b"csibm01143" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01144 + 353 if charset == b"ibm01144" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 905 if charset == b"ccsid01144" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 422 if charset == b"cp01144" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2023 if charset == b"ebcdic-it-280+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 555 if charset == b"csibm01144" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01145 + 218 if charset == b"ibm01145" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 875 if charset == b"ccsid01145" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 392 if charset == b"cp01145" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1789 if charset == b"ebcdic-es-284+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 525 if charset == b"csibm01145" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01146 + 643 if charset == b"ibm01146" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1125 if charset == b"ccsid01146" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 642 if charset == b"cp01146" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1698 if charset == b"ebcdic-gb-285+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 775 if charset == b"csibm01146" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01147 + 406 if charset == b"ibm01147" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1215 if charset == b"ccsid01147" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 732 if charset == b"cp01147" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1063 if charset == b"ebcdic-fr-297+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 865 if charset == b"csibm01147" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01148 + 1121 if charset == b"ibm01148" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 975 if charset == b"ccsid01148" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 492 if charset == b"cp01148" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1254 if charset == b"ebcdic-international-500+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 625 if charset == b"csibm01148" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM01149 + 558 if charset == b"ibm01149" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1575 if charset == b"ccsid01149" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1092 if charset == b"cp01149" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1563 if charset == b"ebcdic-is-871+euro" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1225 if charset == b"csibm01149" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // BIG5-HKSCS + 4842 if charset == b"big5-hkscs" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2537 if charset == b"csbig5hkscs" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // IBM1047 + 502 if charset == b"ibm1047" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 401 if charset == b"ibm-1047" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 879 if charset == b"csibm1047" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // PTCP154 + 607 if charset == b"ptcp154" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 259 if charset == b"csptcp154" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 530 if charset == b"pt154" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 345 if charset == b"cp154" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 3958 if charset == b"cyrillic-asian" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // AMIGA-1251 + 2805 if charset == b"amiga-1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1312 if charset == b"ami1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2704 if charset == b"amiga1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1343 if charset == b"ami-1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2546 if charset == b"csamiga1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // KOI7-SWITCHED + 2784 if charset == b"koi7-switched" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2690 if charset == b"cskoi7switched" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // BRF + 448 if charset == b"brf" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 385 if charset == b"csbrf" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // TSCII + 0 if charset == b"tscii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 87 if charset == b"cstscii" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CP51932 + 1082 if charset == b"cp51932" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1039 if charset == b"cscp51932" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-874 + 2716 if charset == b"windows-874" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1442 if charset == b"cswindows874" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1250 + 2302 if charset == b"windows-1250" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1763 if charset == b"cswindows1250" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1251 + 2252 if charset == b"windows-1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1713 if charset == b"cswindows1251" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1252 + 2247 if charset == b"windows-1252" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1708 if charset == b"cswindows1252" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1253 + 2682 if charset == b"windows-1253" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 2143 if charset == b"cswindows1253" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1254 + 2282 if charset == b"windows-1254" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1743 if charset == b"cswindows1254" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1255 + 2267 if charset == b"windows-1255" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1728 if charset == b"cswindows1255" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1256 + 2392 if charset == b"windows-1256" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1853 if charset == b"cswindows1256" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1257 + 2437 if charset == b"windows-1257" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1898 if charset == b"cswindows1257" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // WINDOWS-1258 + 2317 if charset == b"windows-1258" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1778 if charset == b"cswindows1258" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // TIS-620 + 1012 if charset == b"tis-620" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 703 if charset == b"cstis620" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 1400 if charset == b"iso-8859-11" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + // CP50220 + 437 if charset == b"cp50220" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), + 219 if charset == b"cscp50220" => Some(Box::new(SingleByteDecoder::new(SingleByteDecoder::ISO_8859_2, capacity))), +*/ diff --git a/src/decoders/charsets/single_byte.rs b/src/decoders/charsets/single_byte.rs new file mode 100644 index 0000000..be73361 --- /dev/null +++ b/src/decoders/charsets/single_byte.rs @@ -0,0 +1,491 @@ +use super::CharsetDecoder; + +pub struct SingleByteDecoder { + table: &'static [char], + result: String, +} + +impl CharsetDecoder for SingleByteDecoder { + fn ingest(&mut self, ch: u8) -> () { + self.result + .push(unsafe { *self.table.get_unchecked(ch as usize) }); + } + + fn to_string(&self) -> Option<&str> { + if self.result.len() > 0 { + Some(&self.result) + } else { + None + } + } +} + +impl SingleByteDecoder { + pub fn new(table: &'static [char], capacity: usize) -> SingleByteDecoder { + SingleByteDecoder { + result: String::with_capacity(capacity), + table: table, + } + } + + pub const ISO_8859_1: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{a1}', '\u{a2}', + '\u{a3}', '\u{a4}', '\u{a5}', '\u{a6}', '\u{a7}', '\u{a8}', '\u{a9}', '\u{aa}', '\u{ab}', + '\u{ac}', '\u{ad}', '\u{ae}', '\u{af}', '\u{b0}', '\u{b1}', '\u{b2}', '\u{b3}', '\u{b4}', + '\u{b5}', '\u{b6}', '\u{b7}', '\u{b8}', '\u{b9}', '\u{ba}', '\u{bb}', '\u{bc}', '\u{bd}', + '\u{be}', '\u{bf}', '\u{c0}', '\u{c1}', '\u{c2}', '\u{c3}', '\u{c4}', '\u{c5}', '\u{c6}', + '\u{c7}', '\u{c8}', '\u{c9}', '\u{ca}', '\u{cb}', '\u{cc}', '\u{cd}', '\u{ce}', '\u{cf}', + '\u{d0}', '\u{d1}', '\u{d2}', '\u{d3}', '\u{d4}', '\u{d5}', '\u{d6}', '\u{d7}', '\u{d8}', + '\u{d9}', '\u{da}', '\u{db}', '\u{dc}', '\u{dd}', '\u{de}', '\u{df}', '\u{e0}', '\u{e1}', + '\u{e2}', '\u{e3}', '\u{e4}', '\u{e5}', '\u{e6}', '\u{e7}', '\u{e8}', '\u{e9}', '\u{ea}', + '\u{eb}', '\u{ec}', '\u{ed}', '\u{ee}', '\u{ef}', '\u{f0}', '\u{f1}', '\u{f2}', '\u{f3}', + '\u{f4}', '\u{f5}', '\u{f6}', '\u{f7}', '\u{f8}', '\u{f9}', '\u{fa}', '\u{fb}', '\u{fc}', + '\u{fd}', '\u{fe}', '\u{ff}', + ]; + + pub const ISO_8859_2: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{104}', '\u{2d8}', + '\u{141}', '\u{a4}', '\u{13d}', '\u{15a}', '\u{a7}', '\u{a8}', '\u{160}', '\u{15e}', + '\u{164}', '\u{179}', '\u{ad}', '\u{17d}', '\u{17b}', '\u{b0}', '\u{105}', '\u{2db}', + '\u{142}', '\u{b4}', '\u{13e}', '\u{15b}', '\u{2c7}', '\u{b8}', '\u{161}', '\u{15f}', + '\u{165}', '\u{17a}', '\u{2dd}', '\u{17e}', '\u{17c}', '\u{154}', '\u{c1}', '\u{c2}', + '\u{102}', '\u{c4}', '\u{139}', '\u{106}', '\u{c7}', '\u{10c}', '\u{c9}', '\u{118}', + '\u{cb}', '\u{11a}', '\u{cd}', '\u{ce}', '\u{10e}', '\u{110}', '\u{143}', '\u{147}', + '\u{d3}', '\u{d4}', '\u{150}', '\u{d6}', '\u{d7}', '\u{158}', '\u{16e}', '\u{da}', + '\u{170}', '\u{dc}', '\u{dd}', '\u{162}', '\u{df}', '\u{155}', '\u{e1}', '\u{e2}', + '\u{103}', '\u{e4}', '\u{13a}', '\u{107}', '\u{e7}', '\u{10d}', '\u{e9}', '\u{119}', + '\u{eb}', '\u{11b}', '\u{ed}', '\u{ee}', '\u{10f}', '\u{111}', '\u{144}', '\u{148}', + '\u{f3}', '\u{f4}', '\u{151}', '\u{f6}', '\u{f7}', '\u{159}', '\u{16f}', '\u{fa}', + '\u{171}', '\u{fc}', '\u{fd}', '\u{163}', '\u{2d9}', + ]; + + pub const ISO_8859_3: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{126}', '\u{2d8}', + '\u{a3}', '\u{a4}', '\u{fffd}', '\u{124}', '\u{a7}', '\u{a8}', '\u{130}', '\u{15e}', + '\u{11e}', '\u{134}', '\u{ad}', '\u{fffd}', '\u{17b}', '\u{b0}', '\u{127}', '\u{b2}', + '\u{b3}', '\u{b4}', '\u{b5}', '\u{125}', '\u{b7}', '\u{b8}', '\u{131}', '\u{15f}', + '\u{11f}', '\u{135}', '\u{bd}', '\u{fffd}', '\u{17c}', '\u{c0}', '\u{c1}', '\u{c2}', + '\u{fffd}', '\u{c4}', '\u{10a}', '\u{108}', '\u{c7}', '\u{c8}', '\u{c9}', '\u{ca}', + '\u{cb}', '\u{cc}', '\u{cd}', '\u{ce}', '\u{cf}', '\u{fffd}', '\u{d1}', '\u{d2}', '\u{d3}', + '\u{d4}', '\u{120}', '\u{d6}', '\u{d7}', '\u{11c}', '\u{d9}', '\u{da}', '\u{db}', '\u{dc}', + '\u{16c}', '\u{15c}', '\u{df}', '\u{e0}', '\u{e1}', '\u{e2}', '\u{fffd}', '\u{e4}', + '\u{10b}', '\u{109}', '\u{e7}', '\u{e8}', '\u{e9}', '\u{ea}', '\u{eb}', '\u{ec}', '\u{ed}', + '\u{ee}', '\u{ef}', '\u{fffd}', '\u{f1}', '\u{f2}', '\u{f3}', '\u{f4}', '\u{121}', + '\u{f6}', '\u{f7}', '\u{11d}', '\u{f9}', '\u{fa}', '\u{fb}', '\u{fc}', '\u{16d}', + '\u{15d}', '\u{2d9}', + ]; + + pub const ISO_8859_4: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{104}', '\u{138}', + '\u{156}', '\u{a4}', '\u{128}', '\u{13b}', '\u{a7}', '\u{a8}', '\u{160}', '\u{112}', + '\u{122}', '\u{166}', '\u{ad}', '\u{17d}', '\u{af}', '\u{b0}', '\u{105}', '\u{2db}', + '\u{157}', '\u{b4}', '\u{129}', '\u{13c}', '\u{2c7}', '\u{b8}', '\u{161}', '\u{113}', + '\u{123}', '\u{167}', '\u{14a}', '\u{17e}', '\u{14b}', '\u{100}', '\u{c1}', '\u{c2}', + '\u{c3}', '\u{c4}', '\u{c5}', '\u{c6}', '\u{12e}', '\u{10c}', '\u{c9}', '\u{118}', + '\u{cb}', '\u{116}', '\u{cd}', '\u{ce}', '\u{12a}', '\u{110}', '\u{145}', '\u{14c}', + '\u{136}', '\u{d4}', '\u{d5}', '\u{d6}', '\u{d7}', '\u{d8}', '\u{172}', '\u{da}', '\u{db}', + '\u{dc}', '\u{168}', '\u{16a}', '\u{df}', '\u{101}', '\u{e1}', '\u{e2}', '\u{e3}', + '\u{e4}', '\u{e5}', '\u{e6}', '\u{12f}', '\u{10d}', '\u{e9}', '\u{119}', '\u{eb}', + '\u{117}', '\u{ed}', '\u{ee}', '\u{12b}', '\u{111}', '\u{146}', '\u{14d}', '\u{137}', + '\u{f4}', '\u{f5}', '\u{f6}', '\u{f7}', '\u{f8}', '\u{173}', '\u{fa}', '\u{fb}', '\u{fc}', + '\u{169}', '\u{16b}', '\u{2d9}', + ]; + + pub const ISO_8859_5: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{401}', '\u{402}', + '\u{403}', '\u{404}', '\u{405}', '\u{406}', '\u{407}', '\u{408}', '\u{409}', '\u{40a}', + '\u{40b}', '\u{40c}', '\u{ad}', '\u{40e}', '\u{40f}', '\u{410}', '\u{411}', '\u{412}', + '\u{413}', '\u{414}', '\u{415}', '\u{416}', '\u{417}', '\u{418}', '\u{419}', '\u{41a}', + '\u{41b}', '\u{41c}', '\u{41d}', '\u{41e}', '\u{41f}', '\u{420}', '\u{421}', '\u{422}', + '\u{423}', '\u{424}', '\u{425}', '\u{426}', '\u{427}', '\u{428}', '\u{429}', '\u{42a}', + '\u{42b}', '\u{42c}', '\u{42d}', '\u{42e}', '\u{42f}', '\u{430}', '\u{431}', '\u{432}', + '\u{433}', '\u{434}', '\u{435}', '\u{436}', '\u{437}', '\u{438}', '\u{439}', '\u{43a}', + '\u{43b}', '\u{43c}', '\u{43d}', '\u{43e}', '\u{43f}', '\u{440}', '\u{441}', '\u{442}', + '\u{443}', '\u{444}', '\u{445}', '\u{446}', '\u{447}', '\u{448}', '\u{449}', '\u{44a}', + '\u{44b}', '\u{44c}', '\u{44d}', '\u{44e}', '\u{44f}', '\u{2116}', '\u{451}', '\u{452}', + '\u{453}', '\u{454}', '\u{455}', '\u{456}', '\u{457}', '\u{458}', '\u{459}', '\u{45a}', + '\u{45b}', '\u{45c}', '\u{a7}', '\u{45e}', '\u{45f}', + ]; + + pub const ISO_8859_6: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{a4}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{60c}', '\u{ad}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{61b}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{61f}', '\u{fffd}', '\u{621}', '\u{622}', '\u{623}', '\u{624}', '\u{625}', + '\u{626}', '\u{627}', '\u{628}', '\u{629}', '\u{62a}', '\u{62b}', '\u{62c}', '\u{62d}', + '\u{62e}', '\u{62f}', '\u{630}', '\u{631}', '\u{632}', '\u{633}', '\u{634}', '\u{635}', + '\u{636}', '\u{637}', '\u{638}', '\u{639}', '\u{63a}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{640}', '\u{641}', '\u{642}', '\u{643}', '\u{644}', '\u{645}', + '\u{646}', '\u{647}', '\u{648}', '\u{649}', '\u{64a}', '\u{64b}', '\u{64c}', '\u{64d}', + '\u{64e}', '\u{64f}', '\u{650}', '\u{651}', '\u{652}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', + ]; + + pub const ISO_8859_7: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{2018}', + '\u{2019}', '\u{a3}', '\u{fffd}', '\u{fffd}', '\u{a6}', '\u{a7}', '\u{a8}', '\u{a9}', + '\u{fffd}', '\u{ab}', '\u{ac}', '\u{ad}', '\u{fffd}', '\u{2015}', '\u{b0}', '\u{b1}', + '\u{b2}', '\u{b3}', '\u{384}', '\u{385}', '\u{386}', '\u{b7}', '\u{388}', '\u{389}', + '\u{38a}', '\u{bb}', '\u{38c}', '\u{bd}', '\u{38e}', '\u{38f}', '\u{390}', '\u{391}', + '\u{392}', '\u{393}', '\u{394}', '\u{395}', '\u{396}', '\u{397}', '\u{398}', '\u{399}', + '\u{39a}', '\u{39b}', '\u{39c}', '\u{39d}', '\u{39e}', '\u{39f}', '\u{3a0}', '\u{3a1}', + '\u{fffd}', '\u{3a3}', '\u{3a4}', '\u{3a5}', '\u{3a6}', '\u{3a7}', '\u{3a8}', '\u{3a9}', + '\u{3aa}', '\u{3ab}', '\u{3ac}', '\u{3ad}', '\u{3ae}', '\u{3af}', '\u{3b0}', '\u{3b1}', + '\u{3b2}', '\u{3b3}', '\u{3b4}', '\u{3b5}', '\u{3b6}', '\u{3b7}', '\u{3b8}', '\u{3b9}', + '\u{3ba}', '\u{3bb}', '\u{3bc}', '\u{3bd}', '\u{3be}', '\u{3bf}', '\u{3c0}', '\u{3c1}', + '\u{3c2}', '\u{3c3}', '\u{3c4}', '\u{3c5}', '\u{3c6}', '\u{3c7}', '\u{3c8}', '\u{3c9}', + '\u{3ca}', '\u{3cb}', '\u{3cc}', '\u{3cd}', '\u{3ce}', '\u{fffd}', + ]; + + pub const ISO_8859_8: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{fffd}', '\u{a2}', + '\u{a3}', '\u{a4}', '\u{a5}', '\u{a6}', '\u{a7}', '\u{a8}', '\u{a9}', '\u{d7}', '\u{ab}', + '\u{ac}', '\u{ad}', '\u{ae}', '\u{af}', '\u{b0}', '\u{b1}', '\u{b2}', '\u{b3}', '\u{b4}', + '\u{b5}', '\u{b6}', '\u{b7}', '\u{b8}', '\u{b9}', '\u{f7}', '\u{bb}', '\u{bc}', '\u{bd}', + '\u{be}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', + '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{fffd}', '\u{2017}', '\u{5d0}', + '\u{5d1}', '\u{5d2}', '\u{5d3}', '\u{5d4}', '\u{5d5}', '\u{5d6}', '\u{5d7}', '\u{5d8}', + '\u{5d9}', '\u{5da}', '\u{5db}', '\u{5dc}', '\u{5dd}', '\u{5de}', '\u{5df}', '\u{5e0}', + '\u{5e1}', '\u{5e2}', '\u{5e3}', '\u{5e4}', '\u{5e5}', '\u{5e6}', '\u{5e7}', '\u{5e8}', + '\u{5e9}', '\u{5ea}', '\u{fffd}', '\u{fffd}', '\u{200e}', '\u{200f}', '\u{fffd}', + ]; + + pub const ISO_8859_9: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{a1}', '\u{a2}', + '\u{a3}', '\u{a4}', '\u{a5}', '\u{a6}', '\u{a7}', '\u{a8}', '\u{a9}', '\u{aa}', '\u{ab}', + '\u{ac}', '\u{ad}', '\u{ae}', '\u{af}', '\u{b0}', '\u{b1}', '\u{b2}', '\u{b3}', '\u{b4}', + '\u{b5}', '\u{b6}', '\u{b7}', '\u{b8}', '\u{b9}', '\u{ba}', '\u{bb}', '\u{bc}', '\u{bd}', + '\u{be}', '\u{bf}', '\u{c0}', '\u{c1}', '\u{c2}', '\u{c3}', '\u{c4}', '\u{c5}', '\u{c6}', + '\u{c7}', '\u{c8}', '\u{c9}', '\u{ca}', '\u{cb}', '\u{cc}', '\u{cd}', '\u{ce}', '\u{cf}', + '\u{11e}', '\u{d1}', '\u{d2}', '\u{d3}', '\u{d4}', '\u{d5}', '\u{d6}', '\u{d7}', '\u{d8}', + '\u{d9}', '\u{da}', '\u{db}', '\u{dc}', '\u{130}', '\u{15e}', '\u{df}', '\u{e0}', '\u{e1}', + '\u{e2}', '\u{e3}', '\u{e4}', '\u{e5}', '\u{e6}', '\u{e7}', '\u{e8}', '\u{e9}', '\u{ea}', + '\u{eb}', '\u{ec}', '\u{ed}', '\u{ee}', '\u{ef}', '\u{11f}', '\u{f1}', '\u{f2}', '\u{f3}', + '\u{f4}', '\u{f5}', '\u{f6}', '\u{f7}', '\u{f8}', '\u{f9}', '\u{fa}', '\u{fb}', '\u{fc}', + '\u{131}', '\u{15f}', '\u{ff}', + ]; + + pub const ISO_8859_10: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{104}', '\u{112}', + '\u{122}', '\u{12a}', '\u{128}', '\u{136}', '\u{a7}', '\u{13b}', '\u{110}', '\u{160}', + '\u{166}', '\u{17d}', '\u{ad}', '\u{16a}', '\u{14a}', '\u{b0}', '\u{105}', '\u{113}', + '\u{123}', '\u{12b}', '\u{129}', '\u{137}', '\u{b7}', '\u{13c}', '\u{111}', '\u{161}', + '\u{167}', '\u{17e}', '\u{2015}', '\u{16b}', '\u{14b}', '\u{100}', '\u{c1}', '\u{c2}', + '\u{c3}', '\u{c4}', '\u{c5}', '\u{c6}', '\u{12e}', '\u{10c}', '\u{c9}', '\u{118}', + '\u{cb}', '\u{116}', '\u{cd}', '\u{ce}', '\u{cf}', '\u{d0}', '\u{145}', '\u{14c}', + '\u{d3}', '\u{d4}', '\u{d5}', '\u{d6}', '\u{168}', '\u{d8}', '\u{172}', '\u{da}', '\u{db}', + '\u{dc}', '\u{dd}', '\u{de}', '\u{df}', '\u{101}', '\u{e1}', '\u{e2}', '\u{e3}', '\u{e4}', + '\u{e5}', '\u{e6}', '\u{12f}', '\u{10d}', '\u{e9}', '\u{119}', '\u{eb}', '\u{117}', + '\u{ed}', '\u{ee}', '\u{ef}', '\u{f0}', '\u{146}', '\u{14d}', '\u{f3}', '\u{f4}', '\u{f5}', + '\u{f6}', '\u{169}', '\u{f8}', '\u{173}', '\u{fa}', '\u{fb}', '\u{fc}', '\u{fd}', '\u{fe}', + '\u{138}', + ]; + + pub const ISO_8859_13: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{201d}', '\u{a2}', + '\u{a3}', '\u{a4}', '\u{201e}', '\u{a6}', '\u{a7}', '\u{d8}', '\u{a9}', '\u{156}', + '\u{ab}', '\u{ac}', '\u{ad}', '\u{ae}', '\u{c6}', '\u{b0}', '\u{b1}', '\u{b2}', '\u{b3}', + '\u{201c}', '\u{b5}', '\u{b6}', '\u{b7}', '\u{f8}', '\u{b9}', '\u{157}', '\u{bb}', + '\u{bc}', '\u{bd}', '\u{be}', '\u{e6}', '\u{104}', '\u{12e}', '\u{100}', '\u{106}', + '\u{c4}', '\u{c5}', '\u{118}', '\u{112}', '\u{10c}', '\u{c9}', '\u{179}', '\u{116}', + '\u{122}', '\u{136}', '\u{12a}', '\u{13b}', '\u{160}', '\u{143}', '\u{145}', '\u{d3}', + '\u{14c}', '\u{d5}', '\u{d6}', '\u{d7}', '\u{172}', '\u{141}', '\u{15a}', '\u{16a}', + '\u{dc}', '\u{17b}', '\u{17d}', '\u{df}', '\u{105}', '\u{12f}', '\u{101}', '\u{107}', + '\u{e4}', '\u{e5}', '\u{119}', '\u{113}', '\u{10d}', '\u{e9}', '\u{17a}', '\u{117}', + '\u{123}', '\u{137}', '\u{12b}', '\u{13c}', '\u{161}', '\u{144}', '\u{146}', '\u{f3}', + '\u{14d}', '\u{f5}', '\u{f6}', '\u{f7}', '\u{173}', '\u{142}', '\u{15b}', '\u{16b}', + '\u{fc}', '\u{17c}', '\u{17e}', '\u{2019}', + ]; + + pub const ISO_8859_14: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{1e02}', + '\u{1e03}', '\u{a3}', '\u{10a}', '\u{10b}', '\u{1e0a}', '\u{a7}', '\u{1e80}', '\u{a9}', + '\u{1e82}', '\u{1e0b}', '\u{1ef2}', '\u{ad}', '\u{ae}', '\u{178}', '\u{1e1e}', '\u{1e1f}', + '\u{120}', '\u{121}', '\u{1e40}', '\u{1e41}', '\u{b6}', '\u{1e56}', '\u{1e81}', '\u{1e57}', + '\u{1e83}', '\u{1e60}', '\u{1ef3}', '\u{1e84}', '\u{1e85}', '\u{1e61}', '\u{c0}', '\u{c1}', + '\u{c2}', '\u{c3}', '\u{c4}', '\u{c5}', '\u{c6}', '\u{c7}', '\u{c8}', '\u{c9}', '\u{ca}', + '\u{cb}', '\u{cc}', '\u{cd}', '\u{ce}', '\u{cf}', '\u{174}', '\u{d1}', '\u{d2}', '\u{d3}', + '\u{d4}', '\u{d5}', '\u{d6}', '\u{1e6a}', '\u{d8}', '\u{d9}', '\u{da}', '\u{db}', '\u{dc}', + '\u{dd}', '\u{176}', '\u{df}', '\u{e0}', '\u{e1}', '\u{e2}', '\u{e3}', '\u{e4}', '\u{e5}', + '\u{e6}', '\u{e7}', '\u{e8}', '\u{e9}', '\u{ea}', '\u{eb}', '\u{ec}', '\u{ed}', '\u{ee}', + '\u{ef}', '\u{175}', '\u{f1}', '\u{f2}', '\u{f3}', '\u{f4}', '\u{f5}', '\u{f6}', + '\u{1e6b}', '\u{f8}', '\u{f9}', '\u{fa}', '\u{fb}', '\u{fc}', '\u{fd}', '\u{177}', + '\u{ff}', + ]; + + pub const ISO_8859_15: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{a1}', '\u{a2}', + '\u{a3}', '\u{20ac}', '\u{a5}', '\u{160}', '\u{a7}', '\u{161}', '\u{a9}', '\u{aa}', + '\u{ab}', '\u{ac}', '\u{ad}', '\u{ae}', '\u{af}', '\u{b0}', '\u{b1}', '\u{b2}', '\u{b3}', + '\u{17d}', '\u{b5}', '\u{b6}', '\u{b7}', '\u{17e}', '\u{b9}', '\u{ba}', '\u{bb}', + '\u{152}', '\u{153}', '\u{178}', '\u{bf}', '\u{c0}', '\u{c1}', '\u{c2}', '\u{c3}', + '\u{c4}', '\u{c5}', '\u{c6}', '\u{c7}', '\u{c8}', '\u{c9}', '\u{ca}', '\u{cb}', '\u{cc}', + '\u{cd}', '\u{ce}', '\u{cf}', '\u{d0}', '\u{d1}', '\u{d2}', '\u{d3}', '\u{d4}', '\u{d5}', + '\u{d6}', '\u{d7}', '\u{d8}', '\u{d9}', '\u{da}', '\u{db}', '\u{dc}', '\u{dd}', '\u{de}', + '\u{df}', '\u{e0}', '\u{e1}', '\u{e2}', '\u{e3}', '\u{e4}', '\u{e5}', '\u{e6}', '\u{e7}', + '\u{e8}', '\u{e9}', '\u{ea}', '\u{eb}', '\u{ec}', '\u{ed}', '\u{ee}', '\u{ef}', '\u{f0}', + '\u{f1}', '\u{f2}', '\u{f3}', '\u{f4}', '\u{f5}', '\u{f6}', '\u{f7}', '\u{f8}', '\u{f9}', + '\u{fa}', '\u{fb}', '\u{fc}', '\u{fd}', '\u{fe}', '\u{ff}', + ]; + + pub const ISO_8859_16: &'static [char] = &[ + '\u{0}', '\u{1}', '\u{2}', '\u{3}', '\u{4}', '\u{5}', '\u{6}', '\u{7}', '\u{8}', '\u{9}', + '\u{a}', '\u{b}', '\u{c}', '\u{d}', '\u{e}', '\u{f}', '\u{10}', '\u{11}', '\u{12}', + '\u{13}', '\u{14}', '\u{15}', '\u{16}', '\u{17}', '\u{18}', '\u{19}', '\u{1a}', '\u{1b}', + '\u{1c}', '\u{1d}', '\u{1e}', '\u{1f}', '\u{20}', '\u{21}', '\u{22}', '\u{23}', '\u{24}', + '\u{25}', '\u{26}', '\u{27}', '\u{28}', '\u{29}', '\u{2a}', '\u{2b}', '\u{2c}', '\u{2d}', + '\u{2e}', '\u{2f}', '\u{30}', '\u{31}', '\u{32}', '\u{33}', '\u{34}', '\u{35}', '\u{36}', + '\u{37}', '\u{38}', '\u{39}', '\u{3a}', '\u{3b}', '\u{3c}', '\u{3d}', '\u{3e}', '\u{3f}', + '\u{40}', '\u{41}', '\u{42}', '\u{43}', '\u{44}', '\u{45}', '\u{46}', '\u{47}', '\u{48}', + '\u{49}', '\u{4a}', '\u{4b}', '\u{4c}', '\u{4d}', '\u{4e}', '\u{4f}', '\u{50}', '\u{51}', + '\u{52}', '\u{53}', '\u{54}', '\u{55}', '\u{56}', '\u{57}', '\u{58}', '\u{59}', '\u{5a}', + '\u{5b}', '\u{5c}', '\u{5d}', '\u{5e}', '\u{5f}', '\u{60}', '\u{61}', '\u{62}', '\u{63}', + '\u{64}', '\u{65}', '\u{66}', '\u{67}', '\u{68}', '\u{69}', '\u{6a}', '\u{6b}', '\u{6c}', + '\u{6d}', '\u{6e}', '\u{6f}', '\u{70}', '\u{71}', '\u{72}', '\u{73}', '\u{74}', '\u{75}', + '\u{76}', '\u{77}', '\u{78}', '\u{79}', '\u{7a}', '\u{7b}', '\u{7c}', '\u{7d}', '\u{7e}', + '\u{7f}', '\u{80}', '\u{81}', '\u{82}', '\u{83}', '\u{84}', '\u{85}', '\u{86}', '\u{87}', + '\u{88}', '\u{89}', '\u{8a}', '\u{8b}', '\u{8c}', '\u{8d}', '\u{8e}', '\u{8f}', '\u{90}', + '\u{91}', '\u{92}', '\u{93}', '\u{94}', '\u{95}', '\u{96}', '\u{97}', '\u{98}', '\u{99}', + '\u{9a}', '\u{9b}', '\u{9c}', '\u{9d}', '\u{9e}', '\u{9f}', '\u{a0}', '\u{104}', '\u{105}', + '\u{141}', '\u{20ac}', '\u{ab}', '\u{160}', '\u{a7}', '\u{161}', '\u{a9}', '\u{218}', + '\u{201e}', '\u{179}', '\u{ad}', '\u{17a}', '\u{17b}', '\u{b0}', '\u{b1}', '\u{10c}', + '\u{142}', '\u{17d}', '\u{201d}', '\u{b6}', '\u{b7}', '\u{17e}', '\u{10d}', '\u{219}', + '\u{bb}', '\u{152}', '\u{153}', '\u{178}', '\u{17c}', '\u{c0}', '\u{c1}', '\u{c2}', + '\u{102}', '\u{c4}', '\u{106}', '\u{c6}', '\u{c7}', '\u{c8}', '\u{c9}', '\u{ca}', '\u{cb}', + '\u{cc}', '\u{cd}', '\u{ce}', '\u{cf}', '\u{110}', '\u{143}', '\u{d2}', '\u{d3}', '\u{d4}', + '\u{150}', '\u{d6}', '\u{15a}', '\u{170}', '\u{d9}', '\u{da}', '\u{db}', '\u{dc}', + '\u{118}', '\u{21a}', '\u{df}', '\u{e0}', '\u{e1}', '\u{e2}', '\u{103}', '\u{e4}', + '\u{107}', '\u{e6}', '\u{e7}', '\u{e8}', '\u{e9}', '\u{ea}', '\u{eb}', '\u{ec}', '\u{ed}', + '\u{ee}', '\u{ef}', '\u{111}', '\u{144}', '\u{f2}', '\u{f3}', '\u{f4}', '\u{151}', + '\u{f6}', '\u{15b}', '\u{171}', '\u{f9}', '\u{fa}', '\u{fb}', '\u{fc}', '\u{119}', + '\u{21b}', '\u{ff}', + ]; +} + diff --git a/src/decoders/mod.rs b/src/decoders/mod.rs new file mode 100644 index 0000000..6855132 --- /dev/null +++ b/src/decoders/mod.rs @@ -0,0 +1,14 @@ +pub mod quoted_printable; +pub mod base64; +pub mod charsets; + +pub enum DecoderResult<'x> { + Byte(u8), + ByteArray(&'x [u8]), + NeedData, + Error +} + +pub trait Decoder { + fn ingest(&mut self, ch: u8) -> DecoderResult; +} diff --git a/src/decoders/quoted_printable.rs b/src/decoders/quoted_printable.rs new file mode 100644 index 0000000..02986c8 --- /dev/null +++ b/src/decoders/quoted_printable.rs @@ -0,0 +1,182 @@ +use super::{Decoder, DecoderResult}; + +enum QuotedPrintableState { + None, + Eq, + Hex1, +} + +pub struct QuotedPrintableDecoder { + state: QuotedPrintableState, + hex_1: i8, +} + +impl QuotedPrintableDecoder { + pub fn new() -> QuotedPrintableDecoder { + QuotedPrintableDecoder { + state: QuotedPrintableState::None, + hex_1: 0, + } + } +} + +impl Decoder for QuotedPrintableDecoder { + fn ingest(&mut self, ch: u8) -> DecoderResult { + match ch { + b'=' => { + // = + if let QuotedPrintableState::None = self.state { + self.state = QuotedPrintableState::Eq; + } else { + return DecoderResult::Error; + } + } + b'\n' => { + // \n + match self.state { + QuotedPrintableState::Eq => { + self.state = QuotedPrintableState::None; + } + QuotedPrintableState::Hex1 => { + return DecoderResult::Error; + } + QuotedPrintableState::None => { + return DecoderResult::Byte(b'\n'); + } + } + } + b'\r' | b'\t' => (), // \r + b' '..=b'~' => match self.state { + QuotedPrintableState::None => { + return DecoderResult::Byte(ch); + } + QuotedPrintableState::Eq => { + self.hex_1 = unsafe { *HEX_MAP.get_unchecked(ch as usize) }; + if self.hex_1 == -1 { + return DecoderResult::Error; + } else { + self.state = QuotedPrintableState::Hex1; + } + } + QuotedPrintableState::Hex1 => { + let hex2 = unsafe { *HEX_MAP.get_unchecked(ch as usize) }; + + self.state = QuotedPrintableState::None; + if hex2 == -1 { + return DecoderResult::Error; + } else { + return DecoderResult::Byte(((self.hex_1 as u8) << 4) | hex2 as u8); + } + } + }, + _ => { + if let QuotedPrintableState::None = self.state { + return DecoderResult::Byte(b'!'); + } else { + return DecoderResult::Error; + } + } + } + + DecoderResult::NeedData + } +} + +#[cfg(test)] +mod tests { + use crate::decoders::{quoted_printable::QuotedPrintableDecoder, Decoder, DecoderResult}; + + #[test] + fn decode_success() { + let input = [ + b"J'interdis aux marchands de vanter trop leurs marchandises. ".to_vec(), + b"Car ils se font=\nvite p=C3=A9dagogues et t'enseignent comme but ce ".to_vec(), + b"qui n'est par essence qu=\n'un moyen, et te trompant ainsi sur la route ".to_vec(), + b"=C3=A0 suivre les voil=C3=\n=A0 bient=C3=B4t qui te d=C3=A9gradent, car ".to_vec(), + b"si leur musique est vulgaire il=\ns te fabriquent pour te la vendre une ".to_vec(), + b"=C3=A2me vulgaire.\n=E2=80=94=E2=80=89Antoine de Saint-Exup=C3=A9ry, ".to_vec(), + b"Citadelle (1948)".to_vec(), + ] + .concat(); + let mut decoder = QuotedPrintableDecoder::new(); + let mut result = Vec::new(); + + for ch in input { + match decoder.ingest(ch) { + DecoderResult::Byte(val) => { + result.push(val); + } + DecoderResult::NeedData => (), + _ => { + assert!(false, "Error decoding."); + } + } + } + + assert_eq!( + std::str::from_utf8(&result[..]).unwrap(), + concat!( + "J'interdis aux marchands de vanter trop leurs marchandises. ", + "Car ils se fontvite pédagogues et t'enseignent comme but ce qui ", + "n'est par essence qu'un moyen, et te trompant ainsi sur la route ", + "à suivre les voilà bientôt qui te dégradent, car si leur musique ", + "est vulgaire ils te fabriquent pour te la vendre une âme vulgaire.\n", + "— Antoine de Saint-Exupéry, Citadelle (1948)" + ) + ); + } + + #[test] + fn decode_invalid() { + let inputs = [ + b"=2=123".to_vec(), + b"= 20".to_vec(), + b"=====".to_vec(), + b"=20=20=XX".to_vec(), + b"=AX".to_vec(), + b"=\n=\n==".to_vec(), + b"=\r=1z".to_vec(), + b"=|".to_vec(), + ]; + + for input in inputs { + let mut failed = false; + let mut decoder = QuotedPrintableDecoder::new(); + + for ch in &input { + match decoder.ingest(*ch) { + DecoderResult::Byte(_) | DecoderResult::NeedData => (), + DecoderResult::ByteArray(_) => { + assert!(false, "Error decoding."); + } + DecoderResult::Error => { + failed = true; + break; + } + } + } + + assert_eq!(failed, true, "{}", std::str::from_utf8(&input[..]).unwrap()); + } + } +} + +/* + * Adapted from Daniel Lemire's source: + * https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2019/04/17/hexparse.cpp + * + */ + +static HEX_MAP: &'static [i8] = &[ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, + 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +]; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..06df424 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,223 @@ +use std::{ + borrow::{BorrowMut, Cow}, + error::Error +}; + +/* + +"Date:" date-time CRLF +"From:" mailbox-list CRLF +"Sender:" mailbox CRLF +"Reply-To:" address-list CRLF +"To:" address-list CRLF +"Cc:" address-list CRLF +"Bcc:" [address-list / CFWS] CRLF +"Message-ID:" msg-id CRLF +"In-Reply-To:" 1*msg-id CRLF +"References:" 1*msg-id CRLF +"Subject:" unstructured CRLF +"Comments:" unstructured CRLF +"Keywords:" phrase *("," phrase) CRLF +"Resent-Date:" date-time CRLF +"Resent-From:" mailbox-list CRLF +"Resent-Sender:" mailbox CRLF +"Resent-To:" address-list CRLF +"Resent-Cc:" address-list CRLF +"Resent-Bcc:" [address-list / CFWS] CRLF +"Resent-Message-ID:" msg-id CRLF +"Return-Path:" path CRLF +"Received:" *received-token ";" date-time CRLF +Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08j34c0p +Content-transfer-encoding: base64 +"Content-ID" ":" msg-id + + + +*/ + +mod parsers; +mod decoders; + + + +/*struct Message<'x> { + headers: Vec>, +}*/ +use crate::parsers::message_stream::MessageStream; +use crate::parsers::header::Header; + +static HEX_TO_VAL: &'static [i8] = &[ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, + 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1]; + + +fn main() { + let mut mail = concat!( + "Subject: This is a test email\n", + "Content-Type: multipart/alternative; boundary=foobar\n", + "Date: Sun, 02 Oct 2016 07:06:22 -0700 (PDT)\n", + "\n", + "--foobar\n", + "Content-Type: text/plain; charset=utf-8\n", + "Content-Transfer-Encoding: quoted-printable\n", + "\n", + "This is the plaintext version, in utf-8. Proof by Euro: =E2=82=AC\n", + "--foobar\n", + "Content-Type: text/html\n", + "Content-Transfer-Encoding: base64\n", + "\n", + "PGh0bWw+PGJvZHk+VGhpcyBpcyB0aGUgPGI+SFRNTDwvYj4gdmVyc2lvbiwgaW4g \n", + "dXMtYXNjaWkuIFByb29mIGJ5IEV1cm86ICZldXJvOzwvYm9keT48L2h0bWw+Cg== \n", + "--foobar--\n", + "After the final boundary stuff gets ignored.\n" + ) + .to_string(); + + //let mut parser = MessageStream::new(unsafe { mail.as_bytes_mut() }); + + //let hdr = Header::parse(&mut parser); + + let val = (HEX_TO_VAL['3' as usize] << 4) as u8 | HEX_TO_VAL['f' as usize] as u8; + + println!("{}", val); + + + /*static HASH_VALUES: &'static [i8] = + &[38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 0, 0, + 10, 0, 0, 5, 5, 0, 38, 5, 38, 15, + 38, 25, 38, 38, 0, 15, 10, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38]; + + for item in HASH_VALUES.into_iter().enumerate() { + let (i, x): (usize, &i8) = item; + if *x != 38 { + println!("{} => {},", i, x); + + } + }*/ + + //let part1 = std::str::from_utf8(parser.get_slice(0, 10)).unwrap(); + //let part2 = std::str::from_utf8(parser.get_slice(11, 20)).unwrap(); + + //println!("{}-{}", part1, part2 ); +} + +/* +pub fn qp_decode<'x>(stream: &'x mut MessageStream, is_header: bool) -> Option<&'x [u8]> { + let mut state: QuotedPrintableState = QuotedPrintableState::None; + let mut hex_1: i8 = 0; + let output_start = stream.begin_write(); + + while let Some(ch) = stream.next() { + match ch { + b'=' => { // = + if let QuotedPrintableState::None = state { + state = QuotedPrintableState::Eq; + } else { + break; + } + }, + b'\n' if !is_header => { // \n + match state { + QuotedPrintableState::Eq => { + state = QuotedPrintableState::None; + }, + QuotedPrintableState::Hex1 => { + break; + }, + QuotedPrintableState::None => { + stream.write(b'\n'); + } + } + }, + b'\n' if is_header => { + break; + }, + b'\r' | b'\t' => (), // \r + b'_' if is_header => { + match state { + QuotedPrintableState::None => { + stream.write(b' '); + }, + _ => { + break; + } + } + }, + b' '..=b'~' => { + match state { + QuotedPrintableState::None => { + stream.write(ch); + }, + QuotedPrintableState::Eq => { + hex_1 = unsafe{*HEX_TO_VAL.get_unchecked(ch as usize)}; + if hex_1 == -1 { + break; + } else { + state = QuotedPrintableState::Hex1; + } + }, + QuotedPrintableState::Hex1 => { + let hex2 = unsafe{*HEX_TO_VAL.get_unchecked(ch as usize)}; + + state = QuotedPrintableState::None; + if hex2 == -1 { + break; + } else { + stream.write(((hex_1 as u8) << 4) | hex2 as u8); + } + } + } + }, + _ => { + if let QuotedPrintableState::None = state { + stream.write(b'!'); + } else { + break; + } + } + } + } + + let output_end = stream.get_write_pos(); + if output_end > output_start { + return stream.get_bytes(output_start, output_end); + } else { + return None; + } +} +*/ \ No newline at end of file diff --git a/src/parsers/address.rs b/src/parsers/address.rs new file mode 100644 index 0000000..a5e3d4e --- /dev/null +++ b/src/parsers/address.rs @@ -0,0 +1,15 @@ +pub type EmailAddress<'x> = &'x str; +pub type InvalidAddress<'x> = &'x str; + +pub struct NamedAddress<'x> { + name: &'x str, + email: EmailAddress<'x>, +} + +pub enum Address<'x> { + EmailAddress(EmailAddress<'x>), + NamedAddress(NamedAddress<'x>), + InvalidAddress(InvalidAddress<'x>), +} + +pub type AddressList<'x> = Vec>; diff --git a/src/parsers/header.rs b/src/parsers/header.rs new file mode 100644 index 0000000..551dba3 --- /dev/null +++ b/src/parsers/header.rs @@ -0,0 +1,144 @@ +use crate::parsers::message_stream::MessageStream; +use crate::parsers::address::*; +pub enum Header<'x> { + Sender(Address<'x>), + From(Address<'x>), + To(AddressList<'x>), + Cc(AddressList<'x>), + Bcc(AddressList<'x>), + Subject(&'x str), + Other((&'x str, &'x str)), +} + +/* + +List-Help +List-Unsubscribe +List-Subscribe +List-Post +List-Owner +List-Archive + +*/ + +pub enum EncodingType { + QuotedPrintable, + Base64, + Bit7, + Bit8 +} + +pub struct NonAsciiText<'x> { + encoding: EncodingType, + charset: &'x [u8], + data: &'x [u8] + +} + + +impl<'x> Header<'x> { + + + + pub fn parse(s: &'x mut MessageStream) -> Option> { + let mut ch_hash_1: u8 = 0; + let mut ch_hash_2: u8 = 0; + let mut start_pos: isize = -1; + let mut end_pos: isize = -1; + + let hash_ch = |x: u8| -> u32 { + match x { + 98 | 99 | 101 | 102 | 105 | 114 => 0, + 103 | 104 | 107 => 5, + 100 | 116 => 10, + 109 | 115 => 15, + 111 => 25, + _ => 38 + } + }; + + while let Some(ch) = (*s).get_lower_char() { + match ch { + 10 => return None, + 13 | 9 | 32 => (), // CR TAB SPACE + 58 if start_pos != -1 => { // : + let field_len: u32 = (end_pos - start_pos + 1) as u32; + + if field_len >= 2 && field_len <= 25 { + let hash = field_len + hash_ch(ch_hash_2) + hash_ch(ch_hash_1); + + if hash >= 2 && hash <= 37 { + let field = (*s).get_bytes(start_pos as usize, (end_pos + 1) as usize).unwrap(); + + match hash - 2 { + 0 if field == b"cc" => { + }, + 1 if field == b"bcc" => { + }, + 7 if field == b"resent-cc" => { + }, + 8 if field == b"resent-bcc" => { + }, + 9 if field == b"resent-date" => { + }, + 10 if field == b"content-type" => { + }, + 11 if field == b"resent-sender" => { + }, + 12 if field == b"date" => { + }, + 14 if field == b"return-path" => { + }, + 16 if field == b"received" => { + }, + 17 if field == b"from" => { + }, + 18 if field == b"content-id" => { + }, + 19 if field == b"sender" => { + }, + 21 if field == b"comments" => { + }, + 23 if field == b"references" => { + }, + 24 if field == b"resent-from" => { + }, + 25 if field == b"resent-message-id" => { + }, + 26 if field == b"keywords" => { + }, + 28 if field == b"content-transfer-encoding" => { + }, + 30 if field == b"subject" => { + println!("Subject!"); + }, + 31 if field == b"reply-to" => { + }, + 32 if field == b"resent-to" => { + }, + 33 if field == b"message-id" => { + }, + 34 if field == b"in-reply-to" => { + }, + 35 if field == b"to" => { + }, + _ => () + } + } + } + }, + _ => { + if start_pos != -1 { + end_pos = (*s).get_read_pos(); + ch_hash_2 = ch; + } else { + start_pos = (*s).get_read_pos(); + end_pos = start_pos; + ch_hash_1 = ch; + } + } + } + } + None + } +} diff --git a/src/parsers/message_stream.rs b/src/parsers/message_stream.rs new file mode 100644 index 0000000..179284b --- /dev/null +++ b/src/parsers/message_stream.rs @@ -0,0 +1,92 @@ +use std::borrow::Cow; + +pub struct MessageStream<'x> { + data: &'x mut [u8], + read_pos: isize, + write_pos: usize +} + +impl<'x> MessageStream<'x> { + pub fn new(data: &mut [u8]) -> MessageStream { + MessageStream { + data: data, + read_pos: -1, + write_pos: 0 + } + } + + pub fn get_bytes(&self, from: usize, to: usize) -> Option<&[u8]> { + self.data.get(from..to) + } + + pub fn get_str_lossy(&'x self, from: usize, to: usize) -> Option> { + match self.data.get(from..to) { + Some(bytes) => Some(String::from_utf8_lossy(bytes)), + None => None, + } + } + + pub fn get_str(&'x self, from: usize, to: usize) -> Option<&str> { + match self.data.get(from..to) { + Some(bytes) => Some(unsafe { std::str::from_utf8_unchecked(bytes) }), + None => None, + } + } + + pub fn begin_write(&mut self) -> usize { + if self.read_pos > 0 { + self.write_pos = self.read_pos as usize; + } + self.write_pos + } + + pub fn write(&mut self, ch: u8) -> () { + self.data[self.write_pos] = ch; + self.write_pos = self.write_pos + 1; + } + + pub fn write_slice(&mut self, chars: &[u8]) -> () { + self.data[self.write_pos..(self.write_pos+chars.len())].copy_from_slice(chars); + self.write_pos = self.write_pos + chars.len(); + } + + #[inline(always)] + pub fn get_read_pos(&self) -> isize { + self.read_pos + } + + pub fn get_write_pos(&self) -> usize { + self.write_pos + } + + #[inline(always)] + pub fn get_lower_char(&mut self) -> Option { + self.read_pos = self.read_pos + 1; + match self.data.get_mut(self.read_pos as usize) { + Some(ch) => { + if *ch >= 65 && *ch <= 90 { + *ch = *ch + 32; + } + Some(*ch) + }, + None => None + } + } + + pub fn rewind(&mut self, read_pos: usize) -> () { + self.read_pos = self.read_pos - std::cmp::min(self.read_pos, read_pos as isize); + } +} + +impl<'x> Iterator for MessageStream<'x> { + type Item = u8; + + #[inline(always)] + fn next(&mut self) -> Option { + self.read_pos = self.read_pos + 1; + match self.data.get(self.read_pos as usize) { + Some(ch) => Some(*ch), + None => None + } + } +} diff --git a/src/parsers/mod.rs b/src/parsers/mod.rs new file mode 100644 index 0000000..ba0da6f --- /dev/null +++ b/src/parsers/mod.rs @@ -0,0 +1,5 @@ +pub mod address; +pub mod header; +pub mod message_stream; +pub mod rfc2047; + diff --git a/src/parsers/rfc2047.rs b/src/parsers/rfc2047.rs new file mode 100644 index 0000000..81f8c8f --- /dev/null +++ b/src/parsers/rfc2047.rs @@ -0,0 +1,118 @@ +use crate::parsers::message_stream::MessageStream; + +enum Rfc2047State { + Charset, + Language, + Encoding, + Data +} + +enum Rfc2047Encoding { + Invalid, + Base64, + QuotedPrintable +} + +pub fn try_decode<'x>(stream: &'x mut MessageStream) -> Option<&'x str> { + let mut charset: [u8; 10] = [0; 10]; + let mut state = Rfc2047State::Charset; + let mut encoding = Rfc2047Encoding::Invalid; + let mut pos: usize = 0; + + for mut ch in stream.by_ref() { + match state { + Rfc2047State::Charset => { + match ch { + 65..=90 => { // A-Z + ch = ch + 32; // To uppercase + }, + 97..=122 | 45 | 95 => (), // a-z - _ + 63 => { // ? + if pos > 0 { + println!("Charset: {}", unsafe { std::str::from_utf8_unchecked(&charset[0..pos]) }); + state = Rfc2047State::Encoding; + continue; + } else { + return None; + } + }, + 42 => { // * + state = Rfc2047State::Language; + continue; + }, + _ => { + //stream.rewind(1); + return None; + } + } + + // Add to charset array + match charset.get_mut(pos) { + Some(val) => { + *val = ch; + }, + None => {return None;} + } + pos = pos + 1; + }, + Rfc2047State::Language => { // Ignore language + match ch { + 65..=90 | 97..=122 | 45 | 95 => (), + 63 => { // ? + if pos > 0 { + println!("Charset: {}", unsafe { std::str::from_utf8_unchecked(&charset[0..pos]) }); + state = Rfc2047State::Encoding; + continue; + } else { + return None; + } + }, + _ => { + return None; + } + } + }, + Rfc2047State::Encoding => { + match ch { + 113 | 81 => { // q Q + if let Rfc2047Encoding::Invalid = encoding { + encoding = Rfc2047Encoding::QuotedPrintable; + } else { + return None; + } + }, + 98 | 66 => { // b B + if let Rfc2047Encoding::Invalid = encoding { + encoding = Rfc2047Encoding::Base64; + } else { + return None; + } + }, + 63 => { // ? + if let Rfc2047Encoding::Invalid = encoding { + return None; + } + state = Rfc2047State::Data; + }, + _ => { + return None; + } + } + }, + Rfc2047State::Data => { + match ch { + 63 => { // ? + + }, + 13 | 9 | 32 => (), // CR TAB SPACE + 10 => { // LF + return None; + }, + _ => () + } + } + } + } + + None +}