code93 writer + tests

This commit is contained in:
Henry Schimke
2022-12-11 10:33:19 -06:00
parent b1684ac698
commit 6e975edd3d
5 changed files with 276 additions and 251 deletions

View File

@@ -122,8 +122,8 @@ impl OneDReader for Code93Reader {
impl Code93Reader {
// Note that 'abcd' are dummy characters in place of control characters.
const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*";
const ALPHABET: [char; 48] = [
pub const ALPHABET_STRING: &str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*";
pub const ALPHABET: [char; 48] = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'-', '.', ' ', '$', '/', '+', '%', 'a', 'b', 'c', 'd', '*',
@@ -133,7 +133,7 @@ impl Code93Reader {
* These represent the encodings of characters, as patterns of wide and narrow bars.
* The 9 least-significant bits of each int correspond to the pattern of wide and narrow.
*/
const CHARACTER_ENCODINGS: [u32; 48] = [
pub const CHARACTER_ENCODINGS: [u32; 48] = [
0x114, 0x148, 0x144, 0x142, 0x128, 0x124, 0x122, 0x150, 0x112, 0x10A, // 0-9
0x1A8, 0x1A4, 0x1A2, 0x194, 0x192, 0x18A, 0x168, 0x164, 0x162, 0x134, // A-J
0x11A, 0x158, 0x14C, 0x146, 0x12C, 0x116, 0x1B4, 0x1B2, 0x1AC, 0x1A6, // K-T
@@ -141,7 +141,7 @@ impl Code93Reader {
0x12E, 0x1D4, 0x1D2, 0x1CA, 0x16E, 0x176, 0x1AE, // - - %
0x126, 0x1DA, 0x1D6, 0x132, 0x15E, // Control chars? $-*
];
const ASTERISK_ENCODING: i32 = Self::CHARACTER_ENCODINGS[47] as i32;
pub const ASTERISK_ENCODING: i32 = Self::CHARACTER_ENCODINGS[47] as i32;
pub fn new() -> Self {
Self {