diff --git a/backend/code1.c b/backend/code1.c index c3e09b54..0b1220d3 100644 --- a/backend/code1.c +++ b/backend/code1.c @@ -2,7 +2,7 @@ /* libzint - the open source barcode library - Copyright (C) 2009-2020 Robin Stuart + Copyright (C) 2009-2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -37,8 +37,16 @@ #include "large.h" #include #include +#ifdef _MSC_VER +#include +/* ceilf (C99) not before MSVC++2013 (C++ 12.0) */ +#if _MSC_VER < 1800 +#define ceilf (float) ceil +#endif +#endif -static void horiz(struct zint_symbol *symbol, int row_no, int full) { +/* Add solid bar */ +static void horiz(struct zint_symbol *symbol, const int row_no, const int full) { int i; if (full) { @@ -52,7 +60,9 @@ static void horiz(struct zint_symbol *symbol, int row_no, int full) { } } -static void central_finder(struct zint_symbol *symbol, int start_row, int row_count, int full_rows) { +/* Central recognition pattern for Versions A-H */ +static void central_finder(struct zint_symbol *symbol, const int start_row, const int row_count, + const int full_rows) { int i; for (i = 0; i < row_count; i++) { @@ -68,7 +78,8 @@ static void central_finder(struct zint_symbol *symbol, int start_row, int row_co } } -static void vert(struct zint_symbol *symbol, int column, int height, int top) { +/* Add solid column */ +static void vert(struct zint_symbol *symbol, const int column, const int height, const int top) { int i; if (top) { @@ -82,7 +93,8 @@ static void vert(struct zint_symbol *symbol, int column, int height, int top) { } } -static void spigot(struct zint_symbol *symbol, int row_no) { +/* Add bump to the right of the vertical recognition pattern column (Versions A-H) */ +static void spigot(struct zint_symbol *symbol, const int row_no) { int i; for (i = symbol->width - 1; i > 0; i--) { @@ -92,64 +104,61 @@ static void spigot(struct zint_symbol *symbol, int row_no) { } } -static int isedi(unsigned char input) { - int result = 0; - - if (input == 13) { - result = 1; +/* Is basic (non-shifted) C40? */ +static int isc40(const unsigned char input) { + if ((input >= '0' && input <= '9') || (input >= 'A' && input <= 'Z') || input == ' ') { + return 1; } - if (input == '*') { - result = 1; - } - if (input == '>') { - result = 1; - } - if (input == ' ') { - result = 1; - } - if ((input >= '0') && (input <= '9')) { - result = 1; - } - if ((input >= 'A') && (input <= 'Z')) { - result = 1; - } - - return result; + return 0; } -static int dq4bi(unsigned char source[], int sourcelen, int position) { - int i; - - for (i = 0; ((position + i) < sourcelen) && isedi(source[position + i]); i++); - - if ((position + i) == sourcelen) { - /* Reached end of input */ - return 0; - } - if (i == 0) { - /* Not EDI */ - return 0; - } - - if (source[position + i - 1] == 13) { +/* Is basic (non-shifted) TEXT? */ +static int istext(const unsigned char input) { + if ((input >= '0' && input <= '9') || (input >= 'a' && input <= 'z') || input == ' ') { return 1; } - if (source[position + i - 1] == '*') { + return 0; +} + +/* Is basic (non-shifted) C40/TEXT? */ +static int isc40text(const int current_mode, const unsigned char input) { + return current_mode == C1_C40 ? isc40(input) : istext(input); +} + +/* EDI characters are uppercase alphanumerics plus space plus EDI terminator (CR) plus 2 EDI separator chars */ +static int isedi(const unsigned char input) { + + if (isc40(input)) { return 1; } - if (source[position + i - 1] == '>') { + if (input == 13 || input == '*' || input == '>') { return 1; } return 0; } -static int c1_look_ahead_test(unsigned char source[], int sourcelen, int position, int current_mode, int gs1) { - float ascii_count, c40_count, text_count, edi_count, byte_count; - char reduced_char; - int done, best_scheme, sp; +/* Whether Step Q4bi applies, i.e. if one of the 3 EDI terminator/separator chars appears before a non-EDI char */ +static int is_step_Q4bi_applicable(const unsigned char source[], const int sourcelen, const int position) { + int i; - /* Step J */ + for (i = position; i < sourcelen && isedi(source[i]); i++) { + if (source[i] == 13 || source[i] == '*' || source[i] == '>') { + return 1; + } + } + + return 0; +} + +/* AIM USS Code One Annex D Steps J-R */ +static int c1_look_ahead_test(const unsigned char source[], const int sourcelen, const int position, + const int current_mode, const int gs1) { + float ascii_count, c40_count, text_count, edi_count, byte_count; + int ascii_rnded, c40_rnded, text_rnded, edi_rnded, byte_rnded; + int sp; + + /* Step J1 */ if (current_mode == C1_ASCII) { ascii_count = 0.0f; c40_count = 1.0f; @@ -165,211 +174,324 @@ static int c1_look_ahead_test(unsigned char source[], int sourcelen, int positio } switch (current_mode) { - case C1_C40: c40_count = 0.0f; + case C1_C40: c40_count = 0.0f; /* Step J2 */ break; - case C1_TEXT: text_count = 0.0f; + case C1_TEXT: text_count = 0.0f; /* Step J3 */ break; - case C1_BYTE: byte_count = 0.0f; + case C1_EDI: edi_count = 0.0f; /* Missing in spec */ break; - case C1_EDI: edi_count = 0.0f; + case C1_BYTE: byte_count = 0.0f; /* Step J4 */ break; } - for (sp = position; (sp < sourcelen) && (sp <= (position + 8)); sp++) { - - if (source[sp] <= 127) { - reduced_char = source[sp]; - } else { - reduced_char = source[sp] - 127; - } + for (sp = position; sp < sourcelen; sp++) { /* Step L */ if ((source[sp] >= '0') && (source[sp] <= '9')) { - ascii_count += 0.5f; + ascii_count += 0.5f; /* Step L1 */ } else { - ascii_count = (float) ceil(ascii_count); if (source[sp] > 127) { - ascii_count += 2.0f; + ascii_count = ceilf(ascii_count) + 2.0f; /* Step L2 */ } else { - ascii_count += 1.0f; + ascii_count = ceilf(ascii_count) + 1.0f; /* Step L3 */ } } /* Step M */ - done = 0; - if (reduced_char == ' ') { - c40_count += (2.0f / 3.0f); - done = 1; - } - if ((reduced_char >= '0') && (reduced_char <= '9')) { - c40_count += (2.0f / 3.0f); - done = 1; - } - if ((reduced_char >= 'A') && (reduced_char <= 'Z')) { - c40_count += (2.0f / 3.0f); - done = 1; - } - if (source[sp] > 127) { - c40_count += (4.0f / 3.0f); - } - if (done == 0) { - c40_count += (4.0f / 3.0f); + if (isc40(source[sp])) { + c40_count += (2.0f / 3.0f); /* Step M1 */ + } else if (source[sp] > 127) { + c40_count += (8.0f / 3.0f); /* Step M2 */ + } else { + c40_count += (4.0f / 3.0f); /* Step M3 */ } /* Step N */ - done = 0; - if (reduced_char == ' ') { - text_count += (2.0f / 3.0f); - done = 1; - } - if ((reduced_char >= '0') && (reduced_char <= '9')) { - text_count += (2.0f / 3.0f); - done = 1; - } - if ((reduced_char >= 'a') && (reduced_char <= 'z')) { - text_count += (2.0f / 3.0f); - done = 1; - } - if (source[sp] > 127) { - text_count += (4.0f / 3.0f); - } - if (done == 0) { - text_count += (4.0f / 3.0f); + if (istext(source[sp])) { + text_count += (2.0f / 3.0f); /* Step N1 */ + } else if (source[sp] > 127) { + text_count += (8.0f / 3.0f); /* Step N2 */ + } else { + text_count += (4.0f / 3.0f); /* Step N3 */ } /* Step O */ - done = 0; - if (source[sp] == 13) { - edi_count += (2.0f / 3.0f); - done = 1; - } - if (source[sp] == '*') { - edi_count += (2.0f / 3.0f); - done = 1; - } - if (source[sp] == '>') { - edi_count += (2.0f / 3.0f); - done = 1; - } - if (source[sp] == ' ') { - edi_count += (2.0f / 3.0f); - done = 1; - } - if ((source[sp] >= '0') && (source[sp] <= '9')) { - edi_count += (2.0f / 3.0f); - done = 1; - } - if ((source[sp] >= 'A') && (source[sp] <= 'Z')) { - edi_count += (2.0f / 3.0f); - done = 1; - } - if (source[sp] > 127) { - edi_count += (13.0f / 3.0f); + if (isedi(source[sp])) { + edi_count += (2.0f / 3.0f); /* Step O1 */ + } else if (source[sp] > 127) { + edi_count += (13.0f / 3.0f); /* Step O2 */ } else { - if (done == 0) { - edi_count += (10.0f / 3.0f); - } + edi_count += (10.0f / 3.0f); /* Step O3 */ } /* Step P */ if (gs1 && (source[sp] == '[')) { - byte_count += 3.0f; + byte_count += 3.0f; /* Step P1 */ } else { - byte_count += 1.0f; + byte_count += 1.0f; /* Step P2 */ } - } + /* If not end of data and at least 4 characters processed */ + /* NOTE: different than spec, where it's at least 3, but that ends up suppressing C40/TEXT/EDI. + BWIPP uses 4, as does very similar Data Matrix ISO/IEC 16022:2006 Annex P algorithm */ + if (sp + 1 != sourcelen && sp >= position + 3) { + /* Step Q */ + float cnt; + ascii_rnded = (int) ceilf(ascii_count); + c40_rnded = (int) ceilf(c40_count); + text_rnded = (int) ceilf(text_count); + edi_rnded = (int) ceilf(edi_count); + byte_rnded = (int) ceilf(byte_count); - ascii_count = (float) ceil(ascii_count); - c40_count = (float) ceil(c40_count); - text_count = (float) ceil(text_count); - edi_count = (float) ceil(edi_count); - byte_count = (float) ceil(byte_count); - best_scheme = C1_ASCII; - - if (sp == sourcelen) { - /* Step K */ - int best_count = (int) edi_count; - - if (text_count <= best_count) { - best_count = (int) text_count; - best_scheme = C1_TEXT; - } - - if (c40_count <= best_count) { - best_count = (int) c40_count; - best_scheme = C1_C40; - } - - if (ascii_count <= best_count) { - best_count = (int) ascii_count; - best_scheme = C1_ASCII; - } - - if (byte_count <= best_count) { - // best_count = (int) byte_count; - best_scheme = C1_BYTE; - } - } else { - /* Step Q */ - - if (((edi_count + 1.0f <= ascii_count) && (edi_count + 1.0f <= c40_count)) && - ((edi_count + 1.0f <= byte_count) && (edi_count + 1.0f <= text_count))) { - best_scheme = C1_EDI; - } - - if ((c40_count + 1.0f <= ascii_count) && (c40_count + 1.0f <= text_count)) { - - if (c40_count < edi_count) { - best_scheme = C1_C40; - } else { - if (c40_count == edi_count) { - if (dq4bi(source, sourcelen, position)) { - best_scheme = C1_EDI; - } else { - best_scheme = C1_C40; + cnt = byte_count + 1.0f; + if (cnt <= ascii_rnded && cnt <= c40_rnded && cnt <= text_rnded && cnt <= edi_rnded) { + return C1_BYTE; /* Step Q1 */ + } + cnt = ascii_count + 1.0f; + if (cnt <= c40_rnded && cnt <= text_rnded && cnt <= edi_rnded && cnt <= byte_rnded) { + return C1_ASCII; /* Step Q2 */ + } + cnt = text_rnded + 1.0f; + if (cnt <= ascii_rnded && cnt <= c40_rnded && cnt <= edi_rnded && cnt <= byte_rnded) { + return C1_TEXT; /* Step Q3 */ + } + cnt = c40_rnded + 1.0f; + if (cnt <= ascii_rnded && cnt <= text_rnded) { + /* Step Q4 */ + if (c40_rnded < edi_rnded) { + return C1_C40; /* Step Q4a */ + } + if (c40_rnded == edi_rnded) { + /* Step Q4b */ + if (is_step_Q4bi_applicable(source, sourcelen, sp + 1)) { + return C1_EDI; /* Step Q4bi */ } + return C1_C40; /* Step Q4bii */ } } - } - - if (((text_count + 1.0f <= ascii_count) && (text_count + 1.0f <= c40_count)) && - ((text_count + 1.0f <= byte_count) && (text_count + 1.0f <= edi_count))) { - best_scheme = C1_TEXT; - } - - if (((ascii_count + 1.0f <= byte_count) && (ascii_count + 1.0f <= c40_count)) && - ((ascii_count + 1.0f <= text_count) && (ascii_count + 1.0f <= edi_count))) { - best_scheme = C1_ASCII; - } - - if (((byte_count + 1.0f <= ascii_count) && (byte_count + 1.0f <= c40_count)) && - ((byte_count + 1.0f <= text_count) && (byte_count + 1.0f <= edi_count))) { - best_scheme = C1_BYTE; + cnt = edi_rnded + 1.0f; + if (cnt <= ascii_rnded && cnt <= c40_rnded && cnt <= text_rnded && cnt <= byte_rnded) { + return C1_EDI; /* Step Q5 */ + } } } - return best_scheme; + /* Step K */ + ascii_rnded = (int) ceilf(ascii_count); + c40_rnded = (int) ceilf(c40_count); + text_rnded = (int) ceilf(text_count); + edi_rnded = (int) ceilf(edi_count); + byte_rnded = (int) ceilf(byte_count); + + if (byte_count <= ascii_rnded && byte_count <= c40_rnded && byte_count <= text_rnded && byte_count <= edi_rnded) { + return C1_BYTE; /* Step K1 */ + } + if (ascii_count <= c40_rnded && ascii_count <= text_rnded && ascii_count <= edi_rnded + && ascii_count <= byte_rnded) { + return C1_ASCII; /* Step K2 */ + } + if (c40_rnded <= text_rnded && c40_rnded <= edi_rnded) { + return C1_C40; /* Step K3 */ + } + if (text_rnded <= edi_rnded) { + return C1_TEXT; /* Step K4 */ + } + + return C1_EDI; /* Step K5 */ } -static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int target[], int length) { +/* Whether can fit last character or characters in a single ASCII codeword */ +static int is_last_single_ascii(const unsigned char string[], const int length, const int sp) { + if (length - sp == 1 && string[sp + 1] <= 127) { + return 1; + } + if (length - sp == 2 && istwodigits(string, length, sp)) { + return 1; + } + return 0; +} + +/* Return length of numeric sequence from position `sp`, stopping after `max` if given (non-zero) */ +static int digits_ahead(const unsigned char string[], const int length, const int sp, const int max) { + int i, end; + if (max && sp + max < length) { + end = sp + max; + } else { + end = length; + } + for (i = sp; i < end; i++) { + if (string[i] < '0' || string[i] > '9') { + break; + } + } + return i - sp; +} + +/* Copy C40/TEXT/EDI triplets from buffer to target. Returns elements left in buffer (< 3) */ +static int cte_buffer_transfer(int cte_buffer[6], int cte_p, unsigned target[], int *p_tp) { + int cte_i, cte_e; + int tp = *p_tp; + + cte_e = (cte_p / 3) * 3; + + for (cte_i = 0; cte_i < cte_e; cte_i += 3) { + int iv = (1600 * cte_buffer[cte_i]) + (40 * cte_buffer[cte_i + 1]) + (cte_buffer[cte_i + 2]) + 1; + target[tp++] = iv >> 8; + target[tp++] = iv & 0xFF; + } + + cte_p -= cte_e; + + if (cte_p) { + memmove(cte_buffer, cte_buffer + cte_e, sizeof(int) * cte_p); + } + + *p_tp = tp; + + return cte_p; +} + +/* Copy DECIMAL bytes to target. Returns bits left in buffer (< 8) */ +static int decimal_binary_transfer(char decimal_binary[24], int db_p, unsigned int target[], int *p_tp) { + int b_i, b_e, p; + int tp = *p_tp; + + /* Transfer full bytes to target */ + b_e = db_p & 0xF8; + + for (b_i = 0; b_i < b_e; b_i += 8) { + int value = 0; + for (p = 0; p < 8; p++) { + value <<= 1; + value += decimal_binary[b_i + p] == '1'; + } + target[tp++] = value; + } + + db_p &= 0x07; /* Bits remaining */ + + if (db_p) { + memmove(decimal_binary, decimal_binary + b_e, db_p); + } + + *p_tp = tp; + + return db_p; +} + +/* Unlatch to ASCII from DECIMAL mode using 6 ones flag. DECIMAL binary buffer will be empty */ +static int decimal_unlatch(char decimal_binary[24], int db_p, unsigned int target[], int *p_tp, + const int decimal_count, const unsigned char *source, int *p_sp) { + int sp = *p_sp; + int bits_left; + + db_p = bin_append_posn(63, 6, decimal_binary, db_p); /* Unlatch */ + if (db_p >= 8) { + db_p = decimal_binary_transfer(decimal_binary, db_p, target, p_tp); + } + bits_left = (8 - db_p) & 0x07; + if (decimal_count >= 1 && bits_left >= 4) { + db_p = bin_append_posn(ctoi(source[sp]) + 1, 4, decimal_binary, db_p); + sp++; + if (bits_left == 6) { + db_p = bin_append_posn(1, 2, decimal_binary, db_p); + } + (void)decimal_binary_transfer(decimal_binary, db_p, target, p_tp); + + } else if (bits_left) { + if (bits_left >= 4) { + db_p = bin_append_posn(15, 4, decimal_binary, db_p); + } + if (bits_left == 2 || bits_left == 6) { + db_p = bin_append_posn(1, 2, decimal_binary, db_p); + } + (void)decimal_binary_transfer(decimal_binary, db_p, target, p_tp); + } + + *p_sp = sp; + + return 0; +} + +/* Number of codewords remaining in a particular version (may be negative) */ +static int codewords_remaining(struct zint_symbol *symbol, int tp) { + int i; + + if (symbol->option_2 == 10) { /* Version T */ + if (tp > 24) { + return 38 - tp; + } + if (tp > 10) { + return 24 - tp; + } + return 10 - tp; + } + /* Versions A to H */ + for (i = 6; i >= 0; i--) { + if (tp > c1_data_length[i]) { + return c1_data_length[i + 1] - tp; + } + } + return c1_data_length[0] - tp; +} + +/* Number of C40/TEXT elements needed to encode `input` */ +static int c40text_cnt(const int current_mode, const int gs1, unsigned char input) { + int cnt; + + if (gs1 && input == '[') { + return 2; + } + cnt = 1; + if (input > 127) { + cnt += 2; + input = input - 128; + } + if ((current_mode == C1_C40 && c40_shift[input]) || (current_mode == C1_TEXT && text_shift[input])) { + cnt += 1; + } + + return cnt; +} + +/* Copy `source` to `eci_buf` with "\NNNNNN" ECI indicator at start and backslashes escaped */ +static void eci_escape(const int eci, unsigned char *source, const int length, unsigned char *eci_buf, const int eci_length) { + int i, j; + + j = sprintf((char *) eci_buf, "\\%06d", eci); + + for (i = 0; i < length && j < eci_length; i++) { + if (source[i] == '\\') { + eci_buf[j++] = '\\'; + } + eci_buf[j++] = source[i]; + } + eci_buf[j] = '\0'; +} + +/* Convert to codewords */ +static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigned int target[], int length, + int *p_last_mode) { int current_mode, next_mode; - int sp, tp, gs1, i, j, p, latch; - int c40_buffer[6], c40_p; - int text_buffer[6], text_p; - int edi_buffer[6], edi_p; - char decimal_binary[40]; + int sp, tp, gs1, i; + int cte_buffer[6], cte_p = 0; /* C1_C40/TEXT/EDI buffer and index */ + char decimal_binary[24]; /* C1_DECIMAL buffer */ + int db_p = 0; int byte_start = 0; + int debug_print = symbol->debug & ZINT_DEBUG_PRINT; + int eci_length = length + 7 + chr_cnt(source, length, '\\'); +#ifndef _MSC_VER + unsigned char eci_buf[eci_length + 1]; +#else + unsigned char *eci_buf = (unsigned char *) _alloca(eci_length + 1); +#endif sp = 0; tp = 0; - memset(c40_buffer, 0, sizeof(*c40_buffer)); - c40_p = 0; - memset(text_buffer, 0, sizeof(*text_buffer)); - text_p = 0; - memset(edi_buffer, 0, sizeof(*edi_buffer)); - edi_p = 0; - strcpy(decimal_binary, ""); + + /* Step A */ + current_mode = C1_ASCII; + next_mode = C1_ASCII; if ((symbol->input_mode & 0x07) == GS1_MODE) { gs1 = 1; @@ -377,133 +499,75 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne gs1 = 0; } if (gs1) { - /* FNC1 */ - target[tp] = 232; - tp++; + if (length >= 15 && digits_ahead(source, length, 0, 15) == 15) { + target[tp++] = 236; /* FNC1 and change to Decimal */ + next_mode = C1_DECIMAL; + } else if (length >= 7 && digits_ahead(source, length, 0, 0) == length) { + target[tp++] = 236; /* FNC1 and change to Decimal */ + next_mode = C1_DECIMAL; + } else { + target[tp++] = 232; /* FNC1 */ + } + /* Note ignoring ECI if GS1 mode (up to caller to warn) */ + } else if (symbol->eci) { + target[tp++] = 129; /* Pad */ + target[tp++] = '\\' + 1; /* Escape char */ + eci_escape(symbol->eci, source, length, eci_buf, eci_length); + source = eci_buf; + length = eci_length; } - /* Step A */ - current_mode = C1_ASCII; - next_mode = C1_ASCII; - do { if (current_mode != next_mode) { /* Change mode */ switch (next_mode) { - case C1_C40: target[tp] = 230; - tp++; + case C1_C40: target[tp++] = 230; break; - case C1_TEXT: target[tp] = 239; - tp++; + case C1_TEXT: target[tp++] = 239; break; - case C1_EDI: target[tp] = 238; - tp++; + case C1_EDI: target[tp++] = 238; break; - case C1_BYTE: target[tp] = 231; - tp++; + case C1_BYTE: target[tp++] = 231; + byte_start = tp; + target[tp++] = 0; /* Byte count holder (may be expanded to 2 codewords) */ break; } + current_mode = next_mode; } - if ((current_mode != C1_BYTE) && (next_mode == C1_BYTE)) { - byte_start = tp; - } - current_mode = next_mode; - if (current_mode == C1_ASCII) { /* Step B - ASCII encodation */ next_mode = C1_ASCII; - if ((length - sp) >= 21) { + if ((length - sp) >= 21 && digits_ahead(source, length, sp, 21) == 21) { /* Step B1 */ - j = 0; - - for (i = 0; i < 21; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 21) { - next_mode = C1_DECIMAL; - bin_append(15, 4, decimal_binary); - } - } - - if ((next_mode == C1_ASCII) && ((length - sp) >= 13)) { + next_mode = C1_DECIMAL; + db_p = bin_append_posn(15, 4, decimal_binary, db_p); + } else if ((length - sp) >= 13 && digits_ahead(source, length, sp, 0) == (length - sp)) { /* Step B2 */ - j = 0; - - for (i = 0; i < 13; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 13) { - latch = 0; - for (i = sp + 13; i < length; i++) { - if (!((source[i] >= '0') && (source[i] <= '9'))) { - latch = 1; - } - } - - if (!(latch)) { - next_mode = C1_DECIMAL; - bin_append(15, 4, decimal_binary); - } - } + next_mode = C1_DECIMAL; + db_p = bin_append_posn(15, 4, decimal_binary, db_p); } - if (next_mode == C1_ASCII) { /* Step B3 */ + if (next_mode == C1_ASCII) { if (istwodigits(source, length, sp)) { - target[tp] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130; - tp++; + if (debug_print) printf("ASCII double-digits "); + + /* Step B3 */ + target[tp++] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130; sp += 2; } else { if ((gs1) && (source[sp] == '[')) { - if ((length - sp) >= 15) { + if (length - (sp + 1) >= 15 && digits_ahead(source, length, sp + 1, 15) == 15) { /* Step B4 */ - j = 0; - - for (i = 0; i < 15; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 15) { - target[tp] = 236; /* FNC1 and change to Decimal */ - tp++; - sp++; - next_mode = C1_DECIMAL; - } - } - - if ((length - sp) >= 7) { /* Step B5 */ - j = 0; - - for (i = 0; i < 7; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 7) { - latch = 0; - for (i = sp + 7; i < length; i++) { - if (!((source[i] >= '0') && (source[i] <= '9'))) { - latch = 1; - } - } - - if (!(latch)) { - target[tp] = 236; /* FNC1 and change to Decimal */ - tp++; - sp++; - next_mode = C1_DECIMAL; - } - } + target[tp++] = 236; /* FNC1 and change to Decimal */ + sp++; + next_mode = C1_DECIMAL; + } else if (length - (sp + 1) >= 7 && digits_ahead(source, length, sp + 1, 0) == length - (sp + 1)) { + /* Step B5 */ + target[tp++] = 236; /* FNC1 and change to Decimal */ + sp++; + next_mode = C1_DECIMAL; } } @@ -513,470 +577,184 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1); if (next_mode == C1_ASCII) { + if (debug_print) printf("ASCII "); + if (source[sp] > 127) { /* Step B7 */ - target[tp] = 235; /* FNC4 */ - tp++; - target[tp] = (source[sp] - 128) + 1; - tp++; - sp++; + target[tp++] = 235; /* FNC4 (Upper Shift) */ + target[tp++] = (source[sp] - 128) + 1; + } else if ((gs1) && (source[sp] == '[')) { + /* Step B8 */ + target[tp++] = 232; /* FNC1 */ } else { /* Step B8 */ - if ((gs1) && (source[sp] == '[')) { - target[tp] = 232; /* FNC1 */ - tp++; - sp++; - } else { - target[tp] = source[sp] + 1; - tp++; - sp++; - } + target[tp++] = source[sp] + 1; } + sp++; } } } } - } - if (current_mode == C1_C40) { - /* Step C - C40 encodation */ + } else if (current_mode == C1_C40 || current_mode == C1_TEXT) { + /* Step C/D - C40/TEXT encodation */ - next_mode = C1_C40; - if (c40_p == 0) { - int done = 0; - if ((length - sp) >= 12) { - j = 0; - - for (i = 0; i < 12; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 12) { - next_mode = C1_ASCII; - done = 1; - } - } - - if ((length - sp) >= 8) { - j = 0; - - for (i = 0; i < 8; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if ((length - sp) == 8) { - latch = 1; - } else { - latch = 1; - for (j = sp + 8; j < length; j++) { - if ((source[j] <= '0') || (source[j] >= '9')) { - latch = 0; - } - } - } - - if ((j == 8) && latch) { - next_mode = C1_ASCII; - done = 1; - } - } - - if (!(done)) { + next_mode = current_mode; + if (cte_p == 0) { + /* Step C/D1 */ + if ((length - sp) >= 12 && digits_ahead(source, length, sp, 12) == 12) { + /* Step C/D1a */ + next_mode = C1_ASCII; + } else if ((length - sp) >= 8 && digits_ahead(source, length, sp, 0) == (length - sp)) { + /* Step C/D1b */ + next_mode = C1_ASCII; + } else { next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1); } } - if (next_mode != C1_C40) { - target[tp] = 255; /* Unlatch */ - tp++; + if (next_mode != current_mode) { + /* Step C/D1c */ + target[tp++] = 255; /* Unlatch */ } else { - int shift_set, value; - if (source[sp] > 127) { - c40_buffer[c40_p] = 1; - c40_p++; - c40_buffer[c40_p] = 30; /* Upper Shift */ - c40_p++; - shift_set = c40_shift[source[sp] - 128]; - value = c40_value[source[sp] - 128]; + /* Step C/D2 */ + const char *ct_shift, *ct_value; + + if (current_mode == C1_C40) { + ct_shift = c40_shift; + ct_value = c40_value; } else { - shift_set = c40_shift[source[sp]]; - value = c40_value[source[sp]]; + ct_shift = text_shift; + ct_value = text_value; + } + if (debug_print) printf(current_mode == C1_C40 ? "C40 " : "TEXT "); + + if (source[sp] > 127) { + cte_buffer[cte_p++] = 1; /* Shift 2 */ + cte_buffer[cte_p++] = 30; /* FNC4 (Upper Shift) */ + if (ct_shift[source[sp] - 128]) { + cte_buffer[cte_p++] = ct_shift[source[sp] - 128] - 1; + } + cte_buffer[cte_p++] = ct_value[source[sp] - 128]; + } else if (gs1 && (source[sp] == '[')) { + cte_buffer[cte_p++] = 1; /* Shift 2 */ + cte_buffer[cte_p++] = 27; /* FNC1 */ + } else { + if (ct_shift[source[sp]]) { + cte_buffer[cte_p++] = ct_shift[source[sp]] - 1; + } + cte_buffer[cte_p++] = ct_value[source[sp]]; } - if (gs1 && (source[sp] == '[')) { - shift_set = 2; - value = 27; /* FNC1 */ - } - - if (shift_set != 0) { - c40_buffer[c40_p] = shift_set - 1; - c40_p++; - } - c40_buffer[c40_p] = value; - c40_p++; - - if (c40_p >= 3) { - int iv; - - iv = (1600 * c40_buffer[0]) + (40 * c40_buffer[1]) + (c40_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - - c40_buffer[0] = c40_buffer[3]; - c40_buffer[1] = c40_buffer[4]; - c40_buffer[2] = c40_buffer[5]; - c40_buffer[3] = 0; - c40_buffer[4] = 0; - c40_buffer[5] = 0; - c40_p -= 3; + if (cte_p >= 3) { + cte_p = cte_buffer_transfer(cte_buffer, cte_p, target, &tp); } sp++; } - } - if (current_mode == C1_TEXT) { - /* Step D - Text encodation */ - - next_mode = C1_TEXT; - if (text_p == 0) { - int done = 0; - if ((length - sp) >= 12) { - j = 0; - - for (i = 0; i < 12; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 12) { - next_mode = C1_ASCII; - done = 1; - } - } - - if ((length - sp) >= 8) { - j = 0; - - for (i = 0; i < 8; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if ((length - sp) == 8) { - latch = 1; - } else { - latch = 1; - for (j = sp + 8; j < length; j++) { - if ((source[j] <= '0') || (source[j] >= '9')) { - latch = 0; - } - } - } - - if ((j == 8) && latch) { - next_mode = C1_ASCII; - done = 1; - } - } - - if (!(done)) { - next_mode = c1_look_ahead_test(source, length, sp, current_mode, gs1); - } - } - - if (next_mode != C1_TEXT) { - target[tp] = 255; - tp++; /* Unlatch */ - } else { - int shift_set, value; - if (source[sp] > 127) { - text_buffer[text_p] = 1; - text_p++; - text_buffer[text_p] = 30; - text_p++; /* Upper Shift */ - shift_set = text_shift[source[sp] - 128]; - value = text_value[source[sp] - 128]; - } else { - shift_set = text_shift[source[sp]]; - value = text_value[source[sp]]; - } - - if (gs1 && (source[sp] == '[')) { - shift_set = 2; - value = 27; /* FNC1 */ - } - - if (shift_set != 0) { - text_buffer[text_p] = shift_set - 1; - text_p++; - } - text_buffer[text_p] = value; - text_p++; - - if (text_p >= 3) { - int iv; - - iv = (1600 * text_buffer[0]) + (40 * text_buffer[1]) + (text_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - - text_buffer[0] = text_buffer[3]; - text_buffer[1] = text_buffer[4]; - text_buffer[2] = text_buffer[5]; - text_buffer[3] = 0; - text_buffer[4] = 0; - text_buffer[5] = 0; - text_p -= 3; - } - sp++; - } - } - - if (current_mode == C1_EDI) { + } else if (current_mode == C1_EDI) { /* Step E - EDI Encodation */ next_mode = C1_EDI; - if (edi_p == 0) { - if ((length - sp) >= 12) { - j = 0; - - for (i = 0; i < 12; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if (j == 12) { - next_mode = C1_ASCII; - } - } - - if ((length - sp) >= 8) { - j = 0; - - for (i = 0; i < 8; i++) { - if ((source[sp + i] >= '0') && (source[sp + i] <= '9')) { - j++; - } - } - - if ((length - sp) == 8) { - latch = 1; - } else { - latch = 1; - for (j = sp + 8; j < length; j++) { - if ((source[j] <= '0') || (source[j] >= '9')) { - latch = 0; - } - } - } - - if ((j == 8) && latch) { - next_mode = C1_ASCII; - } - } - - if (!((isedi(source[sp]) && isedi(source[sp + 1])) && isedi(source[sp + 2]))) { + if (cte_p == 0) { + /* Step E1 */ + if ((length - sp) >= 12 && digits_ahead(source, length, sp, 12) == 12) { + /* Step E1a */ + next_mode = C1_ASCII; + } else if ((length - sp) >= 8 && digits_ahead(source, length, sp, 0) == (length - sp)) { + /* Step E1b */ + next_mode = C1_ASCII; + } else if ((length - sp) < 3 || !isedi(source[sp]) || !isedi(source[sp + 1]) + || !isedi(source[sp + 2])) { + /* Step E1c */ + /* This ensures ASCII switch if don't have EDI triplet, so cte_p will be zero on loop exit */ next_mode = C1_ASCII; } } if (next_mode != C1_EDI) { - target[tp] = 255; /* Unlatch */ - tp++; + if (is_last_single_ascii(source, length, sp) && codewords_remaining(symbol, tp) == 1) { + /* No unlatch needed if data fits as ASCII in last data codeword */ + } else { + target[tp++] = 255; /* Unlatch */ + } } else { - int value = 0; - if (source[sp] == 13) { - value = 0; - } - if (source[sp] == '*') { - value = 1; - } - if (source[sp] == '>') { - value = 2; - } - if (source[sp] == ' ') { - value = 3; - } + /* Step E2 */ + static const char edi_nonalphanum_chars[] = "\015*> "; + + if (debug_print) printf("EDI "); + if ((source[sp] >= '0') && (source[sp] <= '9')) { - value = source[sp] - '0' + 4; - } - if ((source[sp] >= 'A') && (source[sp] <= 'Z')) { - value = source[sp] - 'A' + 14; + cte_buffer[cte_p++] = source[sp] - '0' + 4; + } else if ((source[sp] >= 'A') && (source[sp] <= 'Z')) { + cte_buffer[cte_p++] = source[sp] - 'A' + 14; + } else { + cte_buffer[cte_p++] = posn(edi_nonalphanum_chars, source[sp]); } - edi_buffer[edi_p] = value; - edi_p++; - - if (edi_p >= 3) { - int iv; - - iv = (1600 * edi_buffer[0]) + (40 * edi_buffer[1]) + (edi_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - - edi_buffer[0] = edi_buffer[3]; - edi_buffer[1] = edi_buffer[4]; - edi_buffer[2] = edi_buffer[5]; - edi_buffer[3] = 0; - edi_buffer[4] = 0; - edi_buffer[5] = 0; - edi_p -= 3; + if (cte_p >= 3) { + cte_p = cte_buffer_transfer(cte_buffer, cte_p, target, &tp); } sp++; } - } - if (current_mode == C1_DECIMAL) { + } else if (current_mode == C1_DECIMAL) { /* Step F - Decimal encodation */ - int decimal_count, data_left; + int decimal_count; + + if (debug_print) printf("DECIMAL "); next_mode = C1_DECIMAL; - data_left = length - sp; - decimal_count = 0; + decimal_count = digits_ahead(source, length, sp, 3); - if (data_left >= 1) { - if ((source[sp] >= '0') && (source[sp] <= '9')) { - decimal_count = 1; - } - } - if (data_left >= 2) { - if ((decimal_count == 1) && ((source[sp + 1] >= '0') && (source[sp + 1] <= '9'))) { - decimal_count = 2; - } - } - if (data_left >= 3) { - if ((decimal_count == 2) && ((source[sp + 2] >= '0') && (source[sp + 2] <= '9'))) { - decimal_count = 3; - } - } - - if (decimal_count != 3) { - size_t bits_left_in_byte, target_count; - int sub_target; - /* Finish Decimal mode and go back to ASCII */ - - bin_append(63, 6, decimal_binary); /* Unlatch */ - - target_count = 3; - if (strlen(decimal_binary) <= 16) { - target_count = 2; - } - if (strlen(decimal_binary) <= 8) { - target_count = 1; - } - bits_left_in_byte = (8 * target_count) - strlen(decimal_binary); - if (bits_left_in_byte == 8) { - bits_left_in_byte = 0; - } - - if (bits_left_in_byte == 2) { - bin_append(1, 2, decimal_binary); - } - - if ((bits_left_in_byte == 4) || (bits_left_in_byte == 6)) { - if (decimal_count >= 1) { - bin_append(ctoi(source[sp]) + 1, 4, decimal_binary); - sp++; + if (length - sp < 3) { + /* Step F1 */ + int bits_left = 8 - db_p; + int single_ascii = bits_left == 8 && is_last_single_ascii(source, length, sp); + if (codewords_remaining(symbol, tp) == 1 && (single_ascii || (decimal_count == 1 && bits_left >= 4))) { + if (single_ascii) { + /* Encode last character or last 2 digits as ASCII */ + if (istwodigits(source, length, sp)) { + target[tp++] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130; + sp += 2; + } else { + target[tp++] = source[sp] + 1; + sp++; + } } else { - bin_append(15, 4, decimal_binary); - } - } - - if (bits_left_in_byte == 6) { - bin_append(1, 2, decimal_binary); - } - - /* Binary buffer is full - transfer to target */ - if (target_count >= 1) { - sub_target = 0; - - for (i = 0; i < 8; i++) { - if (decimal_binary[i] == '1') { - sub_target += 128 >> i; + /* Encode last digit in 4 bits */ + db_p = bin_append_posn(ctoi(source[sp]) + 1, 4, decimal_binary, db_p); + sp++; + if (bits_left == 6) { + db_p = bin_append_posn(1, 2, decimal_binary, db_p); } + db_p = decimal_binary_transfer(decimal_binary, db_p, target, &tp); } - target[tp] = sub_target; - tp++; + } else { + db_p = decimal_unlatch(decimal_binary, db_p, target, &tp, decimal_count, source, &sp); + current_mode = C1_ASCII; /* Note need to set current_mode also in case exit loop */ } - if (target_count >= 2) { - sub_target = 0; - - for (i = 0; i < 8; i++) { - if (decimal_binary[i + 8] == '1') { - sub_target += 128 >> i; - } - } - target[tp] = sub_target; - tp++; - } - if (target_count == 3) { - sub_target = 0; - - for (i = 0; i < 8; i++) { - if (decimal_binary[i + 16] == '1') { - sub_target += 128 >> i; - } - } - target[tp] = sub_target; - tp++; - } - next_mode = C1_ASCII; + } else { - /* There are three digits - convert the value to binary */ - bin_append((100 * ctoi(source[sp])) + (10 * ctoi(source[sp + 1])) + ctoi(source[sp + 2]) + 1, 10, decimal_binary); - sp += 3; - } - - if (strlen(decimal_binary) >= 24) { - int target1 = 0, target2 = 0, target3 = 0; - char temp_binary[40]; - - /* Binary buffer is full - transfer to target */ - - for (p = 0; p < 8; p++) { - if (decimal_binary[p] == '1') { - target1 += (0x80 >> p); + if (decimal_count != 3) { + /* Step F2 */ + db_p = decimal_unlatch(decimal_binary, db_p, target, &tp, decimal_count, source, &sp); + current_mode = next_mode = C1_ASCII; /* Note need to set current_mode also in case exit loop */ + } else { + /* Step F3 */ + /* There are three digits - convert the value to binary */ + int value = (100 * ctoi(source[sp])) + (10 * ctoi(source[sp + 1])) + ctoi(source[sp + 2]) + 1; + db_p = bin_append_posn(value, 10, decimal_binary, db_p); + if (db_p >= 8) { + db_p = decimal_binary_transfer(decimal_binary, db_p, target, &tp); } - if (decimal_binary[p + 8] == '1') { - target2 += (0x80 >> p); - } - if (decimal_binary[p + 16] == '1') { - target3 += (0x80 >> p); - } - } - target[tp] = target1; - tp++; - target[tp] = target2; - tp++; - target[tp] = target3; - tp++; - - strcpy(temp_binary, ""); - if (strlen(decimal_binary) > 24) { - for (i = 0; i <= (int) (strlen(decimal_binary) - 24); i++) { - temp_binary[i] = decimal_binary[i + 24]; - } - strcpy(decimal_binary, temp_binary); + sp += 3; } } - } - if (current_mode == C1_BYTE) { + } else if (current_mode == C1_BYTE) { next_mode = C1_BYTE; if (gs1 && (source[sp] == '[')) { @@ -988,196 +766,153 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], unsigne } if (next_mode != C1_BYTE) { - /* Insert byte field length */ - if ((tp - byte_start) <= 249) { - for (i = tp; i >= byte_start; i--) { - target[i + 1] = target[i]; - } - target[byte_start] = (tp - byte_start); - tp++; + /* Update byte field length */ + int byte_count = tp - (byte_start + 1); + if (byte_count <= 249) { + target[byte_start] = byte_count; } else { - for (i = tp; i >= byte_start; i--) { - target[i + 2] = target[i]; - } - target[byte_start] = 249 + ((tp - byte_start) / 250); - target[byte_start + 1] = ((tp - byte_start) % 250); - tp += 2; + /* Insert extra codeword */ + memmove(target + byte_start + 2, target + byte_start + 1, sizeof(unsigned int) * byte_count); + target[byte_start] = 249 + (byte_count / 250); + target[byte_start + 1] = (byte_count % 250); + tp++; } } else { - target[tp] = source[sp]; - tp++; + if (debug_print) printf("BYTE "); + + target[tp++] = source[sp]; sp++; } } if (tp > 1480) { + if (debug_print) printf("\n"); /* Data is too large for symbol */ - strcpy(symbol->errtxt, "511: Input data too long"); return 0; } } while (sp < length); - /* Empty buffers */ - if (c40_p == 2) { - int iv; - - c40_buffer[2] = 1; - iv = (1600 * c40_buffer[0]) + (40 * c40_buffer[1]) + (c40_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - target[tp] = 255; - tp++; /* Unlatch */ - } - if (c40_p == 1) { - int iv; - - c40_buffer[1] = 1; - c40_buffer[2] = 31; /* Pad */ - iv = (1600 * c40_buffer[0]) + (40 * c40_buffer[1]) + (c40_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - target[tp] = 255; - tp++; /* Unlatch */ - } - if (text_p == 2) { - int iv; - - text_buffer[2] = 1; - iv = (1600 * text_buffer[0]) + (40 * text_buffer[1]) + (text_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - target[tp] = 255; - tp++; /* Unlatch */ - } - if (text_p == 1) { - int iv; - - text_buffer[1] = 1; - text_buffer[2] = 31; /* Pad */ - iv = (1600 * text_buffer[0]) + (40 * text_buffer[1]) + (text_buffer[2]) + 1; - target[tp] = iv / 256; - tp++; - target[tp] = iv % 256; - tp++; - target[tp] = 255; - tp++; /* Unlatch */ + if (debug_print) { + printf("\nEnd Current Mode: %d, tp %d, cte_p %d, db_p %d\n", current_mode, tp, cte_p, db_p); } - if (current_mode == C1_DECIMAL) { - size_t bits_left_in_byte, target_count; - int sub_target; - /* Finish Decimal mode and go back to ASCII */ + /* Empty buffers (note cte_buffer will be empty if current_mode C1_EDI) */ + if (current_mode == C1_C40 || current_mode == C1_TEXT) { + if (cte_p >= 1) { + int cws_remaining = codewords_remaining(symbol, tp); - bin_append(63, 6, decimal_binary); /* Unlatch */ - - target_count = 3; - if (strlen(decimal_binary) <= 16) { - target_count = 2; - } - if (strlen(decimal_binary) <= 8) { - target_count = 1; - } - bits_left_in_byte = (8 * target_count) - strlen(decimal_binary); - if (bits_left_in_byte == 8) { - bits_left_in_byte = 0; - } - - if (bits_left_in_byte == 2) { - bin_append(1, 2, decimal_binary); - } - - if ((bits_left_in_byte == 4) || (bits_left_in_byte == 6)) { - bin_append(15, 4, decimal_binary); - } - - if (bits_left_in_byte == 6) { - bin_append(1, 2, decimal_binary); - } - - /* Binary buffer is full - transfer to target */ - if (target_count >= 1) { - sub_target = 0; - - for (i = 0; i < 8; i++) { - if (decimal_binary[i] == '1') { - sub_target += 128 >> i; + /* Note doing strict interpretation of spec here (same as BWIPP), unlike in Data Matrix case */ + if (cws_remaining == 1 && cte_p == 1 && isc40text(current_mode, source[sp - 1])) { + /* 2.2.2.2 "...except when a single symbol character is left at the end before the first + error correction character. This single character is encoded in the ASCII code set." */ + target[tp++] = source[sp - 1] + 1; /* As ASCII */ + cte_p = 0; + } else if (cws_remaining == 2 && cte_p == 2) { + /* 2.2.2.2 "Two characters may be encoded in C40 mode in the last two data symbol characters of the + symbol as two C40 values followed by one of the C40 shift characters." */ + cte_buffer[cte_p++] = 0; /* Shift 0 */ + cte_p = cte_buffer_transfer(cte_buffer, cte_p, target, &tp); + } + if (cte_p >= 1) { + int cnt, total_cnt = 0; + /* Backtrack to last complete triplet (same technique as BWIPP) */ + while (sp > 0 && cte_p % 3) { + sp--; + cnt = c40text_cnt(current_mode, gs1, source[sp]); + total_cnt += cnt; + cte_p -= cnt; } - } - target[tp] = sub_target; - tp++; - } - if (target_count >= 2) { - sub_target = 0; + tp -= (total_cnt / 3) * 2; - for (i = 0; i < 8; i++) { - if (decimal_binary[i + 8] == '1') { - sub_target += 128 >> i; + target[tp++] = 255; /* Unlatch */ + for (; sp < length; sp++) { + if (istwodigits(source, length, sp)) { + target[tp++] = (10 * ctoi(source[sp])) + ctoi(source[sp + 1]) + 130; + sp++; + } else if (source[sp] > 127) { + target[tp++] = 235; /* FNC4 (Upper Shift) */ + target[tp++] = (source[sp] - 128) + 1; + } else if ((gs1) && (source[sp] == '[')) { + target[tp++] = 232; /* FNC1 */ + } else { + target[tp++] = source[sp] + 1; + } } + current_mode = C1_ASCII; } - target[tp] = sub_target; - tp++; } - if (target_count == 3) { - sub_target = 0; - for (i = 0; i < 8; i++) { - if (decimal_binary[i + 16] == '1') { - sub_target += 128 >> i; - } - } - target[tp] = sub_target; - tp++; + } else if (current_mode == C1_DECIMAL) { + int bits_left; + + /* Finish Decimal mode and go back to ASCII unless only one codeword remaining */ + if (codewords_remaining(symbol, tp) > 1) { + db_p = bin_append_posn(63, 6, decimal_binary, db_p); /* Unlatch */ } - } - if (current_mode == C1_BYTE) { - /* Insert byte field length */ - if ((tp - byte_start) <= 249) { - for (i = tp; i >= byte_start; i--) { - target[i + 1] = target[i]; + if (db_p >= 8) { + db_p = decimal_binary_transfer(decimal_binary, db_p, target, &tp); + } + + bits_left = (8 - db_p) & 0x07; + + if (bits_left) { + + if ((bits_left == 4) || (bits_left == 6)) { + db_p = bin_append_posn(15, 4, decimal_binary, db_p); } - target[byte_start] = (tp - byte_start); - tp++; - } else { - for (i = tp; i >= byte_start; i--) { - target[i + 2] = target[i]; + + if (bits_left == 2 || bits_left == 6) { + db_p = bin_append_posn(1, 2, decimal_binary, db_p); + } + + (void)decimal_binary_transfer(decimal_binary, db_p, target, &tp); + } + current_mode = C1_ASCII; + + } else if (current_mode == C1_BYTE) { + /* Update byte field length unless no codewords remaining */ + if (codewords_remaining(symbol, tp) > 0) { + int byte_count = tp - (byte_start + 1); + if (byte_count <= 249) { + target[byte_start] = byte_count; + } else { + /* Insert extra byte field byte */ + memmove(target + byte_start + 2, target + byte_start + 1, sizeof(unsigned int) * byte_count); + target[byte_start] = 249 + (byte_count / 250); + target[byte_start + 1] = (byte_count % 250); + tp++; } - target[byte_start] = 249 + ((tp - byte_start) / 250); - target[byte_start + 1] = ((tp - byte_start) % 250); - tp += 2; } } /* Re-check length of data */ if (tp > 1480) { /* Data is too large for symbol */ - strcpy(symbol->errtxt, "512: Input data too long"); return 0; } - if (symbol->debug & ZINT_DEBUG_PRINT) { - printf("Target:"); + *p_last_mode = current_mode; + + if (debug_print) { + printf("Target (%d):", tp); for (i = 0; i < tp; i++) { printf(" [%d]", target[i]); } - printf("\n"); + printf("\nLast Mode: %d\n", *p_last_mode); } return tp; } -static void block_copy(struct zint_symbol *symbol, char grid[][120], int start_row, int start_col, int height, int width, int row_offset, int col_offset) { +/* Set symbol from datagrid */ +static void block_copy(struct zint_symbol *symbol, char datagrid[136][120], const int start_row, const int start_col, + const int height, const int width, const int row_offset, const int col_offset) { int i, j; for (i = start_row; i < (start_row + height); i++) { for (j = start_col; j < (start_col + width); j++) { - if (grid[i][j] == '1') { + if (datagrid[i][j]) { set_module(symbol, i + row_offset, j + col_offset); } } @@ -1191,6 +926,7 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le int row, col; int sub_version = 0; rs_t rs; + int error_number = 0; if ((symbol->option_2 < 0) || (symbol->option_2 > 10)) { strcpy(symbol->errtxt, "513: Invalid symbol size"); @@ -1201,12 +937,11 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le /* Version S */ int codewords; large_int elreg; - unsigned int data[15], ecc[15]; - int stream[30]; + unsigned int data[30], ecc[15]; int block_width; if (length > 18) { - strcpy(symbol->errtxt, "514: Input data too long"); + strcpy(symbol->errtxt, "514: Input data too long for Version S"); return ZINT_ERROR_TOO_LONG; } if (is_sane(NEON, source, length) == ZINT_ERROR_INVALID_DATA) { @@ -1214,200 +949,163 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le return ZINT_ERROR_INVALID_DATA; } - sub_version = 3; - codewords = 12; - block_width = 6; /* Version S-30 */ - if (length <= 12) { - /* Version S-20 */ - sub_version = 2; - codewords = 8; - block_width = 4; - } + size = 9; if (length <= 6) { /* Version S-10 */ sub_version = 1; codewords = 4; block_width = 2; + } else if (length <= 12) { + /* Version S-20 */ + sub_version = 2; + codewords = 8; + block_width = 4; + } else { + /* Version S-30 */ + sub_version = 3; + codewords = 12; + block_width = 6; } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Subversion: %d\n", sub_version); + } + + /* Convert value plus one to binary */ large_load_str_u64(&elreg, source, length); - - for (i = 0; i < 15; i++) { - data[i] = 0; - ecc[i] = 0; - } - + large_add_u64(&elreg, 1); large_uint_array(&elreg, data, codewords, 5 /*bits*/); rs_init_gf(&rs, 0x25); - rs_init_code(&rs, codewords, 1); + rs_init_code(&rs, codewords, 0); rs_encode_uint(&rs, codewords, data, ecc); for (i = 0; i < codewords; i++) { - stream[i] = data[i]; - stream[i + codewords] = ecc[codewords - i - 1]; + data[i + codewords] = ecc[codewords - i - 1]; } - for (i = 0; i < 136; i++) { - for (j = 0; j < 120; j++) { - datagrid[i][j] = '0'; - } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Codewords (%d): ", codewords); + for (i = 0; i < codewords * 2; i++) printf(" %d", data[i]); + printf("\n"); } i = 0; for (row = 0; row < 2; row++) { for (col = 0; col < block_width; col++) { - if (stream[i] & 0x10) { - datagrid[row * 2][col * 5] = '1'; - } - if (stream[i] & 0x08) { - datagrid[row * 2][(col * 5) + 1] = '1'; - } - if (stream[i] & 0x04) { - datagrid[row * 2][(col * 5) + 2] = '1'; - } - if (stream[i] & 0x02) { - datagrid[(row * 2) + 1][col * 5] = '1'; - } - if (stream[i] & 0x01) { - datagrid[(row * 2) + 1][(col * 5) + 1] = '1'; - } - if (stream[i + 1] & 0x10) { - datagrid[row * 2][(col * 5) + 3] = '1'; - } - if (stream[i + 1] & 0x08) { - datagrid[row * 2][(col * 5) + 4] = '1'; - } - if (stream[i + 1] & 0x04) { - datagrid[(row * 2) + 1][(col * 5) + 2] = '1'; - } - if (stream[i + 1] & 0x02) { - datagrid[(row * 2) + 1][(col * 5) + 3] = '1'; - } - if (stream[i + 1] & 0x01) { - datagrid[(row * 2) + 1][(col * 5) + 4] = '1'; - } + datagrid[row * 2][col * 5] = data[i] & 0x10; + datagrid[row * 2][(col * 5) + 1] = data[i] & 0x08; + datagrid[row * 2][(col * 5) + 2] = data[i] & 0x04; + datagrid[(row * 2) + 1][col * 5] = data[i] & 0x02; + datagrid[(row * 2) + 1][(col * 5) + 1] = data[i] & 0x01; + datagrid[row * 2][(col * 5) + 3] = data[i + 1] & 0x10; + datagrid[row * 2][(col * 5) + 4] = data[i + 1] & 0x08; + datagrid[(row * 2) + 1][(col * 5) + 2] = data[i + 1] & 0x04; + datagrid[(row * 2) + 1][(col * 5) + 3] = data[i + 1] & 0x02; + datagrid[(row * 2) + 1][(col * 5) + 4] = data[i + 1] & 0x01; i += 2; } } - size = 9; symbol->rows = 8; symbol->width = 10 * sub_version + 1; - } - if (symbol->option_2 == 10) { + } else if (symbol->option_2 == 10) { /* Version T */ - unsigned int data[80] = {0}; /* Allow for doubled digits */ + unsigned int data[90 + 2]; /* Allow for 90 BYTE mode (+ latch and byte count) */ unsigned int ecc[22]; - unsigned int stream[60]; int data_length; int data_cw, ecc_cw, block_width; + int last_mode; - if (length > 80) { - strcpy(symbol->errtxt, "519: Input data too long"); + if (length > 90 || (symbol->eci && length + 7 + chr_cnt(source, length, '\\') > 90)) { + strcpy(symbol->errtxt, "519: Input data too long for Version T"); return ZINT_ERROR_TOO_LONG; } - data_length = c1_encode(symbol, source, data, length); + data_length = c1_encode(symbol, source, data, length, &last_mode); - if (data_length == 0) { - return ZINT_ERROR_TOO_LONG; - } - - if (data_length > 38) { - strcpy(symbol->errtxt, "516: Input data too long"); + if (data_length == 0 || data_length > 38) { + strcpy(symbol->errtxt, "516: Input data too long for Version T"); return ZINT_ERROR_TOO_LONG; } size = 10; - sub_version = 3; - data_cw = 38; - ecc_cw = 22; - block_width = 12; - if (data_length <= 24) { - sub_version = 2; - data_cw = 24; - ecc_cw = 16; - block_width = 8; - } if (data_length <= 10) { sub_version = 1; data_cw = 10; ecc_cw = 10; block_width = 4; + } else if (data_length <= 24) { + sub_version = 2; + data_cw = 24; + ecc_cw = 16; + block_width = 8; + } else { + sub_version = 3; + data_cw = 38; + ecc_cw = 22; + block_width = 12; } - for (i = data_length; i < data_cw; i++) { - data[i] = 129; /* Pad */ + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Padding: %d, Subversion: %d\n", data_cw - data_length, sub_version); + } + + /* If require padding */ + if (data_cw > data_length) { + /* If did not finish in ASCII or BYTE mode, switch to ASCII */ + if (last_mode != C1_ASCII && last_mode != C1_BYTE) { + data[data_length++] = 255; /* Unlatch */ + } + for (i = data_length; i < data_cw; i++) { + data[i] = 129; /* Pad */ + } } /* Calculate error correction data */ rs_init_gf(&rs, 0x12d); - rs_init_code(&rs, ecc_cw, 1); + rs_init_code(&rs, ecc_cw, 0); rs_encode_uint(&rs, data_cw, data, ecc); - /* "Stream" combines data and error correction data */ - for (i = 0; i < data_cw; i++) { - stream[i] = data[i]; - } for (i = 0; i < ecc_cw; i++) { - stream[data_cw + i] = ecc[ecc_cw - i - 1]; + data[data_cw + i] = ecc[ecc_cw - i - 1]; } - for (i = 0; i < 136; i++) { - for (j = 0; j < 120; j++) { - datagrid[i][j] = '0'; - } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Codewords (%d):", data_cw + ecc_cw); + for (i = 0; i < data_cw + ecc_cw; i++) printf(" %d", data[i]); + printf("\n"); } i = 0; for (row = 0; row < 5; row++) { for (col = 0; col < block_width; col++) { - if (stream[i] & 0x80) { - datagrid[row * 2][col * 4] = '1'; - } - if (stream[i] & 0x40) { - datagrid[row * 2][(col * 4) + 1] = '1'; - } - if (stream[i] & 0x20) { - datagrid[row * 2][(col * 4) + 2] = '1'; - } - if (stream[i] & 0x10) { - datagrid[row * 2][(col * 4) + 3] = '1'; - } - if (stream[i] & 0x08) { - datagrid[(row * 2) + 1][col * 4] = '1'; - } - if (stream[i] & 0x04) { - datagrid[(row * 2) + 1][(col * 4) + 1] = '1'; - } - if (stream[i] & 0x02) { - datagrid[(row * 2) + 1][(col * 4) + 2] = '1'; - } - if (stream[i] & 0x01) { - datagrid[(row * 2) + 1][(col * 4) + 3] = '1'; - } + datagrid[row * 2][col * 4] = data[i] & 0x80; + datagrid[row * 2][(col * 4) + 1] = data[i] & 0x40; + datagrid[row * 2][(col * 4) + 2] = data[i] & 0x20; + datagrid[row * 2][(col * 4) + 3] = data[i] & 0x10; + datagrid[(row * 2) + 1][col * 4] = data[i] & 0x08; + datagrid[(row * 2) + 1][(col * 4) + 1] = data[i] & 0x04; + datagrid[(row * 2) + 1][(col * 4) + 2] = data[i] & 0x02; + datagrid[(row * 2) + 1][(col * 4) + 3] = data[i] & 0x01; i++; } } symbol->rows = 16; symbol->width = (sub_version * 16) + 1; - } - if ((symbol->option_2 != 9) && (symbol->option_2 != 10)) { - /* Version A to H */ - unsigned int data[1500], ecc[600]; - unsigned int sub_data[190], sub_ecc[75]; - unsigned int stream[2100]; + } else { + /* Versions A to H */ + unsigned int data[1480 + 560]; + unsigned int sub_data[185], sub_ecc[70]; int data_length; - int data_blocks; + int data_cw; + int blocks, data_blocks, ecc_blocks, ecc_length; + int last_mode; - for (i = 0; i < 1500; i++) { - data[i] = 0; - } - data_length = c1_encode(symbol, source, data, length); + data_length = c1_encode(symbol, source, data, length, &last_mode); if (data_length == 0) { strcpy(symbol->errtxt, "517: Input data is too long"); @@ -1428,76 +1126,59 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le strcpy(symbol->errtxt, "518: Input too long for selected symbol size"); return ZINT_ERROR_TOO_LONG; } + data_cw = c1_data_length[size - 1]; - for (i = data_length; i < c1_data_length[size - 1]; i++) { - data[i] = 129; /* Pad */ + /* If require padding */ + if (data_cw > data_length) { + /* If did not finish in ASCII or BYTE mode, switch to ASCII */ + if (last_mode != C1_ASCII && last_mode != C1_BYTE) { + data[data_length++] = 255; /* Unlatch */ + } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Padding: %d\n", data_cw - data_length); + } + for (i = data_length; i < data_cw; i++) { + data[i] = 129; /* Pad */ + } + } else if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("No padding\n"); } /* Calculate error correction data */ - data_length = c1_data_length[size - 1]; - for (i = 0; i < 190; i++) { - sub_data[i] = 0; - } - for (i = 0; i < 75; i++) { - sub_ecc[i] = 0; - } - - data_blocks = c1_blocks[size - 1]; + blocks = c1_blocks[size - 1]; + data_blocks = c1_data_blocks[size - 1]; + ecc_blocks = c1_ecc_blocks[size - 1]; + ecc_length = c1_ecc_length[size - 1]; rs_init_gf(&rs, 0x12d); - rs_init_code(&rs, c1_ecc_blocks[size - 1], 0); - for (i = 0; i < data_blocks; i++) { - for (j = 0; j < c1_data_blocks[size - 1]; j++) { - - sub_data[j] = data[j * data_blocks + i]; + rs_init_code(&rs, ecc_blocks, 0); + for (i = 0; i < blocks; i++) { + for (j = 0; j < data_blocks; j++) { + sub_data[j] = data[j * blocks + i]; } - rs_encode_uint(&rs, c1_data_blocks[size - 1], sub_data, sub_ecc); - for (j = 0; j < c1_ecc_blocks[size - 1]; j++) { - ecc[c1_ecc_length[size - 1] - (j * data_blocks + i) - 1] = sub_ecc[j]; + rs_encode_uint(&rs, data_blocks, sub_data, sub_ecc); + for (j = 0; j < ecc_blocks; j++) { + data[data_cw + j * blocks + i] = sub_ecc[ecc_blocks - 1 - j]; } } - /* "Stream" combines data and error correction data */ - for (i = 0; i < data_length; i++) { - stream[i] = data[i]; - } - for (i = 0; i < c1_ecc_length[size - 1]; i++) { - stream[data_length + i] = ecc[i]; - } - - for (i = 0; i < 136; i++) { - for (j = 0; j < 120; j++) { - datagrid[i][j] = '0'; - } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Codewords (%d):", data_cw + ecc_length); + for (i = 0; i < data_cw + ecc_length; i++) printf(" %d", data[i]); + printf("\n"); } i = 0; for (row = 0; row < c1_grid_height[size - 1]; row++) { for (col = 0; col < c1_grid_width[size - 1]; col++) { - if (stream[i] & 0x80) { - datagrid[row * 2][col * 4] = '1'; - } - if (stream[i] & 0x40) { - datagrid[row * 2][(col * 4) + 1] = '1'; - } - if (stream[i] & 0x20) { - datagrid[row * 2][(col * 4) + 2] = '1'; - } - if (stream[i] & 0x10) { - datagrid[row * 2][(col * 4) + 3] = '1'; - } - if (stream[i] & 0x08) { - datagrid[(row * 2) + 1][col * 4] = '1'; - } - if (stream[i] & 0x04) { - datagrid[(row * 2) + 1][(col * 4) + 1] = '1'; - } - if (stream[i] & 0x02) { - datagrid[(row * 2) + 1][(col * 4) + 2] = '1'; - } - if (stream[i] & 0x01) { - datagrid[(row * 2) + 1][(col * 4) + 3] = '1'; - } + datagrid[row * 2][col * 4] = data[i] & 0x80; + datagrid[row * 2][(col * 4) + 1] = data[i] & 0x40; + datagrid[row * 2][(col * 4) + 2] = data[i] & 0x20; + datagrid[row * 2][(col * 4) + 3] = data[i] & 0x10; + datagrid[(row * 2) + 1][col * 4] = data[i] & 0x08; + datagrid[(row * 2) + 1][(col * 4) + 1] = data[i] & 0x04; + datagrid[(row * 2) + 1][(col * 4) + 2] = data[i] & 0x02; + datagrid[(row * 2) + 1][(col * 4) + 3] = data[i] & 0x01; i++; } } @@ -1506,6 +1187,10 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le symbol->width = c1_width[size - 1]; } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Version: %d\n", size); + } + switch (size) { case 1: /* Version A */ central_finder(symbol, 6, 3, 1); @@ -1763,5 +1448,15 @@ INTERNAL int code_one(struct zint_symbol *symbol, unsigned char source[], int le symbol->row_height[i] = 1; } - return 0; + if (symbol->option_2 == 9) { /* Version S */ + if (symbol->eci || (symbol->input_mode & 0x07) == GS1_MODE) { + strcpy(symbol->errtxt, "511: ECI and GS1 mode ignored for Version S"); + error_number = ZINT_WARN_INVALID_OPTION; + } + } else if (symbol->eci && (symbol->input_mode & 0x07) == GS1_MODE) { + strcpy(symbol->errtxt, "512: ECI ignored for GS1 mode"); + error_number = ZINT_WARN_INVALID_OPTION; + } + + return error_number; } diff --git a/backend/library.c b/backend/library.c index aa419c4f..3fa691f8 100644 --- a/backend/library.c +++ b/backend/library.c @@ -553,6 +553,7 @@ static int supports_eci(const int symbology) { case BARCODE_PDF417COMP: case BARCODE_QRCODE: case BARCODE_DOTCODE: + case BARCODE_CODEONE: case BARCODE_GRIDMATRIX: case BARCODE_HANXIN: case BARCODE_ULTRA: diff --git a/backend/tests/test_code1.c b/backend/tests/test_code1.c index b4e8fc95..4cb9f2ba 100644 --- a/backend/tests/test_code1.c +++ b/backend/tests/test_code1.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020 Robin Stuart + Copyright (C) 2020 - 2021 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -44,38 +44,121 @@ static void test_large(int index, int debug) { int expected_rows; int expected_width; }; + // Reference AIM USS Code One Table 2 // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { -1, "1", 2955, 0, 148, 134 }, - /* 1*/ { -1, "1", 2956, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 2*/ { -1, "A", 2217, 0, 148, 134 }, - /* 3*/ { -1, "A", 2218, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 4*/ { -1, "\001", 1480, 0, 148, 134 }, + /* 0*/ { -1, "1", 3550, 0, 148, 134 }, /* Auto Version H */ + /* 1*/ { -1, "1", 3551, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 2*/ { -1, "A", 2218, 0, 148, 134 }, + /* 3*/ { -1, "A", 2219, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 4*/ { -1, "\001", 1480, 0, 148, 134 }, /* Full ASCII */ /* 5*/ { -1, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 6*/ { 1, "1", 12, 0, 16, 18 }, - /* 7*/ { 1, "1", 13, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 8*/ { 2, "1", 33, 0, 22, 22 }, - /* 9*/ { 2, "1", 34, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 10*/ { 3, "1", 75, 0, 28, 32 }, - /* 11*/ { 3, "1", 76, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 12*/ { 4, "1", 177, 0, 40, 42 }, - /* 13*/ { 4, "1", 178, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 14*/ { 5, "1", 360, 0, 52, 54 }, - /* 15*/ { 5, "1", 361, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 16*/ { 6, "1", 732, 0, 70, 76 }, - /* 17*/ { 6, "1", 733, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 18*/ { 7, "1", 1452, 0, 104, 98 }, - /* 19*/ { 7, "1", 1453, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 20*/ { 8, "1", 2955, 0, 148, 134 }, - /* 21*/ { 8, "1", 2956, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 22*/ { 9, "1", 18, 0, 8, 31 }, - /* 23*/ { 9, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 24*/ { 10, "1", 69, 0, 16, 49 }, - /* 25*/ { 10, "1", 70, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 26*/ { 10, "A", 54, 0, 16, 49 }, - /* 27*/ { 10, "A", 55, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 28*/ { 10, "\001", 38, 0, 16, 49 }, - /* 29*/ { 10, "\001", 39, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 6*/ { -1, "\200", 1478, 0, 148, 134 }, /* BYTE */ + /* 7*/ { -1, "\200", 1479, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 8*/ { 1, "1", 22, 0, 16, 18 }, /* Version A */ + /* 9*/ { 1, "1", 23, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 10*/ { 1, "A", 13, 0, 16, 18 }, + /* 11*/ { 1, "A", 14, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 12*/ { 1, "\001", 10, 0, 16, 18 }, + /* 13*/ { 1, "\001", 11, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 14*/ { 1, "\200", 8, 0, 16, 18 }, + /* 15*/ { 1, "\200", 9, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 16*/ { 2, "1", 44, 0, 22, 22 }, /* Version B */ + /* 17*/ { 2, "1", 45, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 18*/ { 2, "A", 27, 0, 22, 22 }, + /* 19*/ { 2, "A", 28, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 20*/ { 2, "A", 26, 0, 22, 22 }, + /* 21*/ { 2, "\001", 19, 0, 22, 22 }, + /* 22*/ { 2, "\001", 20, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 23*/ { 2, "\200", 17, 0, 22, 22 }, + /* 24*/ { 2, "\200", 18, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 25*/ { 3, "1", 104, 0, 28, 32 }, /* Version C */ + /* 26*/ { 3, "1", 105, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 27*/ { 3, "A", 64, 0, 28, 32 }, + /* 28*/ { 3, "A", 65, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 29*/ { 3, "\001", 44, 0, 28, 32 }, + /* 30*/ { 3, "\001", 45, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 31*/ { 3, "\200", 42, 0, 28, 32 }, + /* 32*/ { 3, "\200", 43, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 33*/ { 4, "1", 217, 0, 40, 42 }, /* Version D */ + /* 34*/ { 4, "1", 218, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 35*/ { 4, "A", 135, 0, 40, 42 }, + /* 36*/ { 4, "A", 136, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 37*/ { 4, "\001", 91, 0, 40, 42 }, + /* 38*/ { 4, "\001", 92, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 39*/ { 4, "\200", 89, 0, 40, 42 }, + /* 40*/ { 4, "\200", 90, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 41*/ { 5, "1", 435, 0, 52, 54 }, /* Version E (note 435 multiple of 3) */ + /* 42*/ { 5, "1", 436, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 43*/ { 5, "1", 434, ZINT_ERROR_TOO_LONG, -1, -1 }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */ + /* 44*/ { 5, "1", 433, 0, 52, 54 }, + /* 45*/ { 5, "A", 271, 0, 52, 54 }, + /* 46*/ { 5, "A", 272, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 47*/ { 5, "\001", 182, 0, 52, 54 }, + /* 48*/ { 5, "\001", 183, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 49*/ { 5, "\200", 180, 0, 52, 54 }, + /* 50*/ { 5, "\200", 181, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 51*/ { 6, "1", 886, 0, 70, 76 }, /* Version F */ + /* 52*/ { 6, "1", 887, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 53*/ { 6, "A", 553, 0, 70, 76 }, + /* 54*/ { 6, "A", 554, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 55*/ { 6, "\001", 370, 0, 70, 76 }, + /* 56*/ { 6, "\001", 371, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 57*/ { 6, "\200", 368, 0, 70, 76 }, + /* 58*/ { 6, "\200", 369, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 59*/ { 7, "1", 1755, 0, 104, 98 }, /* Version G (note 1755 multiple of 3) */ + /* 60*/ { 7, "1", 1756, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 61*/ { 7, "1", 1754, ZINT_ERROR_TOO_LONG, -1, -1 }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */ + /* 62*/ { 7, "1", 1753, 0, 104, 98 }, + /* 63*/ { 7, "A", 1096, 0, 104, 98 }, + /* 64*/ { 7, "A", 1097, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 65*/ { 7, "\001", 732, 0, 104, 98 }, + /* 66*/ { 7, "\001", 733, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 67*/ { 7, "\200", 730, 0, 104, 98 }, + /* 68*/ { 7, "\200", 731, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 69*/ { 8, "1", 3550, 0, 148, 134 }, /* Version H */ + /* 70*/ { 8, "1", 3551, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 71*/ { 8, "A", 2218, 0, 148, 134 }, + /* 72*/ { 8, "A", 2219, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 73*/ { 8, "\001", 1480, 0, 148, 134 }, + /* 74*/ { 8, "\001", 1481, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 75*/ { 8, "\200", 1478, 0, 148, 134 }, + /* 76*/ { 8, "\200", 1479, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 77*/ { 9, "1", 6, 0, 8, 11 }, /* Version S-10 */ + /* 78*/ { 9, "1", 7, 0, 8, 21 }, /* -> S-20 */ + /* 79*/ { 9, "1", 12, 0, 8, 21 }, /* Version S-20 */ + /* 80*/ { 9, "1", 13, 0, 8, 31 }, /* -> S-30 */ + /* 81*/ { 9, "1", 18, 0, 8, 31 }, /* Version S-30 */ + /* 82*/ { 9, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 83*/ { 9, "1", 17, 0, 8, 31 }, + /* 84*/ { 10, "1", 22, 0, 16, 17 }, /* Version T-16 */ + /* 85*/ { 10, "1", 23, 0, 16, 33 }, /* -> T-32 */ + /* 86*/ { 10, "A", 13, 0, 16, 17 }, + /* 87*/ { 10, "A", 14, 0, 16, 33 }, /* -> T-32 */ + /* 88*/ { 10, "\001", 10, 0, 16, 17 }, + /* 89*/ { 10, "\001", 11, 0, 16, 33 }, /* -> T-32 */ + /* 90*/ { 10, "\200", 8, 0, 16, 17 }, + /* 91*/ { 10, "\200", 9, 0, 16, 33 }, /* -> T-32 */ + /* 92*/ { 10, "1", 56, 0, 16, 33 }, /* Version T-32 */ + /* 93*/ { 10, "1", 57, 0, 16, 49 }, /* -> T-48 */ + /* 94*/ { 10, "A", 34, 0, 16, 33 }, + /* 95*/ { 10, "A", 35, 0, 16, 49 }, /* -> T-48 */ + /* 96*/ { 10, "\001", 24, 0, 16, 33 }, + /* 97*/ { 10, "\001", 25, 0, 16, 49 }, /* -> T-48 */ + /* 98*/ { 10, "\200", 22, 0, 16, 33 }, + /* 99*/ { 10, "\200", 23, 0, 16, 49 }, /* -> T-48 */ + /*100*/ { 10, "1", 90, 0, 16, 49 }, /* Version T-48 (note 90 multiple of 3) */ + /*101*/ { 10, "1", 91, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*102*/ { 10, "1", 89, ZINT_ERROR_TOO_LONG, -1, -1 }, /* NOTE: a quirk of decimal end-of-data processing is existence of "lower maxs" if digits are not a multiple of 3 */ + /*103*/ { 10, "1", 88, 0, 16, 49 }, + /*104*/ { 10, "A", 55, 0, 16, 49 }, + /*105*/ { 10, "A", 56, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*106*/ { 10, "A", 90, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*107*/ { 10, "\001", 38, 0, 16, 49 }, + /*108*/ { 10, "\001", 39, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*109*/ { 10, "\001", 90, ZINT_ERROR_TOO_LONG, -1, -1 }, + /*110*/ { 10, "\200", 36, 0, 16, 49 }, + /*111*/ { 10, "\200", 37, ZINT_ERROR_TOO_LONG, -1, -1 }, }; int data_size = ARRAY_SIZE(data); @@ -84,6 +167,7 @@ static void test_large(int index, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); @@ -96,7 +180,7 @@ static void test_large(int index, int debug) { ret = ZBarcode_Encode(symbol, (unsigned char *) data_buf, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } @@ -114,48 +198,64 @@ static void test_input(int index, int debug) { int ret; struct item { int input_mode; + int eci; int option_2; char *data; int length; int ret; int expected_rows; int expected_width; + const char *expected_errtxt; }; // s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<")) struct item data[] = { - /* 0*/ { -1, -1, "123456789012ABCDEFGHI", -1, 0, 22, 22 }, - /* 1*/ { -1, -1, "123456789012ABCDEFGHIJ", -1, 0, 22, 22 }, - /* 2*/ { -1, -1, "1", -1, 0, 16, 18 }, - /* 3*/ { -1, 0, "1", -1, 0, 16, 18 }, - /* 4*/ { -1, 1, "1", -1, 0, 16, 18 }, - /* 5*/ { -1, 11, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1 }, - /* 6*/ { -1, 9, "123456789012345678", -1, 0, 8, 31 }, - /* 7*/ { -1, 9, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1 }, - /* 8*/ { -1, 10, "123456789012345678901234567890123456789012345678901234567890123456789", -1, 0, 16, 49 }, - /* 9*/ { -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456", -1, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 10*/ { -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 11*/ { -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 0, 16, 49 }, - /* 12*/ { -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 13*/ { -1, 10, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 38, 0, 16, 49 }, + /* 0*/ { -1, -1, -1, "123456789012ABCDEFGHI", -1, 0, 22, 22, "", }, + /* 1*/ { -1, -1, -1, "123456789012ABCDEFGHIJ", -1, 0, 22, 22, "", }, + /* 2*/ { -1, -1, -1, "1", -1, 0, 16, 18, "", }, + /* 3*/ { -1, -1, 0, "1", -1, 0, 16, 18, "", }, + /* 4*/ { -1, -1, 1, "1", -1, 0, 16, 18, "", }, + /* 5*/ { -1, -1, 1, "ABCDEFGHIJKLMN", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for selected symbol size", }, + /* 6*/ { GS1_MODE, -1, 1, "[01]12345678901231", -1, 0, 16, 18, "", }, + /* 7*/ { -1, 3, 1, "1", -1, 0, 16, 18, "", }, + /* 8*/ { UNICODE_MODE, 3, 1, "é", -1, 0, 16, 18, "", }, + /* 9*/ { GS1_MODE, 3, 1, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 18, "Warning 512: ECI ignored for GS1 mode", }, + /* 10*/ { -1, -1, 9, "123456789012345678", -1, 0, 8, 31, "", }, + /* 11*/ { -1, -1, 9, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 515: Invalid input data (Version S encodes numeric input only)", }, + /* 12*/ { -1, -1, 9, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 514: Input data too long for Version S", }, + /* 13*/ { GS1_MODE, -1, 9, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 8, 31, "Warning 511: ECI and GS1 mode ignored for Version S", }, + /* 14*/ { -1, 3, 9, "1", -1, ZINT_WARN_INVALID_OPTION, 8, 11, "Warning 511: ECI and GS1 mode ignored for Version S", }, + /* 15*/ { -1, -1, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, 0, 16, 49, "", }, + /* 16*/ { -1, -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", }, + /* 17*/ { -1, -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 0, 16, 49, "", }, + /* 18*/ { -1, -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", }, + /* 19*/ { -1, -1, 10, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 38, 0, 16, 49, "", }, + /* 20*/ { -1, 3, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456", -1, 0, 16, 49, "", }, + /* 21*/ { -1, 3, 10, "12345678901234567890123456789012345678901234567890123456789012345678901234567", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", }, + /* 22*/ { -1, 3, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", }, + /* 23*/ { GS1_MODE, -1, 10, "[01]12345678901231", -1, 0, 16, 17, "", }, + /* 24*/ { GS1_MODE, 3, 10, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 17, "Warning 512: ECI ignored for GS1 mode", }, + /* 25*/ { -1, -1, 11, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 513: Invalid symbol size", }, }; int data_size = ARRAY_SIZE(data); for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); - if (ret < 5) { + if (ret < ZINT_ERROR) { assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows); assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width); } + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d symbol->errtxt %s != %s\n", i, symbol->errtxt, data[i].expected_errtxt); ZBarcode_Delete(symbol); } @@ -171,6 +271,8 @@ static void test_encode(int index, int generate, int debug) { int ret; struct item { + int input_mode; + int eci; int option_2; char *data; int length; @@ -182,26 +284,121 @@ static void test_encode(int index, int generate, int debug) { char *comment; char *expected; }; + // Figure examples AIM USS Code One (USSCO) Revision March 3, 2000 struct item data[] = { - /* 0*/ { -1, "123456789012", -1, 0, 16, 18, 1, "", - "100011101010111101" - "111010010010100000" - "110110100010001000" - "110010111000010001" - "100010100011010100" + /* 0*/ { -1, -1, -1, "1234567890123456789012", -1, 0, 16, 18, 1, "USSCO Figure 1 (Version A, no padding), same", + "111111111111001100" + "000110000110010101" + "100010110101101010" + "000010010110100111" + "111010100010101100" "000010000000100000" "111111111111111111" "000000000000000000" "011111111111111110" "010000000000000010" "011111111111111110" - "000100010100100101" - "011001001110101101" - "011010010010101111" - "010111110100100111" - "100010001101111100" + "000111011001101110" + "010110011110101111" + "101000010001101000" + "100111000001100000" + "101000001010111101" }, - /* 1*/ { -1, "Code One", -1, 0, 16, 18, 1, "BWIPP example", + /* 1*/ { -1, -1, -1, "???????????????????????????????????????????????????????????????????????????????????????????", -1, 0, 40, 42, 1, "USSCO Figure 7 (Version D, no padding), same", + "010011010001000100011100010001000100110100" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "010011010001000100011100010001000100110100" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "111111111111111111111111111111111111111111" + "000000000000000000000000000000000000000000" + "011111111111111111111111111111111111111110" + "010000000000000000000000000000000000000010" + "011111111111111111111111111111111111111110" + "010000000000000000000000000000000000000010" + "011111111111111111111111111111111111111110" + "010000000000000000000000000000000000000010" + "011111111111111111111111111111111111111110" + "000010000000000000001000000000000000100000" + "010010010001000100011000010001000100100100" + "000011000000000000001100000000000000110000" + "010010010001000100011000010001000100100100" + "000010000000000000001000000000000000100000" + "010010111100010001111000011011111001100011" + "000010001000000000011010101011101000101101" + "001110101011100111011000101110010010101011" + "101010110000000011011001000100101100100000" + "100110011111100011001010001111001100101100" + "001110111010110001101011100101111101101100" + "101010111111011110111001000100010110100111" + "001110010111101000111000010011001011101011" + "001010001001110101011000110000111010101100" + "101111001111111001001101111000011111110010" + }, + /* 2*/ { -1, -1, 9, "1234567890", -1, 0, 8, 21, 1, "USSCO Figure 9 (left) NOTE: S-20 not S-10 as stated, same", + "000000011110110010110" + "000010000100000010011" + "101111110100010100100" + "010010001100110001010" + "000000000010000000000" + "111111111111111111111" + "100000000000000000001" + "101111111111111111101" + }, + /* 3*/ { -1, -1, 10, "12345678901234567890", -1, 0, 16, 17, 1, "USSCO Figure 9 (right) **NOT SAME** different encodation, figure uses ASCII double digits, Zint DECIMAL (same no. of codewords)", + "11111111111001100" + "00010001010010101" + "10001101001101010" + "00000101010100111" + "11111101010000111" + "11011100000100101" + "11000001000000111" + "01111010010010011" + "11111010001101101" + "00100011010111111" + "00000000100000000" + "11111111111111111" + "10000000000000001" + "10111111111111101" + "10000000000000001" + "10111111111111101" + }, + /* 4*/ { GS1_MODE, -1, 2, "[01]00312341234014[15]950915[10]ABC123456", -1, 0, 22, 22, 1, "USSCO Figure B1 **NOT SAME** using (10) not (30) as (30) no longer compliant", + "1110110000110000001010" + "1100100010001000111100" + "0111100110100100001101" + "1100100100101011101111" + "1001101111100001000100" + "0100101101110000100011" + "0100101000101010110101" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100111001001010100111" + "1001110100011011100001" + "0011101101100110100101" + "1101000110001101100000" + "1010001101011111101100" + "1111101011001110101010" + "1010010111000001110111" + }, + /* 5*/ { -1, -1, -1, "Code One", -1, 0, 16, 18, 1, "BWIPP example", "010011011101100110" "010010000001010110" "001010010101100110" @@ -219,11 +416,21 @@ static void test_encode(int index, int generate, int debug) { "100001100111100100" "100000111000111000" }, - /* 2*/ { 3, "1234567890ABCDEF", -1, 0, 28, 32, 0, "https://fr.wikipedia.org/wiki/Liste_des_symbologies, same; BWIPP **NOT SAME**, has unlatch to ASCII at end, no doc so don't know if necessary", + /* 6*/ { -1, -1, 9, "406990", -1, 0, 8, 11, 1, "BWIPP Version S-10 example", + "01101101101" + "00101010111" + "01101001101" + "00100000100" + "00000000000" + "11111111111" + "10000000001" + "10111111101" + }, + /* 7*/ { -1, -1, 3, "1234567890ABCDEF", -1, 0, 28, 32, 1, "https://fr.wikipedia.org/wiki/Liste_des_symbologies **NOT SAME** as Zint has unlatch to ASCII at end (before padding)", "10001110101011110111011110110101" "11101001001010000011000110101001" - "11101001100010100010001000101000" - "10011011010100000100010001100001" + "11101001100010111110001000101000" + "10011011010100111100010001100001" "10001010001000100010001000101000" "00011000010001000100010001100001" "10001010001000100010001000101000" @@ -240,48 +447,2100 @@ static void test_encode(int index, int generate, int debug) { "01111111111111111111111111111110" "10001010001000100010001000101000" "00011000010001000100010001100001" - "10001010000101011110001101100110" - "00011000010010101010111011100100" - "11101011011100101001000110101100" - "01111000000000010001000111101111" - "00001010100010111100100100101100" - "10001000101110100001010011100110" - "00001011001001010100010001101111" - "00101101111001111011011001111010" + "10001010001010101001001100101101" + "00011000011001100111111110100001" + "01101011001000111101000001100000" + "11101010110111100100001100100100" + "10111001101111010101010011100101" + "11001001100111010000000111101100" + "01101001101100000101111100100000" + "00111100100000110101111110111001" + }, + /* 8*/ { -1, -1, 1, "1", -1, 0, 16, 18, 1, "Version A", + "001111100010001000" + "001010000100010001" + "100010100010001000" + "000110000100010001" + "100010100010111010" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011111101101" + "110101011101100011" + "001011010100100000" + "101000000101100011" + "001110100110110101" + }, + /* 9*/ { -1, -1, 2, "1", -1, 0, 22, 22, 1, "Version B", + "0011111000100010001000" + "0010100001000100010001" + "1000101000100010001000" + "0001100001000100010001" + "1000101000100010001000" + "0001100001000100010001" + "1000101000100010000101" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001100011" + "1011100100100100101111" + "1000001000100010101000" + "1000101010001101101011" + "0011100111110001101010" + "0000001101010001100110" + "0001001111111101111101" + }, + /* 10*/ { -1, -1, 3, "1", -1, 0, 28, 32, 1, "Version C", + "00111110001000100010001000111000" + "00101000010001000100010001100001" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "00001000000000000000000000100000" + "11111111111111111111111111111111" + "00000000000000000000000000100000" + "11111111111111111111111111111111" + "00000000000000000000000000000000" + "01111111111111111111111111111110" + "01000000000000000000000000000010" + "01111111111111111111111111111110" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "10001010000011010001010010101000" + "00011000010011100110010111100110" + "10101001001100010000111010101011" + "11111001011001101001001101100100" + "11001011100101010101000111100000" + "01001000010101111111101101101001" + "00001000011000110111001001100111" + "10001110101100110010000011111001" + }, + /* 11*/ { -1, -1, 4, "1", -1, 0, 40, 42, 1, "Version D", + "001111100010001000101100100010001000111000" + "001010000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000110000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000110000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000110000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000110000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000110000100010001001001000100010001100001" + "100011100010001000101100100010001000111000" + "000110000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000010000000000000001000000000000000100000" + "111111111111111111111111111111111111111111" + "000000000000000000000000000000000000000000" + "011111111111111111111111111111111111111110" + "010000000000000000000000000000000000000010" + "011111111111111111111111111111111111111110" + "010000000000000000000000000000000000000010" + "011111111111111111111111111111111111111110" + "010000000000000000000000000000000000000010" + "011111111111111111111111111111111111111110" + "000110000100010001001001000100010001100001" + "100010100010001000101000100010001000101000" + "000111000100010001001101000100010001110001" + "100010100010001000101000100010001000101000" + "000110000100010001001001000100010001100001" + "100010101001100100001011011010110110100000" + "000110100110101111011011110010011011101001" + "000010010111010100101010110101001011101101" + "000110100010000101111000100111011100101011" + "001110001100000101111001010011111100101011" + "001110011010000011011001001111011001100010" + "110110110000111010011001111100001111101001" + "001110010011111000101011111101110101100100" + "111110111100011110001010001011010010101010" + "001111110100111100111110111101110110111000" + }, + /* 12*/ { -1, -1, 5, "1", -1, 0, 52, 54, 1, "Version E", + "001111100010001000100010001110001000100010001000111000" + "001010000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100011100010001000100010001110001000100010001000111000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000010000000000000000000001000000000000000000000100000" + "111111111111111111111111111111111111111111111111111111" + "000000000000000000000000001000000000000000000000000000" + "111111111111111111111111111111111111111111111111111111" + "000000000000000000000000000000000000000000000000000000" + "011111111111111111111111111111111111111111111111111110" + "010000000000000000000000000000000000000000000000000010" + "011111111111111111111111111111111111111111111111111110" + "010000000000000000000000000000000000000000000000000010" + "011111111111111111111111111111111111111111111111111110" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000110000100010001000100011000010001000100010001100001" + "100010100010001000100010001010001000100010001000101000" + "000111000100010001000100011100010001000100010001110001" + "100010100011001110101101011001001110100110111010100011" + "000110000110110111000001011000110010010101010110100000" + "011110101100010100001110011000100001000000000011101111" + "101010010111001011101001101001011011111100100001100110" + "110010110111001110010010111010101010101111101100101100" + "010010111100101001101011101010101101010000110100100000" + "100010001111111011100100001010111111011111101010101011" + "001110101110001110100000101011001010100011010000101010" + "001010111001011111011100011011011000010001110111100110" + "101110011000100101111110011000100011001011110111101111" + "111110101100111001100001101011110110001010011110100010" + "111111001000100010110011011100010011010001110011110110" + }, + /* 13*/ { -1, -1, 6, "1", -1, 0, 70, 76, 1, "Version F", + "0011111000100010001000100011100010001000100010001110001000100010001000111000" + "0010100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000111000100010001000100011100010001000100010001110001000100010001000111000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000111000100010001000100011100010001000100010001110001000100010001000111000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000010000000000000000000000000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000010000000000000000000000000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000000000000000000000000000000000000000000000000000000" + "0111111111111111111111111111111111111111111111111111111111111111111111111110" + "0100000000000000000000000000000000000000000000000000000000000000000000000010" + "0111111111111111111111111111111111111111111111111111111111111111111111111110" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001110001000100010001000111000100010001000100011100010001000100010001110001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000011011111010101001" + "0001100001000100010001000110000100010001000100011000010001111011011111101101" + "0110101100001000110011100010010001101110011110001010011001110110100001100110" + "1111101111011010000010100010111111101100011011101001001010011000000111100001" + "1101100110100110101000011010111110101010011000011010001011101010101100100001" + "0110111110001001101100001111000011101011100101011101110010001101111001110000" + "0100100100010000000011110010110000101001011011011010110100000101010001101110" + "1110101011010110011110010010101111000100100011011011011011110111000001101010" + "0010101100100000101011100110011110000001100010111000101110111101110110101001" + "0000101100111111111101000010111100010110010000011001110100001110101111101101" + "1101101011000000110000110110010101111111001000111000010110000010100010100100" + "1011100000000011011101000110100110010101001101011001110010010111101101101111" + "1010101001010010110010111110000010100100101111001000101111010101011111100100" + "0001100001110100110100000110010001101111111011101011110000110100110100100000" + "0110101111010001100101000010110001111001111001101011010001001111100001100100" + "1111101011000011001010101110000111001100100011011000010110011100100111101001" + "0100101101010010100110011010000001101000011011111001011101001000011110100101" + "1100111111000110110101110011011001001010010101101111011110000111010100110101" + }, + /* 14*/ { -1, -1, 7, "1", -1, 0, 104, 98, 1, "Version G", + "00111011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00100010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000010000000000000000000000000000000000000000010000000000000000000000000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010011010001000100010001011001000100010001000111000100010001000100011100010001000100010011010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000010011110011001100000110110111011101100001110001100110110000100010100010" + "00010011010001000100010001111101100110011001111111101110111011010110011110011001000000010011010001" + "11110010000000000000111011110011101110011001100110100111000010001000110010100010001000101110101001" + "11101010001000100001011001110001100110010110011010011010010101010101010101010110011001101110110001" + "10011010011111000100010001110001111111111111000010011101110111111100110000100010010110101010101010" + "00010010010010011101110111010100100110011001000110001100110011100100010100010001110111101110101110" + "01001110101110111011100110010110011010100011001110001111001101110111010101011101110111010010110011" + "00101010101010101001111111110111111110000101010110010100010110011001110011101101110111010010110001" + "00110010111001100110011001110001010101010101101010010001000100101000010100010001000101110110110111" + "00010010010000111011101110110000100110011001011110111011101110101010110010101010101010011010011001" + "11010110110111011110100000010000000011011011101110101100110010001000110001010101010101011010101000" + "11111110111111111111010001010001000110000110011010011001011101110111010101010110011001100010110010" + "10001010000100110111011101110110100110011001001010011101110111000001110001100110000011111110111111" + "00100011101011100110011001011101100110011001101111011101110111100111111011101110110010011011011001" + "11110010000000000000101010110010101001111101110110110110100101010101010110100101010101010010101011" + "11000010100010001000010100010100010000110101010110010101110001000100010100001110111011100010001110" + "10111010110001100010001000110101001100110011100110110011001100010001110001100110010100000010000000" + "11101110101110101010101010110110010001000100110110111111111111101100110000100010000101110110110111" + "00010010100010001001010010010010001001000110011010011000000101010101010101110001000100010110001000" + "01110110010101010110101011110011101111101110111010111001100010001000110001000111011101111010001001" + "10001010001000111011101110010100100010001000011110111111111111111101010101010101101001110110110111" + "10011010010001101010101010110001011101110111000110110111011101111001010101010101111011011110011101" + "10010010010001000101011000110000100011011100110010110011110111011101110100110000000000001110010101" + "11111110111111111100010011010011001100000000000010000000001101110111010111111100110011001110010101" + "01010110010110111111111111010101011001100110011010000000000000001110010010001000011000100010100010" + "01010111011110111111111111111010000100010001111011010001000100000111011011001100100100010011010001" + }, + /* 15*/ { -1, -1, 8, "1", -1, 0, 148, 134, 1, "Version H", + "00111011001000100010001000111000100010001000101100100010001000100011100010001000100010110010001000100010001110001000100010001011001000" + "00100010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001011001000100010001000111000100010001000101100100010001000100011100010001000100010110010001000100010001110001000100010001011001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001011001000100010001000111000100010001000101100100010001000100011100010001000100010110010001000100010001110001000100010001011001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001011001000100010001000111000100010001000101100100010001000100011100010001000100010110010001000100010001110001000100010001011001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001011001000100010001000111000100010001000101100100010001000100011100010001000100010110010001000100010001110001000100010001011001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001011001000100010001000111000100010001000101100100010001000100011100010001000100010110010001000100010001110001000100010001011001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "00000010000000000000000000100000000000000000001000000000000000000010000000000000000000100000000000000000001000000000000000000010000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000100000000000000000000000000000000000000010000000000000000000000000000000000000001000000000000000000000000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000100000000000000000000000000000000000000010000000000000000000000000000000000000001000000000000000000000000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010011010001000100010001110001000100010001001101000100010001000111000100010001000100110100010001000100011100010001000100010011010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010011010001000100010001110001000100010001001101000100010001000111000100010001000100110100010001000100011100010001000100010011010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000101000100010001000100010100010001000100010100010001000100010001010001000100010001010001000" + "00010010010001000100010001100001000100010001001001000100010001000110000100010001000100100100010001000100011000010001000100010010010001" + "10001010001000100010001000101000100010001000011010111111111111111110111111111111101010100110011001100110011010011001011011001110001100" + "00010011010001000100010001110001000100010001111110110111011101110111110111011101111111110111011101110111011111011101111111111111111111" + "11001110001100110000100011100011001100110011001011001100111000100010100010001000100010100001000110011001101001100110011001101110100111" + "11111110111111111101101000101000100010001000101000100000101000100010100010001000100010100011111110111011101011101110111011101110000110" + "01110110110111011101110111101000100110011001101001100110011001100110110111011101110111100111011101101000011000010001000100010010010001" + "01100110100110011001100110101110010001000100011000010001000100101010011001100110011001101001100110000001111001110111011101110110110111" + "01101110011101110111011101101101110101101001101001100110011001100110100110101000100010100010001000100010001001101111111111111110111111" + "00010110100110011001100110100110011011100010001010001000100010001010001001101100110011100011001100110011001000110000000000000010000000" + "11111110111010101010101010101010101010101010011010000100010001000110000100010001100010101110111011101110111010111011101010101010101010" + "00000010001110101110111011101011101110111011101001010101010101010110010101010101011100101000100010001000101000100010001101110110110111" + "10101010101010101011000001100001000100010001001001000101000100010010010001000100010001100001000000000000001000000000000000000010111100" + "01110110110111011110010000100000000000000000001000000011101011101110101110111011101110101101011001100110011010011001100110011110100100" + "11001110001100110011001100101100001000100010001010001000100010100110011001100110011001101001100110110110111010111011101110111010111011" + "01000111000100010001000100111011110011001100111100110011001100010011100010001000100010110010001000110111011111011101110111011111011101" + "01000010010001000100010001100001000101010001001001000100010001000110000111100010001000101000100010001000101011001000100010001010001000" + "10111110011101110111011101101101110111000001001001000100010001000110000110100000000000100000000000000000001011001111111111111110111111" + "10001010000010101110111011101011101110111011101001011101110111011110011101110111100000100100010001000100011000010001100010111010111011" + "11111110111111110111011101101101110111011101001000111111111111111110111111111111000101101001100110011001101001100110010000010010010001" + "10111010111011101100101110101110111011101110111010111011110111011110011101110111011101101101101001100110011010011001100110011110011011" + "00010010010001000101110100100100010001000100011000010000111010101010101010101010101010101011111101110111011011011101110111011010110000" + "10111010111011101110111011100000001100110011001011001100110011000010110111011101110111100111011101010101111001110111011101110110110111" + "00000010000000000000000000100000110111011101111001110111011101110110000100010001000100100100010001100110011010011001100110011010011001" + "11110010100010001000100010100010001000110001001001000100010001000110000101100000000000100000000000000000001010100010001000100010100010" + "01010010110011001100110011100011001101010111011011011101110111011110011100100101010101100101010101010101011011101101110111011110011101" + "00100010100100101010101010101010101010101010101001010001000100010010010001000100101100101000100010001000101000100010111100000010000000" + "11011111011111000100010001110001000100010001001101110111011101110111110111011101001101110001000100010001001101000100000101000111000100" + "00000010000000000010100100100100010001000100011000010010111100110010110011001100110011100000101111111111111011111111111111110110010101" + "01000110000100010001101111101111111111111111111011111111101110111010111011101110111011101011110000000000001000000000000000001110010011" + "01010110010101010101010101101111010001000100011000010001000100011010111111111111111111101111111111010001101001100110011001100110100110" + "00110010110011001100110011100100000000000000001000000000000000111110101110111011101110101110111011000011001011001100110011001110001100" + "01010010000000000000000000100000000011000111011011011101110111011110011110011110111011101011101110111011101001101101110111011110011101" + "10101010111011101110111011101011101100011100111000110011001100110010110011001000100010100010001000100010001011010001000100010010010001" + "11011110010001001100110011100011001100110011111010000100010001000110000100010001010001100001000100010001001001000100110101000110000100" + "00010010010110011101110111100111011101110111001010011101110111011110011101110111100111100011001100110011001011001100111100010010010001" + "01000110000100010010100110100110011001100110011010011001100000000010000000000000000000100001101000100010001010001000100010000110101111" + "00010010010001000110110101100101010101010101011001010111000110011010011001100110011001101001001010101010101010101010101010100110010110" + "11111110111111111111111111100101110111011101111001110111011101001010000100010001000100100100010001111001011001010101010101010110010101" + "01100111100110011001100110111101111011101110111110111011101110000111110111011101110111110111011101010001011101010101010101010111010101" + }, + /* 16*/ { -1, -1, 9, "123456", -1, 0, 8, 11, 1, "Version S-10", + "00011110000" + "11000010001" + "10100011100" + "11000011000" + "00000000000" + "11111111111" + "10000000001" + "10111111101" + }, + /* 17*/ { -1, -1, 9, "123456789012", -1, 0, 8, 21, 1, "Version S-20", + "000101110111000010010" + "110101100101011000101" + "100000101001110101100" + "010110101001010001000" + "000000000010000000000" + "111111111111111111111" + "100000000000000000001" + "101111111111111111101" + }, + /* 18*/ { -1, -1, 9, "123456789012345678", -1, 0, 8, 31, 1, "Version S-30", + "0000110111010011100000001111001" + "1110100011011100110110110010111" + "1111100010010100111000011001010" + "1101100000010010010111110001110" + "0000000000000001000000000000000" + "1111111111111111111111111111111" + "1000000000000001000000000000001" + "1011111111111111111111111111101" + }, + /* 19*/ { -1, -1, 10, "ABCDEFGHIJKLM", -1, 0, 16, 17, 1, "Version T-16", + "11100101111100110" + "01101001010011101" + "00101000001011001" + "01000000011110011" + "10010100010001011" + "10101110001001010" + "00101001001001110" + "01101110011001011" + "01111001001110011" + "10000001001101001" + "00000000100000000" + "11111111111111111" + "10000000000000001" + "10111111111111101" + "10000000000000001" + "10111111111111101" + }, + /* 20*/ { -1, -1, 10, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH", -1, 0, 16, 33, 1, "Version T-32", + "111001011110011010010100001011001" + "011010011001110100100000011110011" + "100110101101101100001110001001110" + "101001100101101000000110110110000" + "100011111010011000101011110000100" + "011000110111000000010001111011001" + "010000111111100101010011010011101" + "010110011111011000010111100011110" + "000110111101100001011011000011000" + "101111100010010000100011100000110" + "000000000000000010000000000000000" + "111111111111111111111111111111111" + "100000000000000010000000000000001" + "101111111111111111111111111111101" + "100000000000000000000000000000001" + "101111111111111111111111111111101" + }, + /* 21*/ { -1, -1, 10, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC", -1, 0, 16, 49, 1, "Version T-48", + "1110010111100110001010001010110011001101011011011" + "0110100110011101010000000111100111010011001011010" + "0001110001001110100011110101001100101011110001000" + "0000110110110000011000110011100000010001111010110" + "1100100100001010001111000011111011011111011101111" + "1000101000111101111000000100100110100011011110110" + "0000010001110011111001000001000010101000001001110" + "0000010010111000001000100100111111001101000110011" + "0101010011001000001111000100101010001011010001111" + "1100010001111110010001100010011010010011101100110" + "0000000000000000000000001000000000000000000000000" + "1111111111111111111111111111111111111111111111111" + "1000000000000000000000001000000000000000000000001" + "1011111111111111111111111111111111111111111111101" + "1000000000000000000000001000000000000000000000001" + "1011111111111111111111111111111111111111111111101" + }, + /* 22*/ { -1, -1, -1, "123456789012", -1, 0, 16, 18, 1, "ASCII double digits", + "100011101010111101" + "111010010010100000" + "110110100010001000" + "110010111000010001" + "100010100011010100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010100100101" + "011001001110101101" + "011010010010101111" + "010111110100100111" + "100010001101111100" + }, + /* 23*/ { -1, -1, -1, "1234567890123", -1, 0, 16, 18, 1, "DECIMAL (numeric ending >= 13)", + "111111111111001100" + "000110000110010101" + "100010110111011000" + "000010111100010001" + "100010100011100101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011011101000" + "110111100101101000" + "011011111110101010" + "011011110100101000" + "010000100100111111" + }, + /* 24*/ { -1, -1, -1, "1234567890123A", -1, 0, 16, 18, 1, "ASCII (ending not fully numeric)", + "100011101010111101" + "111010010010100000" + "110110100000110100" + "110010111001000010" + "100010100011101100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010110100100" + "010101000111101010" + "001001000010100110" + "001101100111101010" + "010000000011110011" + }, + /* 25*/ { -1, -1, -1, "GOSGOS", -1, 0, 16, 18, 1, "2 C40 triplets, C40 at end, buffer empty, switch to ASCII before padding (5)", + "111011100010001000" + "011010000100010001" + "100010111110001000" + "000110111100010001" + "100010100000100111" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010010100000" + "011011101100100111" + "111111101001100010" + "110101010100101011" + "100110001001111001" + }, + /* 26*/ { -1, -1, -1, "GOSGOSG", -1, 0, 16, 18, 1, "2 C40 triplets + C40 singlet, C40 at end, singlet in buffer, switch to ASCII before padding (3)", + "111011100010001000" + "011010000100010001" + "100010111101001000" + "000110111110000001" + "100010100011000101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011111101011" + "010101100101101111" + "110010101010101010" + "001000000101101010" + "100101111101110001" + }, + /* 27*/ { -1, -1, -1, "GOSGOSGO", -1, 0, 16, 18, 1, "2 C40 triplets + C40 doublet, C40 at end, doublet in buffer, switch to ASCII for doublet (2 pad)", + "111011100010001000" + "011010000100010001" + "100010111101000101" + "000110111110000000" + "100010100010100100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010000100010" + "010011110001101000" + "101110101100101111" + "110011010011101110" + "010001011100111100" + }, + /* 28*/ { -1, -1, -1, "GOSGOSGOS", -1, 0, 16, 18, 1, "3 C40 triplets, C40 at end, switch to ASCII before padding (3)", + "111011100010001000" + "011010000100010001" + "100010100010001111" + "000110000100011111" + "100010100001110000" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010100100101" + "011101101001100111" + "110000000100101000" + "000011011111101011" + "000011110110110001" + }, + /* 29*/ { -1, -1, -1, "GOSGOSGOSG", -1, 0, 16, 18, 1, "3 C40 triplets + C40 singlet, C40 at end, singlet in buffer, switch to ASCII for singlet (1 pad)", + "111011100010001000" + "011010000100010001" + "100010100010001111" + "000110000100011111" + "010010100000100001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "100000011011100000" + "001111100101101101" + "000001100100100010" + "101001010011100111" + "101111111001110110" + }, + /* 30*/ { -1, -1, -1, "GOSGOSGOSGO", -1, 0, 16, 18, 1, "3 C40 triplets + C40 doublet, C40 at end, doublet in buffer, switch to ASCII for doublet (0 pad)", + "111011100010001000" + "011010000100010001" + "100010100010001111" + "000110000100011111" + "010010010111000001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "100000000011101010" + "110111111011100101" + "111101001000101111" + "110000011111100011" + "001001001110111100" + }, + /* 31*/ { -1, -1, -1, "GOSGOSGOSGOS", -1, 0, 16, 18, 1, "4 C40 triplets, C40 at end, empty buffer, switch to ASCII before padding (1)", + "111011100010001000" + "011010000100010001" + "100010100010001000" + "000110000100010001" + "100010111100100001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000111111110100010" + "101010100011101010" + "111100000000101011" + "001010101010101001" + "110011100111110100" + }, + /* 32*/ { -1, -1, -1, ".GOSGOSGOSGOS", -1, 0, 16, 18, 1, "ASCII + 4 C40 triplets, C40 at end, empty buffer, no switch to ASCII as no padding", + "001011111010001000" + "111110011000010001" + "100010100010001000" + "000110000100010001" + "100010100010110100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010111101010" + "011010010011100110" + "000110111100100111" + "111011101001100000" + "010001000011110110" + }, + /* 33*/ { -1, -1, -1, "ABCDEFGHIJ\001K", -1, 0, 16, 18, 1, "4 C40 triplets (last shifted) + singlet, no unlatch, singlet as ASCII, no padding", + "111011010111100110" + "011010100110011101" + "001010100001011000" + "010010000011111111" + "110010010000111101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "001011001010100001" + "101001001111101001" + "101110101101100110" + "001100001010100011" + "001001000000110110" + }, + /* 34*/ { -1, -1, -1, "ABCDEFGHIJK\001", -1, 0, 22, 22, 1, "4 C40 triplets + singlet (shifted), backtrack to 3rd triplet and ASCII encode", + "1110110101111001100010" + "0110101001100111010100" + "1000100101111101000100" + "0000101111111110111100" + "0000101000100010001000" + "0010100001000100010001" + "1000101000100010000000" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101001" + "1010111010001011101100" + "0011100100111011101111" + "1001100110000000101001" + "1100001010011100100111" + "0011000011111010101111" + "1111110001000011110110" + }, + /* 35*/ { -1, -1, -1, "ABCDEFGH\001I\001", -1, 0, 22, 22, 1, "4 C40 triplets + singlet (shifted), backtrack to 2nd triplet and ASCII encode", + "1110110101111001100010" + "0110101001100111010100" + "1111100100010000000100" + "1111101000100100101010" + "0000101000100010001000" + "0010100001000100010001" + "1000101000100010001010" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101011" + "0110001001011110100100" + "0000011100110101101011" + "0100111101001101101110" + "0010001000101001101100" + "1110110010000110101011" + "1001100010111000111111" + }, + /* 36*/ { -1, -1, -1, "\101\102\103\104\105\106\107\110\200\101\102", -1, 0, 22, 22, 1, "'ABCDEFGH<80>AB' - cte_buffer_transfer with cte_p > 3", + "1110110101111001100010" + "0110101001100111010100" + "1000100100101110001111" + "0000101010101100011111" + "0100100100100010001000" + "0010100011000100010001" + "1000101000100010000110" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001100101" + "1010111100010110100110" + "1001111110011001100011" + "1101111110111000100101" + "1010110011101001101111" + "0111100000001001101001" + "0101000100001100110110" + }, + /* 37*/ { -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, 0, 22, 22, 1, "7 EDI triplets + doublet, doublet encoded as triplet with Shift 0 pad, no switch to ASCII, no padding", + "1110110101111001100010" + "0110101001100111010100" + "1000100101100110011010" + "0000101111001110100110" + "1101101011000111000100" + "0101101010000011011011" + "1110101000111110011010" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0000011000111001101001" + "0110011000110111101101" + "0011100111101100101101" + "1110111011011111101110" + "0011000011001101101000" + "0101100011001011101100" + "0100011100011000110110" + }, + /* 38*/ { -1, -1, -1, "gosgos", -1, 0, 16, 18, 1, "2 TEXT triplets, TEXT at end, buffer empty, switch to ASCII before padding", + "111011100010001000" + "111110000100010001" + "100010111110001000" + "000110111100010001" + "100010100010011101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011000101000" + "110001011110101111" + "000001000110100100" + "000011110000100010" + "101100010110111010" + }, + /* 39*/ { -1, -1, -1, "gosgosg", -1, 0, 16, 18, 1, "2 TEXT triplets + TEXT singlet, TEXT at end, singlet in buffer, switch to ASCII for singlet (3 pads)", + "111011100010001000" + "111110000100010001" + "100010111101101000" + "000110111110000001" + "100010100010000100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011010100100" + "000110100011100010" + "011000001111100101" + "100100000110100110" + "010101111001110000" + }, + /* 40*/ { -1, -1, -1, "gosgosgo", -1, 0, 16, 18, 1, "2 TEXT triplets + TEXT doublet, TEXT at end, doublet in buffer, switch to ASCII for doublet, (2 pads)", + "111011100010001000" + "111110000100010001" + "100010111101100111" + "000110111110000000" + "100010100010110111" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011100101000" + "011110111111100101" + "110000110110101111" + "010010000000100110" + "101001101001111111" + }, + /* 41*/ { -1, -1, -1, ".gosgosgosgos", -1, 0, 16, 18, 1, "ASCII + 4 TEXT triplets, TEXT at end, empty buffer, no switch to ASCII as no padding", + "001011111010001000" + "111110111100010001" + "100010100010001000" + "000110000100010001" + "100010100000011010" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010101101100" + "111000100010101011" + "010110110001101110" + "010110000001101110" + "111001010101110110" + }, + /* 42*/ { -1, -1, -1, "\015*>", -1, 0, 16, 18, 1, "1 EDI triplet, ASCII mode", + "000011001000111000" + "111010101111110001" + "100010100010001000" + "000110000100010001" + "100010100011101000" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011010100110" + "011111010100100100" + "011000001001100100" + "111000011101100111" + "101001101110111110" + }, + /* 43*/ { -1, -1, -1, "\015*>\015", -1, 0, 16, 18, 1, "1 EDI triplet + singlet, ASCII mode", + "000011001000110000" + "111010101111111110" + "100010100010001000" + "000110000100010001" + "100010100001100100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011110101100" + "011000011100100011" + "101010110001100011" + "000110111010101011" + "101001000010111001" + }, + /* 44*/ { -1, -1, -1, "\015*>\015*", -1, 0, 16, 18, 1, "1 EDI triplet + doublet, ASCII mode", + "000011001000110000" + "111010101111111110" + "001010100010001000" + "101110000100010001" + "100010100001010000" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011011100010" + "111101001110101111" + "101010110001101100" + "101100010011101101" + "000010101011111010" + }, + /* 45*/ { -1, -1, -1, "\015*>\015*>", -1, 0, 16, 18, 1, "2 EDI triplets, EDI mode", + "111011000000100000" + "111010000010110000" + "001010111110001000" + "101110111100010001" + "100010100011001100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010110101111" + "100010111100100100" + "000001000000101011" + "111000010111100010" + "110010111011111011" + }, + /* 46*/ { -1, -1, -1, "\015*>\015*>\015", -1, 0, 16, 18, 1, "2 EDI triplets + singlet, EDI mode + final ASCII", + "111011000000100000" + "111010000010110000" + "001010111100001000" + "101110111111100001" + "100010100000101110" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010111100011" + "111011011010101001" + "011110010100100101" + "011111001000100110" + "100011100011110000" + }, + /* 47*/ { -1, -1, -1, "\015*>\015*>\015*", -1, 0, 16, 18, 1, "2 EDI triplets + doublet, EDI + final 2 ASCII", + "111011000000100000" + "111010000010110000" + "001010111100000010" + "101110111111101011" + "100010100000111001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010110100110" + "000010000001101101" + "001001011010101001" + "101001000000100011" + "100011000010110110" + }, + /* 48*/ { -1, -1, -1, "\015*>\015*>\015*>", -1, 0, 16, 18, 1, "3 EDI triplets, EDI mode", + "111011000000100000" + "111010000010110000" + "001010000000101111" + "101110000010111111" + "100010100011011101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011110100100" + "100101000000101000" + "110101100111101110" + "110110000011100000" + "110111100010110011" + }, + /* 49*/ { -1, -1, -1, "\015*>\015*>\015*>\015", -1, 0, 16, 18, 1, "3 EDI triplets + singlet, EDI mode + final ASCII singlet", + "111011000000100000" + "111010000010110000" + "001010000000101111" + "101110000010111111" + "000010100000001001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "111000011011101000" + "110001100000101111" + "101111100101100001" + "000101100111100111" + "011010010010111010" + }, + /* 50*/ { -1, -1, -1, "\015*>\015*>\015*>\015*>", -1, 0, 16, 18, 1, "4 EDI triplets, EDI mode", + "111011000000100000" + "111010000010110000" + "001010000000100000" + "101110000010110000" + "001010111110000011" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "101111110110100011" + "100100100001101111" + "010001111111101001" + "100000101110101011" + "110001000001111000" + }, + /* 51*/ { -1, -1, -1, "\015*>\015*>\015*>\015*>\015", -1, 0, 16, 18, 1, "4 EDI triplets + singlet, EDI mode + nolatch final ASCII singlet (last data codeword of symbol)", + "111011000000100000" + "111010000010110000" + "001010000000100000" + "101110000010110000" + "001010000011000011" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "101111101001101110" + "111111010000101000" + "000011011011101101" + "010111001011101001" + "101010110001111100" + }, + /* 52*/ { -1, -1, -1, "\015*>\015*>\015*>\015*>\015*", -1, 0, 22, 22, 1, "4 EDI triplets + doublet, EDI mode + final 2 ASCII", + "1110110000001000000010" + "1110100000101100001011" + "0000100010000000101111" + "0000101011000010111111" + "0000100010100010001000" + "1110101011000100010001" + "1000101000100010001010" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001100001" + "1011100001010010100111" + "1100001100111101100000" + "0110111110101000100011" + "1100011011101100100101" + "0110100100001000101101" + "0010111010100110111000" + }, + /* 53*/ { -1, -1, -1, "\015*>\015*>a", -1, 0, 16, 18, 1, "2 EDI triplets + ASCII singlet, EDI mode + final ASCII", + "111011000000100000" + "111010000010110000" + "001010111101101000" + "101110111100100001" + "100010100010011001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011000101111" + "101001011011101001" + "111010111100101011" + "100111010011100101" + "011111111010110101" + }, + /* 54*/ { -1, -1, -1, "\015*>\015*>\015*>\015*>a", -1, 0, 16, 18, 1, "4 EDI triplets + ASCII singlet, EDI mode + final ASCII", + "111011000000100000" + "111010000010110000" + "001010000000100000" + "101110000010110000" + "001010011010001000" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "101100100011100101" + "010111100000100111" + "011011111111100010" + "001110101010100111" + "110100010001110011" + }, + /* 55*/ { -1, -1, -1, "\015*>\015*>\015*>\015*>\015a", -1, 0, 22, 22, 1, "4 EDI triplets + singlet + ASCII, EDI mode + final 2 ASCII", + "1110110000001000000010" + "1110100000101100001011" + "0000100010000000101111" + "0000101011000010111111" + "0000100110100010001000" + "1110100010000100010001" + "1000101000100010000110" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101001" + "1100100011001011100000" + "0000100110101010101011" + "0011101011110100100111" + "1001111010011000100000" + "0001110010110111101110" + "1001011011101101111101" + }, + /* 56*/ { -1, -1, -1, "\015*>\015*>\015*>\015*a", -1, 0, 22, 22, 1, "3 EDI triplets + doublet + ASCII, EDI mode + final 3 ASCII", + "1110110000001000000010" + "1110100000101100001011" + "0000100010111100000010" + "0000101011111111101011" + "0110101000100010001000" + "0010100001000100010001" + "1000101000100010000110" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101101" + "1111101100010011101010" + "1101101001000001101110" + "0110100011111011101000" + "1100011001100110101011" + "1011110100111010100000" + "0001111010001000110010" + }, + /* 57*/ { -1, -1, -1, "123456789012345", -1, 0, 16, 18, 1, "5 DECIMAL triplets, ASCII switch before padding (2)", + "111111111111001100" + "000110000110010101" + "100010110101101111" + "000010010110111111" + "100010100011110010" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010011100010" + "101100110010100101" + "111000001001100010" + "100010110110101011" + "111111011010110001" + }, + /* 58*/ { -1, -1, -1, "1234567890123456", -1, 0, 16, 18, 1, "5 DECIMAL triplets + singlet, switch to ASCII before padding (2)", + "111111111111001100" + "000110000110010101" + "100010110101101111" + "000010010110110111" + "100010100010100110" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011110100000" + "111011001101101000" + "101011010111101100" + "000101110010100011" + "010101000001110111" + }, + /* 59*/ { -1, -1, -1, "12345678901234567", -1, 0, 16, 18, 1, "5 DECIMAL triplets + doublet, switch before ASCII encoding of final char, padding (1)", + "111111111111001100" + "000110000110010101" + "100010110101101111" + "000010010110110111" + "001110100011101001" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "100000010101101011" + "101101010000100010" + "011011100001101000" + "011100000111101100" + "100010110100110100" + }, + /* 60*/ { -1, -1, -1, "123456789012345678", -1, 0, 16, 18, 1, "6 DECIMAL triplets, switch to ASCII, padding (1)", + "111111111111001100" + "000110000110010101" + "100010110101101010" + "000010010110100111" + "111110100000101101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "110100010010100001" + "010011110101101011" + "100010000011100100" + "101110000010100101" + "011010011110111101" + }, + /* 61*/ { -1, -1, -1, "1234567890123456789", -1, 0, 16, 18, 1, "6 DECIMAL triplets + singlet, switch before ASCII encoding of singlet, no padding", + "111111111111001100" + "000110000110010101" + "100010110101101010" + "000010010110100111" + "111110001111000011" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "110110100111101001" + "000001010011100011" + "101011011101101100" + "011001101011100100" + "101110111011110000" + }, + /* 62*/ { -1, -1, -1, "12345678901234567890", -1, 0, 16, 18, 1, "6 DECIMAL triplets + doublet, switch before ASCII 2-digit encoding of doublet, no padding", + "111111111111001100" + "000110000110010101" + "100010110101101010" + "000010010110100111" + "111110110110000111" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "110111000010100101" + "110000010000100111" + "011110101001100011" + "111110100110101101" + "001000111011111111" + }, + /* 63*/ { -1, -1, -1, "123456789012345678901", -1, 0, 16, 18, 1, "7 DECIMAL triplets, fills to final codeword, no padding", + "111111111111001100" + "000110000110010101" + "100010110101101010" + "000010010110100111" + "111010101111000101" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000111011011101100" + "000000000110101110" + "001011010101101011" + "111000110101100101" + "110001100000110100" + }, + /* 64*/ { -1, -1, -1, "1234567890123456789012", -1, 0, 16, 18, 1, "7 DECIMAL triplets + singlet, fills to final codeword, no padding", + "111111111111001100" + "000110000110010101" + "100010110101101010" + "000010010110100111" + "111010100010101100" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000111011001101110" + "010110011110101111" + "101000010001101000" + "100111000001100000" + "101000001010111101" + }, + /* 65*/ { -1, -1, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, 0, 16, 49, 1, "T-48 90", + "1111111111001100100011011011010101110100010111110" + "0001000110010101000001010101001110001111010000011" + "0111000100011001010100000010110100111000111101000" + "1011111111001100100011010011010101110100010111110" + "0011101111111100110010000110101101010111010001011" + "0111000100011001010100000010110100111000111101000" + "1110011111101101100001000001001100101010010111010" + "0011101111100111100011110011101001101100010110101" + "0011110011111001001110110011010010001001010011011" + "1000100101011101110111000000111110000010001000010" + "0000000000000000000000001000000000000000000000000" + "1111111111111111111111111111111111111111111111111" + "1000000000000000000000001000000000000000000000001" + "1011111111111111111111111111111111111111111111101" + "1000000000000000000000001000000000000000000000001" + "1011111111111111111111111111111111111111111111101" + }, + /* 66*/ { -1, -1, 10, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", -1, ZINT_ERROR_TOO_LONG, 0, 0, 1, "T-48 89", + "" + }, + /* 67*/ { -1, -1, -1, "A123456789012345678901A", -1, 0, 22, 22, 1, "ASCII + 7 DECIMAL triplets + ASCII", + "0100111111111111001100" + "0010100001000110010101" + "1000101101011010101110" + "0000100101101001110001" + "1011100100100010001000" + "1111100010000100010001" + "1000101000100010001000" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101110" + "0110110011111100100001" + "0100111101011000101001" + "1110011001111101100000" + "0100010001010001101011" + "1010001010001011101101" + "1101101001100001110101" + }, + /* 68*/ { -1, -1, -1, "A1234567890123456789012A", -1, 0, 22, 22, 1, "ASCII + 7 DECIMAL triplets + singlet + ASCII", + "0100111111111111001100" + "0010100001000110010101" + "1000101101011010101110" + "0000100101101001110001" + "1011100011010010001000" + "1111100011001000010001" + "1000101000100010000000" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101000" + "1011001000110010100111" + "0001000000011010100011" + "0100110111001011100110" + "0100110111111110101111" + "0101101010001000100111" + "1110011111011111110100" + }, + /* 69*/ { -1, -1, -1, "A12345678901234567890123A", -1, 0, 22, 22, 1, "ASCII + 7 DECIMAL triplets + doublet + ASCII", + "0100111111111111001100" + "0010100001000110010101" + "1000101101011010101110" + "0000100101101001110001" + "1011101001010010001000" + "1111101001001000010001" + "1000101000100010001110" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101011" + "0100111101100011100011" + "1011010001011001101100" + "0110100100111100100101" + "0000100001000101101101" + "0001111010010111100010" + "0001001001000000110100" + }, + /* 70*/ { -1, -1, -1, "ABCDEFGHI123456789012A", -1, 0, 22, 22, 1, "3 C40 triplets + 4 DECIMAL triplets + ASCII 0 padding", + "1110110101111001100010" + "0110101001100111010100" + "1000100101111110001010" + "0000101111111111100100" + "1011101101110110000100" + "1010100000110011100010" + "1000101000100010001001" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101001" + "1011001000111110100100" + "0010110001001001101100" + "0101101100110101100011" + "1011000110000101101111" + "0011001101000011100011" + "0100110101010110111011" + }, + /* 71*/ { -1, -1, -1, "ABCDEFGHI12345678", -1, 0, 22, 22, 1, "3 C40 triplets + ASCII 2-digits end-of-data", + "1110110101111001100010" + "0110101001100111010100" + "1000100101111110001010" + "0000101111111111100100" + "1011101101100010001000" + "1010100000000100010001" + "1000101000100010001011" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001101011" + "1100001011100110100001" + "0001001101101111100011" + "1101011100100001100101" + "0001011111001001100101" + "1010111111111110101011" + "1101101100101010110101" + }, + /* 72*/ { -1, -1, -1, "ABCDEFGH123456789012345678901A", -1, 0, 22, 22, 1, "2 C40 triplets + doublet + ASCII 2-digits ASCII 0 padding", + "1110110101111001100010" + "0110101001100111010100" + "1000100100111110011010" + "0000101110111110011111" + "1100101101100010011010" + "0101101011001110011111" + "1100101101100001001011" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0101101100110010100111" + "0101100110010101101001" + "1011110110000101100001" + "1001100010001101100000" + "1001001001000101100000" + "0010110111111111101111" + "1010010000100000110111" + }, + /* 73*/ { -1, -1, -1, "\200\200", -1, 0, 16, 18, 1, "BYTE", + "111011000010001000" + "011110001000000000" + "100010100010001000" + "000110000100010001" + "100010100000110111" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011100101011" + "001001101101100111" + "001011110000101001" + "010011001011100111" + "110100011101110111" + }, + /* 74*/ { -1, -1, -1, "\200\200\200\200\200\200\200\200", -1, 0, 16, 18, 1, "BYTE (no padding, byte count 0)", + "111011000010001000" + "011110000000000000" + "100010100010001000" + "000010000000000000" + "100010100010101110" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000000001111100111" + "110101101010101101" + "000011001111100001" + "111101011011100111" + "101110100100111000" + }, + /* 75*/ { -1, -1, -1, "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063", -1, 0, 70, 76, 1, "249 BYTEs + 13 DECIMAL", + "1110111111100010001000100011100010001000100010001110001000100010001000111000" + "0111101001000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000111000100010001000100011100010001000100010001110001000100010001000111000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000111000100010001000100011100010001000100010001110001000100010001000111000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000111111111100101100" + "0000100000000000000000000010000000000000000000001000000000000100011001100101" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000010000000000000000000000000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000010000000000000000000000000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000000000000000000000000000000000000000000000000000000" + "0111111111111111111111111111111111111111111111111111111111111111111111111110" + "0100000000000000000000000000000000000000000000000000000000000000000000000010" + "0111111111111111111111111111111111111111111111111111111111111111111111111110" + "1000101101110110001000100010100010001000100010001010001000100010001000101000" + "0000101111000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001110001000100010001000111000100010001000100011100010001000100010001110001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000000000000111100011" + "0001100001000100010001000110000100010001000100011000010001011011011110101011" + "1101100000111100100110000110000010011011010011001000110100111100000010100110" + "0000100100111111111001000010100000111100001101011011101011111101001111100110" + "0110101100100110110000111110010000101000110001101011010101000100010010100001" + "0101111010111101111000110011000001000111111011101100011100011010010111111110" + "0100101011011100111101100010011101110101001000101000100100000100010010100100" + "0100100011111101111101011110001101010001100011011010001011000000011100100100" + "1110101000101010001110101010010011000001011000001001011001011101010011100101" + "1010101111110111000110011010110101010001111000101010011010100101100100101011" + "1101100111010011110000010010000001101111110111011011101001010001101101100100" + "0011101010101010101100111010110100101000011000001001011000100111011011100001" + "0000100001100100110111010110110010110100000100011000100101111111110101100001" + "1110100010111001100110000110101110000101001110111001010100011110111110100110" + "0110100010111000001101100010011011101101111010111011010100111000101010101101" + "0010100011101011110111110110111001101001100101011000110001000000111100101011" + "0000101101010101000011010110011110110100100111111011100001010010000111100100" + "1101111110001011101100010011101010100111101110111101101000010100111000111001" + }, + /* 76*/ { -1, -1, -1, "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063", -1, 0, 70, 76, 1, "250 BYTEs + 13 DECIMAL", + "1110111111000010001000100011100010001000100010001110001000100010001000111000" + "0111101010000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000111000100010001000100011100010001000100010001110001000100010001000111000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000111000100010001000100011100010001000100010001110001000100010001000111000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1000101000100010001000100010100010001000100010001010001000100010001111101111" + "0000100000000000000000000010000000000000000000001000000000000000000001100001" + "0000100000000000000000000010000000000000000000001000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000010000000000000000000000000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000010000000000000000000000000000000000000000000100000" + "1111111111111111111111111111111111111111111111111111111111111111111111111111" + "0000000000000000000000000000000000000000000000000000000000000000000000000000" + "0111111111111111111111111111111111111111111111111111111111111111111111111110" + "0100000000000000000000000000000000000000000000000000000000000000000000000010" + "0111111111111111111111111111111111111111111111111111111111111111111111111110" + "1100101100100011011101100010100010001000100010001010001000100010001000101000" + "1001100101000011110001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001110001000100010001000111000100010001000100011100010001000100010001110001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100010001000101000" + "0001100001000100010001000110000100010001000100011000010001000100010001100001" + "1000101000100010001000100010100010001000100010001010001000100000010101100010" + "0001100001000100010001000110000100010001000100011000010001100011101101100000" + "1010100001101111100000000010010011001010111100011000101010100011100000101000" + "0111101101100100101100101110010111011011000100011000011000100011100011100101" + "1011101000111001101101000110000010100011001011011011100001101111110110100100" + "0100111100000111001011001011110010000001000011011111001001010100111110110011" + "0110100010101111101100111110110100010111010000011000001100110111110110101010" + "1011100010111111000000000110001101000111110011011011110100010011110010101010" + "0101100001110111111101100110010101110000111111001001111110111100000101101001" + "0000100110000111111101000110010110001100010100111000010000001101001111101111" + "0011101111110000010101101110010111001100111101001010010100010011000100100011" + "0001101011000000100111010010010111001110100111101011100100110010111001101100" + "0110100000111010110101100010101100111100111110111000001101001110001111101010" + "1001101111111101101000110110000000100001011110101000110110101111101111101111" + "1111101110000111111010000110101010100000110100101000001101111101110100101000" + "1011100011101001011011001010110001001010111111111011001001101111010110100011" + "1111101101101101100101000110010011000011110001101001001011010001000001100100" + "1110110001110110001100000011110011001110000101001111000111011001010011111110" + }, + /* 77*/ { -1, -1, -1, "\061\062\063\064\065\066\067\070\071\060\061\062\063\064\065\066\067\070\071\060\061\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063", -1, 0, 104, 98, 1, "21 DECIMAL + 501 BYTEs + 13 DECIMAL", + "11111111111100110010001101011110101011101011111011111100001000100010011010001000100010001011001000" + "00010010011001010100000101110010011100011111011110101100010000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000010000000000000000000000000000000000000000010000000000000000000000000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "10001010001000100010001000110000100011111111110010110010001101110110010010001000100010001010001000" + "00000010000000000000000000010000000000010001100110010100001111000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010011010001000100010001011001000100010001000111000100010001000100011100010001000100010011010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000010101111100110001001110010100000010101111110110000111111110100110000011" + "00010011010001000100010001011010001100101100001111001111110110101000111111011111000101101011001001" + "11100110110111110010111110110011111011000100101010110000100011101010110010110111100011100010101000" + "00111110111100010011100011010001010100010101100010111001111100011110010001110010011000011010000000" + "10100110000000001001011110110001001111100100111010001011111010000001110010100010010110000010011110" + "01011010111101101100001000110000111010100100010110010110101101010011110011000001110100110010100101" + "10101110101000001111001100110010001001100110000110101100100011010001010000100101111000010010000000" + "01100110000011111101000100110011010100101100001010000110111010111000010000110101011100010110001011" + "01001010011110111111000101110011000110110111001110101001110110111000110101110010101010111010000010" + "00111110101000000010010100110010001010001000000110100000101110111010010111010101011001000010100001" + "01100110010110010010111011010110101010110000110110011100010001001101110001011100000001100010100010" + "00000110110101100100101101010001110010001101100110000101111101010100010001000100101000010010011010" + "01100110011110101001000101110111001010111111111110101101111101111101010100000010000111101010100010" + "11011011001011110101010000111111110011010111110111011001011000011010011011000001011110001011011010" + "10011010111000000101101111010110110001011101110110010011101001010000010001101100100110111010111011" + "00010010111011011110110110110111011010101101110010010111111101000011110110001110011000001010111010" + "10101010110001111111010101110110000001011011011010100100100011101011110110101101111111001110100000" + "00110010111100010110011101010000101010110110100010001000110111111100110011101111111001001110000101" + "10110110011111110110101010010111111001100000100110010000101010100110010110110000010101101010010011" + "01101110011000001100101000010101111100010110000110011011011111111110010010110001010011011010010100" + "01011110010111000111001101010000010101011000110110111000000100001110010000010011100100101010110001" + "10001110110111000010110010010000011110111011000010001001110010010111110111010001100000011110001101" + "00100010101001000001101111110011101100101011010010011001100001101000110010111111010000011010000000" + "01001010000100010111101011110000010100101101011110011010010011010101010111011111111010000110100000" + "11001110100000010100001001010010000101101110100110101100011011001110010101111001100100110010001101" + "01110011001111110111010101111010111001011100001111011101001011010000011011001100100000101011000101" + }, + /* 78*/ { -1, -1, -1, "\061\062\063\064\065\066\067\070\071\060\061\062\063\064\065\066\067\070\071\060\061\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063\064\065\066\067\070\071\060\061\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200\061\062\063\064\065\066\067\070\071\060\061\062\063", -1, 0, 104, 98, 1, "21 DECIMAL + 251 BYTEs + 21 DECIMAL + 252 BYTEs 13 DECIMAL", + "11111111111100110010001101011110101011101011111011111100001000100010011010001000100010001011001000" + "00010010011001010100000101110010011100011111011110101000010000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "11111111111100110010001101011110101011101011111011111100001000100010011010001000100010001011001000" + "00010010011001010100000101110010011100011111011110101000100000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001011001000100010001000111000100010001000100011100010001000100010011010001000100010001011001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000010000000000000000000000000000000000000000010000000000000000000000000000" + "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010" + "01111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00000010000000000000000000010000000000000000000010000000000000000000010000000000000000000010000000" + "10001110111111110011001000110101110110001000100010100010001000100010010010001000100010001010001000" + "00000010010001100101010000110111000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010011010001000100010001011001000100010001000111000100010001000100011100010001000100010011010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110000100010001000100010100010001000100010010010001000100010001010001000" + "00010010010001000100010001010001000100010001000110000100010001000100010100010001000100010010010001" + "10001010001000100010001000110011000010101111110110110010100010001101110000110101111001011110011111" + "00010011010001000100010001011001111110010101010111011100110101000111111101011100100000000011100110" + "11001010011011010110001001110100001001000100011010001001011101000111110101001001111100011010010010" + "10000010110001101110010110010001110111011000001110100001000101100100010000011011010000010010011000" + "00010010010011001101011100010100111100011010001010000110000111001010010111011110111100011110110101" + "00000010100100110111111101110000101101010101001110010010110010100100010010111100011011110110001100" + "11010110100100100110010110010101010000010100111110111000110001101101110101000010011101011110000010" + "01100010011111110001001000010110001001011010001110101011100010001011110111111010011100111110010000" + "00101010000111011011000010010111011110110110000010001100110010101111010111000110011110101110000001" + "10000010101000010000100101110001011111110001111110001011111110100110010011001100100110100110001110" + "01000010001011010010101110010011100101000011101110010111101000100100010100011010101110000110010001" + "10000010000001111111101110010100011111101000010010010011101111111001110010100110110010101110101111" + "00110010010111000101110010010101110111000100011010000111001110001001010100111001000000010010101001" + "10011011111110010110100101011011100111100000011111111000100101010111011100000001011100001011011101" + "00010010101111110101101101010001111000011011101010010100001000100101110110110001100111010110101111" + "10110010001011100010101000010010110000110101001010100011111010000101010101001111110000010110000010" + "10001110100001100111011011010100110000011100111110011110000010111011110101100011000001000010011101" + "00010010011011110100110100110001100111101101011110111010111000101010110011100100101001000010000011" + "00011010100000000001011100010111110011110011011010010010001000001011110000110010001000100010010001" + "00011110011101000010010010110010000001011000100010000011110010101001010111001110011110010010101100" + "00111110001100010111011110010111101000000111011010010001101111001101110010110100101010101010001110" + "01100010011111000111101001010111100100110000001110110000100001001001010101100010101001111010011001" + "01100010100000100010000100010000010111111011110010010001111110110110110100110110010001110110010101" + "01010110101110000111010001010011001111110001100110101110101100101101110111100010101111100110000101" + "01101010000000111001110100110111110011111001000110101010111111101011110001100001110101000110111101" + "01111111101011000101001010011010111100011101111011110000111111000110111010011101101111001111011011" + }, + /* 79*/ { -1, 3, -1, "\351", -1, 0, 16, 18, 1, "é in ISO 8859-1", + "100011010101011000" + "000110110111010010" + "100010100011100110" + "001010010110111010" + "100010100001001010" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100010000100101" + "111101010011101001" + "101011100101101010" + "001010011001100100" + "101100110110110101" + }, + /* 80*/ { -1, 899, -1, "\134\134\351\142\154\134\141\150\134", -1, 0, 28, 32, 1, "éblah", + "10001101010101100010001110110101" + "00011011011101001010100101101101" + "01011001010101111001100110100110" + "11011011011101101110100011101101" + "01011001010110011001010101101000" + "11011011010010100111011101100001" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "00001000000000000000000000100000" + "11111111111111111111111111111111" + "00000000000000000000000000100000" + "11111111111111111111111111111111" + "00000000000000000000000000000000" + "01111111111111111111111111111110" + "01000000000000000000000000000010" + "01111111111111111111111111111110" + "10001010001000100010001000101000" + "00011000010001000100010001100001" + "10001010000000110100111111101001" + "00011000010100010010010100101010" + "01111000001000111111111111101111" + "01111011010110101000000101100011" + "11111010000111010011000010100010" + "10001000010111011010111000100111" + "11011011010100010100111000101011" + "11011110101110100011111110110011" + }, + /* 81*/ { GS1_MODE, -1, -1, "[90]12[91]1234567890123A", -1, 0, 22, 22, 1, "Step B4", + "1110111101100011101110" + "1000101100111011000100" + "0000101011111001110001" + "1110101000001110111111" + "0011100100100010001000" + "1111100010000100010001" + "1000101000100010000111" + "0000100000000000100000" + "1111111111111111111111" + "0000000000000000000000" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0100000000000000000010" + "0111111111111111111110" + "0001000100010001100001" + "1001100110011111101011" + "1000101110111110100010" + "0010010011111111100100" + "1110011100011111101010" + "0100001001100001101110" + "1110110100001101111001" + }, + /* 82*/ { GS1_MODE, -1, -1, "[90]12[91]12345", -1, 0, 16, 18, 1, "Step B5", + "111011110110001110" + "100010110011101100" + "111010000010111101" + "010010111011111001" + "100010100000001010" + "000010000000100000" + "111111111111111111" + "000000000000000000" + "011111111111111110" + "010000000000000010" + "011111111111111110" + "000100011001101110" + "101011011100101110" + "111100010101100000" + "011100010001100101" + "101000101000110110" }, }; int data_size = ARRAY_SIZE(data); - char escaped[1024]; - char bwipp_buf[8192]; + char escaped[8192]; + char bwipp_buf[32768]; char bwipp_msg[1024]; for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + int length = testUtilSetSymbol(symbol, BARCODE_CODEONE, data[i].input_mode, data[i].eci, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (generate) { - printf(" /*%3d*/ { %d, \"%s\", %d, %s, %d, %d, %d, \"%s\",\n", - i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, + printf(" /*%3d*/ { %s, %d, %d, \"%s\", %d, %s, %d, %d, %d, \"%s\",\n", + i, testUtilInputModeName(data[i].input_mode), data[i].eci, data[i].option_2, + testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].bwipp_cmp, data[i].comment); - testUtilModulesDump(symbol, " ", "\n"); + if (ret < ZINT_ERROR) { + testUtilModulesDump(symbol, " ", "\n"); + } else { + printf(" \"\"\n"); + } printf(" },\n"); } else { - if (ret < 5) { - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + if (ret < ZINT_ERROR) { + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", + i, symbol->rows, data[i].expected_rows, testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", + i, symbol->width, data[i].expected_width, testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); int width, row; ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); - assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", + i, ret, width, row, testUtilEscape(data[i].data, length, escaped, sizeof(escaped))); if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { if (!data[i].bwipp_cmp) { @@ -324,6 +2583,7 @@ static void test_fuzz(int index, int debug) { for (int i = 0; i < data_size; i++) { if (index != -1 && i != index) continue; + if ((debug & ZINT_DEBUG_TEST_PRINT) && !(debug & ZINT_DEBUG_TEST_LESS_NOISY)) printf("i:%d\n", i); struct zint_symbol *symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); diff --git a/backend/tests/test_eci.c b/backend/tests/test_eci.c index f48b97e6..9ee362d9 100644 --- a/backend/tests/test_eci.c +++ b/backend/tests/test_eci.c @@ -339,25 +339,39 @@ static void test_reduced_charset_input(int index, int debug) { /*202*/ { BARCODE_AZRUNE, UNICODE_MODE, 0, "é", ZINT_ERROR_INVALID_DATA, -1, "Numbers <= 255 only" }, /*203*/ { BARCODE_CODE32, UNICODE_MODE, 0, "é", ZINT_ERROR_INVALID_DATA, -1, "Numbers only" }, /*204*/ { BARCODE_CODEONE, UNICODE_MODE, 0, "é", 0, 0, "" }, - /*205*/ { BARCODE_CODEONE, UNICODE_MODE, 3, "é", ZINT_ERROR_INVALID_OPTION, -1, "Does not support ECI" }, - /*206*/ { BARCODE_CODEONE, UNICODE_MODE, 0, "β", ZINT_ERROR_INVALID_DATA, -1, "β not in ISO 8859-1" }, - /*207*/ { BARCODE_ULTRA, UNICODE_MODE, 0, "é", 0, 0, "" }, - /*208*/ { BARCODE_ULTRA, UNICODE_MODE, 3, "é", 0, 3, "Supports ECI" }, - /*209*/ { BARCODE_ULTRA, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 9, "" }, - /*210*/ { BARCODE_ULTRA, UNICODE_MODE, 9, "β", 0, 9, "" }, - /*211*/ { BARCODE_ULTRA, UNICODE_MODE, 20, "テ", 0, 20, "In Shift JIS" }, - /*212*/ { BARCODE_ULTRA, UNICODE_MODE, 20, "テテ", 0, 20, "In Shift JIS" }, - /*213*/ { BARCODE_ULTRA, UNICODE_MODE, 25, "က", 0, 25, "In UCS-2BE" }, - /*214*/ { BARCODE_ULTRA, UNICODE_MODE, 25, "ကက", 0, 25, "In UCS-2BE" }, - /*215*/ { BARCODE_ULTRA, UNICODE_MODE, 25, "12", 0, 25, "ASCII" }, - /*216*/ { BARCODE_ULTRA, UNICODE_MODE, 26, "テ", 0, 26, "" }, - /*217*/ { BARCODE_ULTRA, UNICODE_MODE, 26, "テテ", 0, 26, "" }, - /*218*/ { BARCODE_ULTRA, UNICODE_MODE, 28, "龘", 0, 28, "U+9F98 in Big5 but not in GB2312" }, - /*219*/ { BARCODE_ULTRA, UNICODE_MODE, 28, "龘龘", 0, 28, "U+9F98 in Big5 but not in GB2312" }, - /*220*/ { BARCODE_ULTRA, UNICODE_MODE, 29, "齄", 0, 29, "U+9F44 in GB2312 but not in Big5" }, - /*221*/ { BARCODE_ULTRA, UNICODE_MODE, 29, "齄齄", 0, 29, "U+9F44 in GB2312 but not in Big5" }, - /*222*/ { BARCODE_ULTRA, UNICODE_MODE, 30, "가", 0, 30, "U+AC00 in KS X 1001" }, - /*223*/ { BARCODE_ULTRA, UNICODE_MODE, 30, "가가", 0, 30, "U+AC00 in KS X 1001" }, + /*205*/ { BARCODE_CODEONE, UNICODE_MODE, 3, "é", 0, 3, "Supports ECI" }, + /*206*/ { BARCODE_CODEONE, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 9, "" }, + /*207*/ { BARCODE_CODEONE, UNICODE_MODE, 9, "β", 0, 9, "" }, + /*208*/ { BARCODE_CODEONE, UNICODE_MODE, 20, "テ", 0, 20, "In Shift JIS" }, + /*209*/ { BARCODE_CODEONE, UNICODE_MODE, 20, "テテ", 0, 20, "In Shift JIS" }, + /*210*/ { BARCODE_CODEONE, UNICODE_MODE, 25, "က", 0, 25, "In UCS-2BE" }, + /*211*/ { BARCODE_CODEONE, UNICODE_MODE, 25, "ကက", 0, 25, "In UCS-2BE" }, + /*212*/ { BARCODE_CODEONE, UNICODE_MODE, 25, "12", 0, 25, "ASCII" }, + /*213*/ { BARCODE_CODEONE, UNICODE_MODE, 26, "テ", 0, 26, "" }, + /*214*/ { BARCODE_CODEONE, UNICODE_MODE, 26, "テテ", 0, 26, "" }, + /*215*/ { BARCODE_CODEONE, UNICODE_MODE, 28, "龘", 0, 28, "U+9F98 in Big5 but not in GB2312" }, + /*216*/ { BARCODE_CODEONE, UNICODE_MODE, 28, "龘龘", 0, 28, "U+9F98 in Big5 but not in GB2312" }, + /*217*/ { BARCODE_CODEONE, UNICODE_MODE, 29, "齄", 0, 29, "U+9F44 in GB2312 but not in Big5" }, + /*218*/ { BARCODE_CODEONE, UNICODE_MODE, 29, "齄齄", 0, 29, "U+9F44 in GB2312 but not in Big5" }, + /*219*/ { BARCODE_CODEONE, UNICODE_MODE, 30, "가", 0, 30, "U+AC00 in KS X 1001" }, + /*220*/ { BARCODE_CODEONE, UNICODE_MODE, 30, "가가", 0, 30, "U+AC00 in KS X 1001" }, + /*221*/ { BARCODE_ULTRA, UNICODE_MODE, 0, "é", 0, 0, "" }, + /*222*/ { BARCODE_ULTRA, UNICODE_MODE, 3, "é", 0, 3, "Supports ECI" }, + /*223*/ { BARCODE_ULTRA, UNICODE_MODE, 0, "β", ZINT_WARN_USES_ECI, 9, "" }, + /*224*/ { BARCODE_ULTRA, UNICODE_MODE, 9, "β", 0, 9, "" }, + /*225*/ { BARCODE_ULTRA, UNICODE_MODE, 20, "テ", 0, 20, "In Shift JIS" }, + /*226*/ { BARCODE_ULTRA, UNICODE_MODE, 20, "テテ", 0, 20, "In Shift JIS" }, + /*227*/ { BARCODE_ULTRA, UNICODE_MODE, 25, "က", 0, 25, "In UCS-2BE" }, + /*228*/ { BARCODE_ULTRA, UNICODE_MODE, 25, "ကက", 0, 25, "In UCS-2BE" }, + /*229*/ { BARCODE_ULTRA, UNICODE_MODE, 25, "12", 0, 25, "ASCII" }, + /*230*/ { BARCODE_ULTRA, UNICODE_MODE, 26, "テ", 0, 26, "" }, + /*231*/ { BARCODE_ULTRA, UNICODE_MODE, 26, "テテ", 0, 26, "" }, + /*232*/ { BARCODE_ULTRA, UNICODE_MODE, 28, "龘", 0, 28, "U+9F98 in Big5 but not in GB2312" }, + /*233*/ { BARCODE_ULTRA, UNICODE_MODE, 28, "龘龘", 0, 28, "U+9F98 in Big5 but not in GB2312" }, + /*234*/ { BARCODE_ULTRA, UNICODE_MODE, 29, "齄", 0, 29, "U+9F44 in GB2312 but not in Big5" }, + /*235*/ { BARCODE_ULTRA, UNICODE_MODE, 29, "齄齄", 0, 29, "U+9F44 in GB2312 but not in Big5" }, + /*236*/ { BARCODE_ULTRA, UNICODE_MODE, 30, "가", 0, 30, "U+AC00 in KS X 1001" }, + /*237*/ { BARCODE_ULTRA, UNICODE_MODE, 30, "가가", 0, 30, "U+AC00 in KS X 1001" }, }; int data_size = ARRAY_SIZE(data); diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index 781f6d1f..cd0012a5 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -244,7 +244,7 @@ static void test_buffer(int index, int generate, int debug) { /*120*/ { BARCODE_DBAR_OMNSTK_CC, "1234567890123", "[20]01", 80, 11, 56, 112, 160 }, /*121*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901231", "[20]01", 78, 9, 102, 204, 156 }, /*122*/ { BARCODE_CHANNEL, "01", "", 50, 1, 19, 38, 116 }, - /*123*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, + /*123*/ { BARCODE_CODEONE, "12345678901234567890", "", 16, 16, 18, 36, 32 }, /*124*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, /*125*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, /*126*/ { BARCODE_ULTRA, "1234567890", "", 13, 13, 18, 36, 26 }, diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index 7f9aaacd..30c5b220 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -225,46 +225,47 @@ static void test_buffer_vector(int index, int generate, int debug) { /* 84*/ { BARCODE_ITF14, "1234567890", "", 50, 1, 135, 330, 138.89999 }, /* 85*/ { BARCODE_KIX, "123456ABCDE", "", 8, 3, 87, 174, 16 }, /* 86*/ { BARCODE_AZTEC, "1234567890AB", "", 15, 15, 15, 30, 30 }, - /* 87*/ { BARCODE_DPD, "0123456789012345678901234567", "", 50, 1, 189, 378, 118.9 }, - /* 88*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, - /* 89*/ { BARCODE_HIBC_128, "1234567890", "", 50, 1, 123, 246, 118.9 }, - /* 90*/ { BARCODE_HIBC_39, "1234567890", "", 50, 1, 223, 446, 118.9 }, - /* 91*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, - /* 92*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, - /* 93*/ { BARCODE_HIBC_PDF, "1234567890", "", 24, 8, 103, 206, 48 }, - /* 94*/ { BARCODE_HIBC_MICPDF, "1234567890", "", 28, 14, 38, 76, 56 }, - /* 95*/ { BARCODE_HIBC_BLOCKF, "1234567890", "", 30, 3, 101, 242, 64 }, - /* 96*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, - /* 97*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32, 22 }, - /* 98*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, - /* 99*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, - /*100*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, - /*101*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118.9 }, - /*102*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 116.4 }, - /*103*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 116.4 }, - /*104*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 116.4 }, - /*105*/ { BARCODE_EANX_CC, "1234567", "[20]01", 50, 8, 72, 172, 116.4 }, - /*106*/ { BARCODE_EANX_CC, "1234567+12", "[20]01", 50, 8, 99, 226, 116.4 }, - /*107*/ { BARCODE_EANX_CC, "1234567+12345", "[20]01", 50, 8, 126, 280, 116.4 }, - /*108*/ { BARCODE_GS1_128_CC, "[01]12345678901231", "[20]01", 50, 5, 145, 290, 118.9 }, - /*109*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60.900002 }, - /*110*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 79, 158, 56.900002 }, - /*111*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901231", "[20]01", 41, 5, 134, 268, 100.9 }, - /*112*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 116.4 }, - /*113*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 116.4 }, - /*114*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 116.4 }, - /*115*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 116.4 }, - /*116*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 116.4 }, - /*117*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 116.4 }, - /*118*/ { BARCODE_DBAR_STK_CC, "1234567890123", "[20]01", 24, 9, 56, 112, 48 }, - /*119*/ { BARCODE_DBAR_OMNSTK_CC, "1234567890123", "[20]01", 80, 11, 56, 112, 160 }, - /*120*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901231", "[20]01", 78, 9, 102, 204, 156 }, - /*121*/ { BARCODE_CHANNEL, "01", "", 50, 1, 19, 38, 118.9 }, - /*122*/ { BARCODE_CODEONE, "12345678901234567890", "", 22, 22, 22, 44, 44 }, - /*123*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, - /*124*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, - /*125*/ { BARCODE_ULTRA, "1234567890", "", 13, 13, 18, 36, 26 }, - /*126*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, + /* 87*/ { BARCODE_DAFT, "DAFTDAFTDAFTDAFT", "", 8, 3, 31, 62, 16 }, + /* 88*/ { BARCODE_DPD, "0123456789012345678901234567", "", 50, 1, 189, 378, 118.9 }, + /* 89*/ { BARCODE_MICROQR, "12345", "", 11, 11, 11, 22, 22 }, + /* 90*/ { BARCODE_HIBC_128, "1234567890", "", 50, 1, 123, 246, 118.9 }, + /* 91*/ { BARCODE_HIBC_39, "1234567890", "", 50, 1, 223, 446, 118.9 }, + /* 92*/ { BARCODE_HIBC_DM, "ABC", "", 12, 12, 12, 24, 24 }, + /* 93*/ { BARCODE_HIBC_QR, "1234567890AB", "", 21, 21, 21, 42, 42 }, + /* 94*/ { BARCODE_HIBC_PDF, "1234567890", "", 24, 8, 103, 206, 48 }, + /* 95*/ { BARCODE_HIBC_MICPDF, "1234567890", "", 28, 14, 38, 76, 56 }, + /* 96*/ { BARCODE_HIBC_BLOCKF, "1234567890", "", 30, 3, 101, 242, 64 }, + /* 97*/ { BARCODE_HIBC_AZTEC, "1234567890AB", "", 19, 19, 19, 38, 38 }, + /* 98*/ { BARCODE_DOTCODE, "ABC", "", 11, 11, 16, 32, 22 }, + /* 99*/ { BARCODE_HANXIN, "1234567890AB", "", 23, 23, 23, 46, 46 }, + /*100*/ { BARCODE_MAILMARK, "01000000000000000AA00AA0A", "", 10, 3, 155, 310, 20 }, + /*101*/ { BARCODE_AZRUNE, "255", "", 11, 11, 11, 22, 22 }, + /*102*/ { BARCODE_CODE32, "12345678", "", 50, 1, 103, 206, 118.9 }, + /*103*/ { BARCODE_EANX_CC, "123456789012", "[20]01", 50, 7, 99, 234, 116.4 }, + /*104*/ { BARCODE_EANX_CC, "123456789012+12", "[20]01", 50, 7, 126, 284, 116.4 }, + /*105*/ { BARCODE_EANX_CC, "123456789012+12345", "[20]01", 50, 7, 153, 338, 116.4 }, + /*106*/ { BARCODE_EANX_CC, "1234567", "[20]01", 50, 8, 72, 172, 116.4 }, + /*107*/ { BARCODE_EANX_CC, "1234567+12", "[20]01", 50, 8, 99, 226, 116.4 }, + /*108*/ { BARCODE_EANX_CC, "1234567+12345", "[20]01", 50, 8, 126, 280, 116.4 }, + /*109*/ { BARCODE_GS1_128_CC, "[01]12345678901231", "[20]01", 50, 5, 145, 290, 118.9 }, + /*110*/ { BARCODE_DBAR_OMN_CC, "1234567890123", "[20]01", 21, 5, 100, 200, 60.900002 }, + /*111*/ { BARCODE_DBAR_LTD_CC, "1234567890123", "[20]01", 19, 6, 79, 158, 56.900002 }, + /*112*/ { BARCODE_DBAR_EXP_CC, "[01]12345678901231", "[20]01", 41, 5, 134, 268, 100.9 }, + /*113*/ { BARCODE_UPCA_CC, "12345678901", "[20]01", 50, 7, 99, 234, 116.4 }, + /*114*/ { BARCODE_UPCA_CC, "12345678901+12", "[20]01", 50, 7, 128, 284, 116.4 }, + /*115*/ { BARCODE_UPCA_CC, "12345678901+12345", "[20]01", 50, 7, 155, 338, 116.4 }, + /*116*/ { BARCODE_UPCE_CC, "1234567", "[20]01", 50, 9, 55, 142, 116.4 }, + /*117*/ { BARCODE_UPCE_CC, "1234567+12", "[20]01", 50, 9, 82, 192, 116.4 }, + /*118*/ { BARCODE_UPCE_CC, "1234567+12345", "[20]01", 50, 9, 109, 246, 116.4 }, + /*119*/ { BARCODE_DBAR_STK_CC, "1234567890123", "[20]01", 24, 9, 56, 112, 48 }, + /*120*/ { BARCODE_DBAR_OMNSTK_CC, "1234567890123", "[20]01", 80, 11, 56, 112, 160 }, + /*121*/ { BARCODE_DBAR_EXPSTK_CC, "[01]12345678901231", "[20]01", 78, 9, 102, 204, 156 }, + /*122*/ { BARCODE_CHANNEL, "01", "", 50, 1, 19, 38, 118.9 }, + /*123*/ { BARCODE_CODEONE, "12345678901234567890", "", 16, 16, 18, 36, 32 }, + /*124*/ { BARCODE_GRIDMATRIX, "ABC", "", 18, 18, 18, 36, 36 }, + /*125*/ { BARCODE_UPNQR, "1234567890AB", "", 77, 77, 77, 154, 154 }, + /*126*/ { BARCODE_ULTRA, "1234567890", "", 13, 13, 18, 36, 26 }, + /*127*/ { BARCODE_RMQR, "12345", "", 11, 11, 27, 54, 22 }, }; int data_size = sizeof(data) / sizeof(struct item); diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 07ab955f..7b67f872 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -2285,13 +2285,40 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int bwipp_opts = bwipp_opts_buf; } } else if (symbology == BARCODE_CODEONE) { + if ((symbol->input_mode & 0x07) == GS1_MODE) { /* Hack pseudo-GS1 support */ + int last_ai, ai_latch = 0; + for (int i = 0, j = 0, len = (int) strlen(bwipp_data); i <= len; i++) { /* Reduce square brackets (include NUL) */ + if (bwipp_data[i] == '[') { + if (ai_latch == 0) { + bwipp_data[j++] = '['; + } + last_ai = atoi(bwipp_data + i + 1); + if ((last_ai >= 0 && last_ai <= 4) || (last_ai >= 11 && last_ai <= 20) || last_ai == 23 || (last_ai >= 31 && last_ai <= 36) || last_ai == 41) { + ai_latch = 1; + } + } else if (bwipp_data[i] != ']') { + bwipp_data[j++] = bwipp_data[i]; + } + } + for (int len = (int) strlen(bwipp_data), i = len - 1; i >= 0; i--) { /* Replace square brackets with ^FNC1 */ + if (bwipp_data[i] == '[') { + memmove(bwipp_data + i + 5, bwipp_data + i + 1, len - i); + memcpy(bwipp_data + i, "^FNC1", 5); + len += 4; + } + } + if (symbol->eci == 0) { /* If not already done for ECI */ + sprintf(bwipp_opts_buf + (int) strlen(bwipp_opts_buf), "%sparsefnc", strlen(bwipp_opts_buf) ? " " : ""); + bwipp_opts = bwipp_opts_buf; + } + } if (option_2 >= 1 && option_2 <= 10) { static const char *codeone_versions[] = { "A", "B", "C", "D", "E", "F", "G", "H" }; const char *codeone_version; if (option_2 == 9) { codeone_version = length <= 6 ? "S-10" : length <= 12 ? "S-20" : "S-30"; } else if (option_2 == 10) { - codeone_version = "T-16"; // TODO: Allow for different T sizes + codeone_version = length <= 22 ? "T-16" : length <= 34 ? "T-32" : "T-48"; // TODO: Properly allow for different T sizes } else { codeone_version = codeone_versions[option_2 - 1]; } @@ -2339,13 +2366,13 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int } if (bwipp_opts) { - if (data_len >= 2043) { /* Ghostscript's `arg_str_max` 2048 less "-sd=" */ + if (strlen(bwipp_data) >= 2043) { /* Ghostscript's `arg_str_max` 2048 less "-sd=" */ sprintf(cmd, cmd_opts_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043, bwipp_opts); } else { sprintf(cmd, cmd_opts_fmt, bwipp_barcode, bwipp_data, bwipp_opts); } } else { - if (data_len >= 2043) { + if (strlen(bwipp_data) >= 2043) { sprintf(cmd, cmd_fmt2, bwipp_barcode, bwipp_data, bwipp_data + 2043); } else { sprintf(cmd, cmd_fmt, bwipp_barcode, bwipp_data); diff --git a/backend/tests/tools/bwipp_dump-barcode.ps.diff b/backend/tests/tools/bwipp_dump-barcode.ps.diff index fc17cac0..4b148daf 100644 --- a/backend/tests/tools/bwipp_dump-barcode.ps.diff +++ b/backend/tests/tools/bwipp_dump-barcode.ps.diff @@ -1,6 +1,6 @@ ---- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2021-01-28 22:23:05.208873553 +0000 -+++ ../tools/bwipp_dump.ps 2021-01-28 23:31:03.965490583 +0000 -@@ -26135,34 +26135,80 @@ +--- ../../../../postscriptbarcode/build/monolithic/barcode.ps 2021-02-03 09:22:12.524526773 +0000 ++++ ../tools/bwipp_dump.ps 2021-02-03 09:22:48.752086756 +0000 +@@ -26162,34 +26162,80 @@ pop } ifelse @@ -100,7 +100,7 @@ end -@@ -26221,7 +26267,7 @@ +@@ -26248,7 +26294,7 @@ pop } ifelse @@ -109,7 +109,7 @@ % Get the result of encoding with ean8 and gs1-cc options (lintype) (ean8) put -@@ -26229,29 +26275,75 @@ +@@ -26256,29 +26302,75 @@ options (dontdraw) true put % Plot the linear part @@ -205,7 +205,7 @@ end -@@ -26310,34 +26402,80 @@ +@@ -26337,34 +26429,80 @@ pop } ifelse @@ -305,7 +305,7 @@ end -@@ -26411,34 +26549,80 @@ +@@ -26438,34 +26576,80 @@ /opt options >> def @@ -405,7 +405,7 @@ end -@@ -26497,7 +26681,7 @@ +@@ -26524,7 +26708,7 @@ pop } ifelse @@ -414,7 +414,7 @@ options (lintype) (databaromni) put options (linkage) true put -@@ -26508,7 +26692,7 @@ +@@ -26535,7 +26719,7 @@ linear options //databaromni exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -423,7 +423,7 @@ % Plot the separator /sepfinder { -@@ -26539,20 +26723,66 @@ +@@ -26566,20 +26750,66 @@ sep 0 [0 0 0] putinterval sep sep length 4 sub [0 0 0 0] putinterval 18 sepfinder 64 sepfinder @@ -502,7 +502,7 @@ end -@@ -26610,7 +26840,7 @@ +@@ -26637,7 +26867,7 @@ pop } ifelse @@ -511,7 +511,7 @@ options (lintype) (databarstacked) put options (linkage) true put -@@ -26621,7 +26851,7 @@ +@@ -26648,7 +26878,7 @@ linear options //databarstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -520,7 +520,7 @@ % Plot the separator /sepfinder { -@@ -26649,20 +26879,52 @@ +@@ -26676,20 +26906,52 @@ sep 0 [ 0 0 0 0 ] putinterval sep sep length 4 sub [ 0 0 0 0 ] putinterval 18 sepfinder @@ -585,7 +585,7 @@ end -@@ -26720,7 +26982,7 @@ +@@ -26747,7 +27009,7 @@ pop } ifelse @@ -594,7 +594,7 @@ options (lintype) (databarstackedomni) put options (linkage) true put -@@ -26731,7 +26993,7 @@ +@@ -26758,7 +27020,7 @@ linear options //databarstackedomni exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -603,7 +603,7 @@ % Plot the separator /sepfinder { -@@ -26759,20 +27021,52 @@ +@@ -26786,20 +27048,52 @@ sep 0 [ 0 0 0 0 ] putinterval sep sep length 4 sub [ 0 0 0 0 ] putinterval 18 sepfinder @@ -668,7 +668,7 @@ end -@@ -26945,7 +27239,7 @@ +@@ -26972,7 +27266,7 @@ pop } ifelse @@ -677,7 +677,7 @@ options (lintype) (databarlimited) put options (linkage) true put -@@ -26956,7 +27250,7 @@ +@@ -26983,7 +27277,7 @@ linear options //databarlimited exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -686,7 +686,7 @@ % Plot the separator mark -@@ -26964,22 +27258,68 @@ +@@ -26991,22 +27285,68 @@ counttomark 1 sub array astore /sep exch def pop pop sep 0 [0 0 0] putinterval sep sep length 9 sub [0 0 0 0 0 0 0 0 0] putinterval % 4 + 5 right guard spaces @@ -769,7 +769,7 @@ end -@@ -27038,7 +27378,7 @@ +@@ -27065,7 +27405,7 @@ pop } ifelse @@ -778,7 +778,7 @@ options (lintype) (databarexpanded) put options (linkage) true put -@@ -27049,7 +27389,7 @@ +@@ -27076,7 +27416,7 @@ linear options //databarexpanded exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -787,7 +787,7 @@ % Plot the separator /sepfinder { -@@ -27078,20 +27418,60 @@ +@@ -27105,20 +27445,60 @@ 18 98 bot length 13 sub {} for 69 98 bot length 13 sub {} for ] {sepfinder} forall @@ -860,7 +860,7 @@ end -@@ -27149,7 +27529,7 @@ +@@ -27176,7 +27556,7 @@ pop } ifelse @@ -869,7 +869,7 @@ options (lintype) (databarexpandedstacked) put options (linkage) true put -@@ -27160,7 +27540,7 @@ +@@ -27187,7 +27567,7 @@ linear options //databarexpandedstacked exec dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def dup (pixy) get /linheight exch def @@ -878,7 +878,7 @@ % Plot the separator /sepfinder { -@@ -27186,21 +27566,49 @@ +@@ -27213,21 +27593,49 @@ 19 98 bot length 13 sub {} for 70 98 bot length 13 sub {} for ] {sepfinder} forall @@ -941,7 +941,7 @@ end -@@ -27259,7 +27667,7 @@ +@@ -27286,7 +27694,7 @@ pop } ifelse @@ -950,7 +950,7 @@ options (inkspread) (0) put options (dontdraw) true put -@@ -27286,35 +27694,87 @@ +@@ -27313,35 +27721,87 @@ linear << options {} forall >> //gs1-128 exec dup (sbs) get /linsbs exch def dup (bhs) get 0 get 72 mul /linheight exch def @@ -1052,7 +1052,7 @@ end -@@ -28745,3 +29205,183 @@ +@@ -28772,3 +29232,183 @@ % --END ENCODER hibcazteccode-- % --END TEMPLATE-- diff --git a/backend/tests/tools/bwipp_dump.ps.tar.xz b/backend/tests/tools/bwipp_dump.ps.tar.xz index 36feb18d..ad403973 100644 Binary files a/backend/tests/tools/bwipp_dump.ps.tar.xz and b/backend/tests/tools/bwipp_dump.ps.tar.xz differ diff --git a/frontend/main.c b/frontend/main.c index 1a5f129b..0f20f53d 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifndef _MSC_VER #include #include @@ -32,6 +33,10 @@ #include "zint.h" #endif +/* It's assumed that int is at least 32 bits, the following will compile-time fail if not + * https://stackoverflow.com/a/1980056/664741 */ +typedef int static_assert_int_at_least_32bits[CHAR_BIT != 8 || sizeof(int) < 4 ? -1 : 1]; + #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif @@ -201,8 +206,11 @@ static int validate_int(const char source[], int *p_val) { int i; int length = (int) strlen(source); + if (length > 9) { /* Prevent overflow */ + length = 9; + } for (i = 0; i < length; i++) { - if (source[i] < '0' || source[i] > '9' || val < 0) { /* Neg test checks for overflow */ + if (source[i] < '0' || source[i] > '9') { return 0; } val *= 10; diff --git a/frontend_qt/grpCodeOne.ui b/frontend_qt/grpCodeOne.ui index 6349ed8a..ed09645c 100644 --- a/frontend_qt/grpCodeOne.ui +++ b/frontend_qt/grpCodeOne.ui @@ -120,6 +120,10 @@ GS&1 Data Mode + + GS1 system (Application Identifiers) +(ignored if disabled) + diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 63f65ba5..1c3e744e 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -1151,6 +1151,7 @@ void MainWindow::set_gs1_mode(bool gs1_mode) void MainWindow::update_preview() { int symbology = metaObject()->enumerator(0).value(bstyle->currentIndex()); + int recheck_eci = true; int width = view->geometry().width(); int height = view->geometry().height(); int item_val; @@ -1537,8 +1538,16 @@ void MainWindow::update_preview() case BARCODE_CODEONE: m_bc.bc.setSymbol(BARCODE_CODEONE); - set_gs1_mode(m_optionWidget->findChild("radC1GS1")->isChecked()); m_bc.bc.setOption2(m_optionWidget->findChild("cmbC1Size")->currentIndex()); + if (m_bc.bc.option2() == 9) { // Version S + recheck_eci = false; + cmbECI->setEnabled(false); + lblECI->setEnabled(false); + m_optionWidget->findChild("radC1GS1")->setEnabled(false); + } else { + m_optionWidget->findChild("radC1GS1")->setEnabled(true); + set_gs1_mode(m_optionWidget->findChild("radC1GS1")->isChecked()); + } break; case BARCODE_CODE49: @@ -1591,8 +1600,10 @@ void MainWindow::update_preview() m_symbology = m_bc.bc.symbol(); /* Recheck ECI and Reader Init */ - cmbECI->setEnabled(m_bc.bc.supportsECI()); - lblECI->setEnabled(cmbECI->isEnabled()); + if (recheck_eci) { + cmbECI->setEnabled(m_bc.bc.supportsECI()); + lblECI->setEnabled(cmbECI->isEnabled()); + } chkRInit->setEnabled(m_bc.bc.supportsReaderInit() && (m_bc.bc.inputMode() & 0x07) != GS1_MODE); if (!grpComposite->isHidden() && chkComposite->isChecked())