diff --git a/ChangeLog b/ChangeLog index 75fae057..bc9339f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Version 2.16.0.9 (dev) not released yet (2026-04-22) +Version 2.16.0.9 (dev) not released yet (2026-04-27) ==================================================== **Incompatible changes** @@ -34,8 +34,9 @@ Changes - DATAMATRIX: new options "--dmb256=" (`option_3 = DM_B256_START`) & "--dmc40=" (`option_3 = DM_C40_START`) to allow forcing of initial encodation for given no. (`option_1`) of initial characters, with 0 meaning all -- DATAMATRIX: add manual FNC1 support -- AUSPOST: support Null FCC (DPID all zeroes) +- AZTEC/DATAMATRIX: add manual FNC1 support +- AUSPOST: support FCC 00 Null (DPID all zeroes) and allow variable length data + input Bugs ---- diff --git a/backend/2of5inter_based.c b/backend/2of5inter_based.c index 1cc3683a..59d6c737 100644 --- a/backend/2of5inter_based.c +++ b/backend/2of5inter_based.c @@ -41,7 +41,7 @@ INTERNAL int zint_c25_inter_common(struct zint_symbol *symbol, unsigned char sou /* Interleaved 2-of-5 (ITF-14) */ INTERNAL int zint_itf14(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, error_number, zeroes; + int i, error_number; unsigned char local_source[14]; unsigned char have_check_digit = '\0'; unsigned char check_digit; @@ -70,11 +70,7 @@ INTERNAL int zint_itf14(struct zint_symbol *symbol, unsigned char source[], int } /* Add leading zeros as required */ - zeroes = 13 - length; - for (i = 0; i < zeroes; i++) { - local_source[i] = '0'; - } - memcpy(local_source + zeroes, source, length); + z_zero_fill(source, length, local_source, 13); /* Calculate the check digit - the same method used for EAN-13 */ check_digit = (unsigned char) zint_gs1_check_digit(local_source, 13); @@ -128,7 +124,6 @@ INTERNAL int zint_dpleit(struct zint_symbol *symbol, unsigned char source[], int unsigned int count; int factor; unsigned char local_source[14]; - int zeroes; count = 0; if (length > 13) { @@ -139,10 +134,7 @@ INTERNAL int zint_dpleit(struct zint_symbol *symbol, unsigned char source[], int "Invalid character at position %d in input (digits only)", i); } - zeroes = 13 - length; - for (i = 0; i < zeroes; i++) - local_source[i] = '0'; - memcpy(local_source + zeroes, source, length); + z_zero_fill(source, length, local_source, 13); factor = 4; for (i = 12; i >= 0; i--) { @@ -169,7 +161,7 @@ INTERNAL int zint_dpleit(struct zint_symbol *symbol, unsigned char source[], int /* Deutsche Post Identcode */ /* See dpleit() for (sort of) documentation reference */ INTERNAL int zint_dpident(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, error_number, zeroes; + int i, error_number; unsigned int count; int factor; unsigned char local_source[12]; @@ -183,10 +175,7 @@ INTERNAL int zint_dpident(struct zint_symbol *symbol, unsigned char source[], in "Invalid character at position %d in input (digits only)", i); } - zeroes = 11 - length; - for (i = 0; i < zeroes; i++) - local_source[i] = '0'; - memcpy(local_source + zeroes, source, length); + z_zero_fill(source, length, local_source, 11); factor = 4; for (i = 10; i >= 0; i--) { diff --git a/backend/auspost.c b/backend/auspost.c index fb679ddb..d78f96e1 100644 --- a/backend/auspost.c +++ b/backend/auspost.c @@ -30,10 +30,15 @@ */ /* SPDX-License-Identifier: BSD-3-Clause */ +#include +#include +#include "common.h" +#include "reedsol.h" + static const char AusGDSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #"; #define AUS_GDSET_F (IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F) -/* The contents of data_pattern conform to the following standard: +/* The contents of encoding tables and data pattern `dest[]` conform to the following standard: 0 = Tracker, Ascender and Descender 1 = Tracker and Ascender 2 = Tracker and Descender @@ -46,55 +51,38 @@ static const char AusNTable[10][2] = { /* C Encoding Table (GDSET) */ static const char AusCTable[64][3] = { - { 2,2,2 }, { 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,1,0 }, {3,1,1 }, - { 3,1,2 }, { 3,2,0 }, { 3,2,1 }, { 3,2,2 }, { 0,0,0 }, {0,0,1 }, - { 0,0,2 }, { 0,1,0 }, { 0,1,1 }, { 0,1,2 }, { 0,2,0 }, {0,2,1 }, - { 0,2,2 }, { 1,0,0 }, { 1,0,1 }, { 1,0,2 }, { 1,1,0 }, {1,1,1 }, - { 1,1,2 }, { 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 2,0,0 }, {2,0,1 }, - { 2,0,2 }, { 2,1,0 }, { 2,1,1 }, { 2,1,2 }, { 2,2,0 }, {2,2,1 }, - { 0,2,3 }, { 0,3,0 }, { 0,3,1 }, { 0,3,2 }, { 0,3,3 }, {1,0,3 }, - { 1,1,3 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, { 1,3,2 }, {1,3,3 }, - { 2,0,3 }, { 2,1,3 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, {2,3,2 }, - { 2,3,3 }, { 3,0,3 }, { 3,1,3 }, { 3,2,3 }, { 3,3,0 }, {3,3,1 }, - { 3,3,2 }, { 3,3,3 }, { 0,0,3 }, { 0,1,3 } + { 2,2,2 }, { 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,1,0 }, { 3,1,1 }, { 3,1,2 }, { 3,2,0 }, + { 3,2,1 }, { 3,2,2 }, { 0,0,0 }, { 0,0,1 }, { 0,0,2 }, { 0,1,0 }, { 0,1,1 }, { 0,1,2 }, + { 0,2,0 }, { 0,2,1 }, { 0,2,2 }, { 1,0,0 }, { 1,0,1 }, { 1,0,2 }, { 1,1,0 }, { 1,1,1 }, + { 1,1,2 }, { 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 2,0,0 }, { 2,0,1 }, { 2,0,2 }, { 2,1,0 }, + { 2,1,1 }, { 2,1,2 }, { 2,2,0 }, { 2,2,1 }, { 0,2,3 }, { 0,3,0 }, { 0,3,1 }, { 0,3,2 }, + { 0,3,3 }, { 1,0,3 }, { 1,1,3 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, { 1,3,2 }, { 1,3,3 }, + { 2,0,3 }, { 2,1,3 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, { 2,3,2 }, { 2,3,3 }, { 3,0,3 }, + { 3,1,3 }, { 3,2,3 }, { 3,3,0 }, { 3,3,1 }, { 3,3,2 }, { 3,3,3 }, { 0,0,3 }, { 0,1,3 } }; /* Bar to Decimal Conversion Table (Reed-Solomon) */ static const char AusBarTable[64][3] = { - { 0,0,0 }, { 0,0,1 }, { 0,0,2 }, { 0,0,3 }, { 0,1,0 }, { 0,1,1 }, - { 0,1,2 }, { 0,1,3 }, { 0,2,0 }, { 0,2,1 }, { 0,2,2 }, { 0,2,3 }, - { 0,3,0 }, { 0,3,1 }, { 0,3,2 }, { 0,3,3 }, { 1,0,0 }, { 1,0,1 }, - { 1,0,2 }, { 1,0,3 }, { 1,1,0 }, { 1,1,1 }, { 1,1,2 }, { 1,1,3 }, - { 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, - { 1,3,2 }, { 1,3,3 }, { 2,0,0 }, { 2,0,1 }, { 2,0,2 }, { 2,0,3 }, - { 2,1,0 }, { 2,1,1 }, { 2,1,2 }, { 2,1,3 }, { 2,2,0 }, { 2,2,1 }, - { 2,2,2 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, { 2,3,2 }, { 2,3,3 }, - { 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,0,3 }, { 3,1,0 }, { 3,1,1 }, - { 3,1,2 }, { 3,1,3 }, { 3,2,0 }, { 3,2,1 }, { 3,2,2 }, { 3,2,3 }, - { 3,3,0 }, { 3,3,1 }, { 3,3,2 }, { 3,3,3 } + { 0,0,0 }, { 0,0,1 }, { 0,0,2 }, { 0,0,3 }, { 0,1,0 }, { 0,1,1 }, { 0,1,2 }, { 0,1,3 }, + { 0,2,0 }, { 0,2,1 }, { 0,2,2 }, { 0,2,3 }, { 0,3,0 }, { 0,3,1 }, { 0,3,2 }, { 0,3,3 }, + { 1,0,0 }, { 1,0,1 }, { 1,0,2 }, { 1,0,3 }, { 1,1,0 }, { 1,1,1 }, { 1,1,2 }, { 1,1,3 }, + { 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, { 1,3,2 }, { 1,3,3 }, + { 2,0,0 }, { 2,0,1 }, { 2,0,2 }, { 2,0,3 }, { 2,1,0 }, { 2,1,1 }, { 2,1,2 }, { 2,1,3 }, + { 2,2,0 }, { 2,2,1 }, { 2,2,2 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, { 2,3,2 }, { 2,3,3 }, + { 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,0,3 }, { 3,1,0 }, { 3,1,1 }, { 3,1,2 }, { 3,1,3 }, + { 3,2,0 }, { 3,2,1 }, { 3,2,2 }, { 3,2,3 }, { 3,3,0 }, { 3,3,1 }, { 3,3,2 }, { 3,3,3 } }; -#include -#include -#include "common.h" -#include "reedsol.h" - -static unsigned char aus_convert_pattern(const char data, const int shift) { - return data << shift; -} - /* Adds Reed-Solomon error correction to auspost */ -static char *aus_rs_error(const char data_pattern[], char *d) { - const int length = (int) (d - data_pattern); +static char *aus_rs_error(const char dest[], char *d) { + const int length = (int) (d - dest); int reader, triple_writer; - unsigned char triple[31]; + unsigned char triple[17]; /* Max bars 67 - 12 (ECC) - 4 (start/stop) = 51 / 3 */ unsigned char result[5]; rs_t rs; for (reader = 2, triple_writer = 0; reader < length; reader += 3, triple_writer++) { - triple[triple_writer] = aus_convert_pattern(data_pattern[reader], 4) - | aus_convert_pattern(data_pattern[reader + 1], 2) - | aus_convert_pattern(data_pattern[reader + 2], 0); + triple[triple_writer] = (dest[reader] << 4) | (dest[reader + 1] << 2) | dest[reader + 2]; } zint_rs_init_gf(&rs, 0x43); @@ -120,7 +108,7 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in /* Null Standard Barcode 2 Barcode 3 Reply Route Redirect */ { '0','0' }, { '1','1' }, { '5','9' }, { '6','2' }, { '4','5' }, { '8','7' }, { '9','2' } }; - static const char start_stop[2] = { 1,3 }; + static const char start_stop[2] = { 1,3 }; /* Full,tracker */ int i; int error_number; @@ -128,88 +116,87 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in int loopey, reader; int h; - char data_pattern[200]; - char *d = data_pattern; + char dest[67]; /* Max bars (Customer Barcode 3) */ + char *d = dest; int fcc_idx; /* Index into `fccs[]` */ - unsigned char local_source[30]; - int zeroes = 0; + unsigned char src_buf[8]; /* For zero-padded DPID */ + int not_all_digits = 0; const int content_segs = symbol->output_options & BARCODE_CONTENT_SEGS; /* Suppress clang-tidy-21 clang-analyzer-security.ArrayBound */ assert(symbol->symbology == BARCODE_AUSPOST || symbol->symbology == BARCODE_AUSREPLY || symbol->symbology == BARCODE_AUSROUTE || symbol->symbology == BARCODE_AUSREDIRECT); - /* Do all of the length checking first to avoid stack smashing */ if (symbol->symbology == BARCODE_AUSPOST) { - if (length != 8 && length != 13 && length != 16 && length != 18 && length != 23) { + if (length > 23) { return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 401, - "Input length %d wrong (8, 13, 16, 18 or 23 characters required)", length); + "Input length %d too long (maximum 23)", length); } - } else if (length > 8) { - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 403, "Input length %d too long (maximum 8)", length); - } - - /* Check input immediately to catch invalid chars */ - if ((i = z_not_sane(AUS_GDSET_F, source, length))) { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 404, - "Invalid character at position %d in input (alphanumerics, space and \"#\" only)", i); - } - - if (symbol->symbology == BARCODE_AUSPOST) { - /* Format control code (FCC) */ - switch (length) { - case 8: - fcc_idx = 1; /* FCC 11 Standard Customer */ - break; - case 13: - fcc_idx = 2; /* FCC 59 Customer 2 */ - break; - case 16: - fcc_idx = 2; /* FCC 59 Customer 2 */ - if ((i = z_not_sane(NEON_F, source, length))) { + not_all_digits = z_not_sane(NEON_F, source, length); + if (length <= 8) { + if (not_all_digits) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 405, + "Invalid character at position %d in DPID (digits only for Standard Customer Barcode)", + not_all_digits); + } + if (z_zero_fill(source, length, src_buf, 8)) { + source = src_buf; + length = 8; + } + fcc_idx = 1; /* FCC 11 Standard Customer */ + } else { + if (not_all_digits) { + if ((i = z_not_sane(NEON_F, source, 8))) { return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 402, - "Invalid character at position %d in input (digits only for FCC 59 length 16)", - i); + "Invalid character at position %d in DPID (digits only)", i); } - break; - case 18: - fcc_idx = 3; /* FCC 62 Customer 3 */ - break; - case 23: - fcc_idx = 3; /* FCC 62 Customer 3 */ - if ((i = z_not_sane(NEON_F, source, length))) { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 406, - "Invalid character at position %d in input (digits only for FCC 62 length 23)", - i); + if ((i = z_not_sane(AUS_GDSET_F, source + 8, length - 8))) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 404, + "Invalid character at position %d in input (alphanumerics, space and \"#\" only)", + i + 8); } - break; + } + if (length > 18) { + if (not_all_digits) { + return ZEXT z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 407, + "Invalid character at position %1$d in input (digits only for Customer Barcode 3" + " length %2$d)", not_all_digits, length); + } + fcc_idx = 3; /* FCC 62 Customer Barcode 3 all-digits */ + } else if (length > 16 || (length > 13 && not_all_digits)) { + fcc_idx = 3; /* FCC 62 Customer Barcode 3 */ + } else { + fcc_idx = 2; /* FCC 59 Customer Barcode 2 */ + } } + /* Check if DPID all zeros (Null) */ - for (i = 0; i < 8 && source[i] == '0'; i++); - if (i == 8) { - fcc_idx = 0; /* Null */ + if (z_chr_cnt(source, 8, '0') == 8) { + fcc_idx = 0; /* FCC 00 Null */ } } else { - fcc_idx = symbol->symbology - BARCODE_AUSREPLY + 4; /* 4 (FCC 45), 5 (FCC 87) or 6 (FCC 92) */ + if (length > 8) { + return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 403, "Input length %d too long (maximum 8)", length); + } + if ((i = z_not_sane(NEON_F, source, length))) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 406, + "Invalid character at position %d in DPID (digits only)", i); + } /* Add leading zeros as required */ - zeroes = 8 - length; - memset(local_source, '0', zeroes); + if (z_zero_fill(source, length, src_buf, 8)) { + source = src_buf; + length = 8; + } + + /* Format control code (FCC) */ + fcc_idx = symbol->symbology - BARCODE_AUSREPLY + 4; /* 4 (FCC 45), 5 (FCC 87) or 6 (FCC 92) */ } if (symbol->debug & ZINT_DEBUG_PRINT) { printf("AUSPOST FCC: %.2s\n", fccs[fcc_idx]); } - memcpy(local_source + zeroes, source, length); - length += zeroes; - - /* Verify that the first 8 characters are numbers */ - if ((i = z_not_sane(NEON_F, local_source, 8))) { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 405, - "Invalid character at position %d in DPID (first 8 characters) (digits only)", i); - } - /* Start character */ memcpy(d, start_stop, 2); d += 2; @@ -221,49 +208,47 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in /* Delivery Point Identifier (DPID) */ for (reader = 0; reader < 8; reader++, d += 2) { - memcpy(d, AusNTable[local_source[reader] - '0'], 2); + memcpy(d, AusNTable[source[reader] - '0'], 2); } /* Customer Information */ if (length > 8) { - if (length == 13 || length == 18) { + if (not_all_digits) { for (reader = 8; reader < length; reader++, d += 3) { - memcpy(d, AusCTable[z_posn(AusGDSET, local_source[reader])], 3); + memcpy(d, AusCTable[z_posn(AusGDSET, source[reader])], 3); } - } else if (length == 16 || length == 23) { + } else { for (reader = 8; reader < length; reader++, d += 2) { - memcpy(d, AusNTable[local_source[reader] - '0'], 2); + memcpy(d, AusNTable[source[reader] - '0'], 2); } } } - /* Filler bar */ - h = (int) (d - data_pattern); - switch (h) { - case 22: - case 37: - case 52: - *d++ = 3; - break; - default: - break; + /* Filler bar(s) */ + h = (int) (d - dest); + assert(h < 53); + for (i = h; i != 23 && i != 38 && i != 53; i++) { + *d++ = 3; /* Tracker */ + } + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("Filler: %d\n", i - h); } /* Reed Solomon error correction */ - d = aus_rs_error(data_pattern, d); + d = aus_rs_error(dest, d); /* Stop character */ memcpy(d, start_stop, 2); d += 2; /* Turn the symbol into a bar pattern ready for plotting */ - h = (int) (d - data_pattern); + h = (int) (d - dest); for (loopey = 0, writer = 0; loopey < h; loopey++, writer += 2) { - if (data_pattern[loopey] == 1 || data_pattern[loopey] == 0) { + if (dest[loopey] == 1 || dest[loopey] == 0) { z_set_module(symbol, 0, writer); } z_set_module(symbol, 1, writer); - if (data_pattern[loopey] == 2 || data_pattern[loopey] == 0) { + if (dest[loopey] == 2 || dest[loopey] == 0) { z_set_module(symbol, 2, writer); } } @@ -289,7 +274,7 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in error_number = zint_daft_set_height(symbol, 0.0f, 0.0f); } - if (content_segs && z_ct_cpy_cat(symbol, fccs[fcc_idx], 2, '\xFF' /*separator (none)*/, local_source, length)) { + if (content_segs && z_ct_cpy_cat(symbol, fccs[fcc_idx], 2, '\xFF' /*separator (none)*/, source, length)) { return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ } diff --git a/backend/aztec.c b/backend/aztec.c index 0cfc7472..278fb025 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -146,8 +146,8 @@ static void az_print_modes(const char *modes, const int length) { } /* Determine encoding modes using modified Annex H algorithm (`FAST_MODE`) */ -static int az_text_modes(char modes[], unsigned char source[], int length, const int gs1, const char initial_mode, - const int debug_print) { +static int az_text_modes(char modes[], unsigned char source[], const int length, const char *fncs, + const char initial_mode, const int debug_print) { int i; char current_mode; int count; @@ -157,7 +157,7 @@ static int az_text_modes(char modes[], unsigned char source[], int length, const for (i = 0; i < length; i++) { if (!z_isascii(source[i]) || !AztecFlags[source[i]]) { modes[i] = AZ_B; - } else if (gs1 && source[i] == '\x1D') { + } else if (fncs[i] && source[i] == '\x1D') { modes[i] = AZ_P; /* For FLG(0) = FNC1 */ } else { modes[i] = AztecModes[source[i]]; @@ -774,8 +774,8 @@ static void az_dump_list(const struct az_state_list *list, const char *prefix) { fprintf(stderr, "%sSize %d\n", prefix, (int) list->used); for (i = 0; i < list->used; i++) { const struct az_state *state = list->states + i; - fprintf(stderr, "%.*s %d: mode %d, Size(tokens) %d\n", pl, spaces, (int) i, state->mode, - (int) state->tokens.used); + fprintf(stderr, "%.*s %d: mode %d, Size(tokens) %d, bitCount %d, byteCount %d\n", + pl, spaces, i, state->mode, state->tokens.used, state->bitCount, state->byteCount); } } #endif @@ -859,15 +859,14 @@ static int az_UpdateStateForPair(const struct az_state *state, const int from, c /* Return a set of states that represent the possible ways of updating this state for the next character. The resulting set of states are added to `ret_list` */ static int az_UpdateStateForChar(const struct az_state *state, const unsigned char *source, const int from, - const int gs1, struct az_state_list *ret_list) { + const int fnc1_if_gs, struct az_state_list *ret_list) { unsigned char ch = source[from]; - const int fnc1 = gs1 && ch == '\x1D'; - const int charInCurrentTable = (fnc1 && state->mode == AZ_P) - || (z_isascii(ch) && (AztecFlags[ch] & (1 << state->mode))); + const int fnc1 = fnc1_if_gs && ch == '\x1D'; if (z_isascii(ch)) { + const int charInCurrentTable = fnc1 ? state->mode == AZ_P : AztecFlags[ch] & (1 << state->mode); int mode; for (mode = 0; mode < AZ_NUM_MODES; mode++) { - const int charInModeTable = (fnc1 && mode == AZ_P) || (AztecFlags[ch] & (1 << mode)); + const int charInModeTable = fnc1 ? mode == AZ_P : AztecFlags[ch] & (1 << mode); if (charInModeTable) { /* Try generating the char by latching to its mode */ if (!charInCurrentTable || mode == state->mode || (mode == AZ_D && !fnc1)) { @@ -900,7 +899,7 @@ static int az_UpdateStateForChar(const struct az_state *state, const unsigned ch } } } - if (!fnc1 && (state->byteCount > 0 || !charInCurrentTable)) { + if (!fnc1 && (state->byteCount > 0 || !z_isascii(ch) || !(AztecFlags[ch] & (1 << state->mode)))) { /* It's never worthwhile to go into B/S mode if not already in B/S mode, and the char exists in current mode. That can never save bits over just outputting the char in the current mode */ if (!az_AddByteShiftChar(state, from, -1 /*from2*/, ret_list)) { @@ -937,7 +936,7 @@ static int az_UpdateStateListForPair(struct az_state_list *list, const int from, /* Update a set of states for a new character by updating each state for the new character, merging the results, and then removing the non-optimal states */ static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned char *source, const int from, - const int gs1) { + const int fnc1_if_gs) { int i; struct az_state_list s_ret_list; struct az_state_list *ret_list = &s_ret_list; @@ -945,7 +944,7 @@ static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned return 0; } for (i = 0; i < list->used; i++) { - if (!az_UpdateStateForChar(list->states + i, source, from, gs1, ret_list)) { + if (!az_UpdateStateForChar(list->states + i, source, from, fnc1_if_gs, ret_list)) { az_state_list_free(ret_list); return 0; } @@ -968,8 +967,8 @@ static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned /* Copyright 2016 Huy Cuong Nguyen */ /* zxing-cpp */ /* SPDX-License-Identifier: Apache-2.0 */ /* Note that a bitstream that is encoded to be shortest based on mode choices may not be so after bit-stuffing */ -static int az_binary_string(unsigned char source[], const int length, int bp, - char binary_string[AZTEC_MAP_POSN_MAX + 1], const int gs1, const char initial_mode, +static int az_binary_string(const unsigned char source[], const int length, int bp, + char binary_string[AZTEC_MAP_POSN_MAX + 1], const char *fncs, const char initial_mode, char *p_current_mode) { struct az_state_list s_state_list; struct az_state_list *list = &s_state_list; @@ -1000,7 +999,7 @@ static int az_binary_string(unsigned char source[], const int length, int bp, } i++; } else { - if (!az_UpdateStateListForChar(list, source, i, gs1)) { + if (!az_UpdateStateListForChar(list, source, i, fncs[i])) { az_state_list_free(list); return 0; } @@ -1061,37 +1060,23 @@ static int az_binary_string(unsigned char source[], const int length, int bp, } /* Calculate the binary size */ -static int az_text_size(const char *modes, const unsigned char *source, int length, const int gs1, const int set_gs1, +static int az_text_size(const char *modes, const unsigned char *source, const int length, const char* fncs, const int eci, const char initial_mode, const int eci_latch, int *byte_counts) { int i; int byte_i = 0; char current_mode = initial_mode; int size = 0; - if (set_gs1 && gs1) { - if (eci == 0) { - current_mode = AZ_D; - size += 5 + 4 + 5 + 3; - } else { - size += 5 + 5 + 3; - } - } - if (eci != 0) { + if (eci) { if (initial_mode != AZ_P) { if (eci_latch) { - if (initial_mode != AZ_M) { - if (initial_mode == AZ_D) { - size += 4; - } - size += 5; - } - size += 5; + size += AztecLatchNum[(int) initial_mode][AZ_P]; current_mode = AZ_P; } else { size += initial_mode == AZ_D ? 4 : 5; } } - size += 5 + 3 + 4 + 4 * ((eci > 9) + (eci > 99) + (eci > 999) + (eci > 9999) + (eci > 99999)); + size += 5 + 3 + 4 + 4 * ((eci >= 10) + (eci >= 100) + (eci >= 1000) + (eci >= 10000) + (eci >= 100000)); } for (i = 0; i < length; i++) { if (modes[i] != current_mode) { @@ -1154,7 +1139,7 @@ static int az_text_size(const char *modes, const unsigned char *source, int leng if (modes[i] == AZ_P || (modes[i] & AZ_PS)) { size += 5; - if (gs1 && source[i] == '\x1D') { + if (fncs[i] && source[i] == '\x1D') { size += 3; } } else if (modes[i] == AZ_D && !(modes[i] & AZ_US)) { @@ -1168,9 +1153,8 @@ static int az_text_size(const char *modes, const unsigned char *source, int leng } /* Determine encoding modes and encode */ -static int az_text_process(unsigned char *source, int length, int bp, char *binary_string, const int gs1, - const int gs1_bp, const int eci, const int fast_encode, char *p_current_mode, int *data_length, - const int debug) { +static int az_text_process(unsigned char *source, const int length, int bp, char *binary_string, const char *fncs, + const int eci, const int fast_encode, char *p_current_mode, int *data_length, const int debug) { int i, j; int reduced_length = 0; /* Suppress gcc-14 warning -Wmaybe-uninitialized */ char *modes = (char *) z_alloca(length + 1); @@ -1180,7 +1164,6 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina int eci_latch = 0; char current_mode = p_current_mode ? *p_current_mode : AZ_U; const char initial_mode = current_mode; - const int set_gs1 = bp == gs1_bp; const int initial_bp = bp; const int all_byte_only_or_uld = az_all_byte_only_or_uld(source, length); /* -1 if not */ const int debug_print = debug & ZINT_DEBUG_PRINT; @@ -1190,35 +1173,14 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina const int debug_skip_all = 0; #endif - if (set_gs1 && gs1) { - assert(initial_mode == AZ_U); - if (eci == 0) { - /* Latch to D/L to save a bit */ - current_mode = AZ_D; - bp = z_bin_append_posn(30, 5, binary_string, bp); /* D/L */ - bp = z_bin_append_posn(0, 4 + 5 + 3, binary_string, bp); /* P/S FLG(0) = FNC1 */ - } else { - bp = z_bin_append_posn(0, 5 + 5 + 3, binary_string, bp); /* P/S FLG(0) = FNC1 */ - } - /* See if it's worthwhile latching to AZ_P when have ECI */ - } else if ((debug_skip_all || all_byte_only_or_uld == -1) && eci && initial_mode != AZ_P - && az_count_initial_puncts(source, length) > 2 + (initial_mode == AZ_D)) { - assert(!gs1); - eci_latch = 1; - current_mode = AZ_P; - } - - if (eci != 0) { - const int flg = 1 + (eci > 9) + (eci > 99) + (eci > 999) + (eci > 9999) + (eci > 99999); + if (eci) { + const int flg = 1 + (eci >= 10) + (eci >= 100) + (eci >= 1000) + (eci >= 10000) + (eci >= 100000); if (initial_mode != AZ_P) { - if (eci_latch) { - if (initial_mode != AZ_M) { - if (initial_mode == AZ_D) { - bp = z_bin_append_posn(14, 4, binary_string, bp); /* U/L */ - } - bp = z_bin_append_posn(29, 5, binary_string, bp); /* M/L */ - } - bp = z_bin_append_posn(30, 5, binary_string, bp); /* P/L */ + /* See if it's worthwhile latching to AZ_P */ + if ((eci_latch = az_count_initial_puncts(source, length) >= flg + (initial_mode == AZ_D))) { + bp = z_bin_append_posn(AztecLatch[(int) initial_mode][AZ_P], AztecLatchNum[(int) initial_mode][AZ_P], + binary_string, bp); + current_mode = AZ_P; } else { bp = z_bin_append_posn(0, initial_mode == AZ_D ? 4 : 5, binary_string, bp); /* P/S */ } @@ -1249,9 +1211,9 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina memset(modes, all_byte_only_or_uld, length); reduced_length = length; } else if (fast_encode) { - reduced_length = az_text_modes(modes, source, length, gs1, current_mode, debug_print); + reduced_length = az_text_modes(modes, source, length, fncs, current_mode, debug_print); } else { - bp = az_binary_string(source, length, bp, binary_string, gs1, current_mode, ¤t_mode); + bp = az_binary_string(source, length, bp, binary_string, fncs, current_mode, ¤t_mode); if (bp == 0 || bp > AZTEC_BIN_CAPACITY) { return bp == 0 ? ZINT_ERROR_MEMORY : ZINT_ERROR_TOO_LONG; } @@ -1260,7 +1222,7 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina } if (!size) { - size = az_text_size(modes, source, reduced_length, gs1, set_gs1, eci, initial_mode, eci_latch, byte_counts); + size = az_text_size(modes, source, reduced_length, fncs, eci, initial_mode, eci_latch, byte_counts); if (size == 0 || bp + size > AZTEC_BIN_CAPACITY) { return ZINT_ERROR_TOO_LONG; } @@ -1342,7 +1304,7 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina } if (modes[i] == AZ_P || (modes[i] & AZ_PS)) { - if (gs1 && source[i] == '\x1D') { + if (fncs[i] && source[i] == '\x1D') { bp = z_bin_append_posn(0, 5 + 3, binary_string, bp); /* FLG(0) = FNC1 */ } else { bp = z_bin_append_posn(AztecChar[AZ_P][source[i]], 5, binary_string, bp); @@ -1371,23 +1333,85 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina /* Call `az_text_process()` for each segment */ static int az_text_process_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, int bp, - char binary_string[], const int gs1, const int gs1_bp, int *data_length) { + char binary_string[], const int gs1, int *data_length) { int i; char current_mode = AZ_U; + int have_extra_escapes = 0; + int position_fnc1 = 0; const int fast_encode = symbol->input_mode & FAST_MODE; + const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE; /* Raw text dealt with by `ZBarcode_Encode_Segs()`, except for `eci` feedback. Note not updating `eci` for GS1 mode as not converted */ const int content_segs = !gs1 && (symbol->output_options & BARCODE_CONTENT_SEGS); + if (gs1 || (extra_escape_mode + && (position_fnc1 = z_extra_escape_position_fnc1(segs[0].source, segs[0].length)))) { + unsigned char *source = segs[0].source; + const int length = segs[0].length; + if (position_fnc1) { + if (position_fnc1 == 4) { + bp = z_bin_append_posn(AztecChar[AZ_U][source[0]], 5, binary_string, bp); + } else if (position_fnc1 == 5) { + current_mode = AZ_D; + bp = z_bin_append_posn(30, 5, binary_string, bp); /* D/L */ + bp = z_bin_append_posn(AztecChar[AZ_D][source[0]], 4, binary_string, bp); + bp = z_bin_append_posn(AztecChar[AZ_D][source[1]], 4, binary_string, bp); + } + have_extra_escapes = 1; + } + if (gs1 || (position_fnc1 <= 4 && length > position_fnc1 && z_isdigit(source[position_fnc1]))) { + assert(current_mode == AZ_U); + /* Latch to D/L to save a bit */ + current_mode = AZ_D; + bp = z_bin_append_posn(30, 5, binary_string, bp); /* D/L */ + } + /* See if it's worthwhile latching to AZ_P */ + if (az_count_initial_puncts(source + position_fnc1, length - position_fnc1) >= 1 + !segs[0].eci) { + bp = z_bin_append_posn(AztecLatch[(int) current_mode][AZ_P], AztecLatchNum[(int) current_mode][AZ_P], + binary_string, bp); + bp = z_bin_append_posn(0, 5 + 3, binary_string, bp); /* FLG(0) = FNC1 */ + current_mode = AZ_P; + } else { + bp = z_bin_append_posn(0, 4 + (current_mode != AZ_D) + 5 + 3, binary_string, bp); /* P/S FLG(0) = FNC1 */ + } + } + for (i = 0; i < seg_count; i++) { int error_number; - if ((error_number = az_text_process(segs[i].source, segs[i].length, bp, binary_string, gs1, gs1_bp, - segs[i].eci, fast_encode, ¤t_mode, &bp, symbol->debug))) { - return error_number; + unsigned char *source = segs[i].source + position_fnc1; + int length = segs[i].length - position_fnc1; + if (length) { + unsigned char *src_buf = (unsigned char *) z_alloca(length + 1); + char *fncs = (char *) z_alloca(length); + + if (gs1) { + memset(fncs, 1, length); + } else { + memset(fncs, 0, length); + if (extra_escape_mode) { + if ((error_number = z_extra_escapes(symbol, source, &length, segs[i].eci, src_buf, fncs, + &have_extra_escapes))) { + return error_number; + } + if (have_extra_escapes) { + source = src_buf; + } + } + } + + if ((error_number = az_text_process(source, length, bp, binary_string, fncs, segs[i].eci, fast_encode, + ¤t_mode, &bp, symbol->debug))) { + return error_number; + } } - if (content_segs && segs[i].eci) { - z_ct_set_seg_eci(symbol, i, segs[i].eci); + if (content_segs) { + if (have_extra_escapes) { + z_ct_set_seg_extra_escapes_eci(symbol, i, segs[i].eci); + } else if (segs[i].eci) { + z_ct_set_seg_eci(symbol, i, segs[i].eci); + } } + position_fnc1 = 0; } *data_length = bp; @@ -1568,8 +1592,8 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons int error_number; int compact, data_length, data_maxsize, codeword_size, adjusted_length; int bp = 0; - int gs1_bp = 0; const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE; + const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE; const int reader_init = symbol->output_options & READER_INIT; const int compact_loop_start = reader_init ? 1 : 4; /* Compact 2-4 excluded from Reader Initialisation */ const int debug_print = symbol->debug & ZINT_DEBUG_PRINT; @@ -1587,10 +1611,23 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons if (gs1 && reader_init) { return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 501, "Cannot use Reader Initialisation in GS1 mode"); } + if (extra_escape_mode) { + if (symbol->symbology != BARCODE_AZTEC) { + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 805, + "Can only use Extra Escape mode with non-variant Aztec Code"); + } + if (gs1) { + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 806, "Cannot use Extra Escape mode in GS1 mode"); + } + if (reader_init) { + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 807, "Cannot use Reader Initialisation in Extra Escape mode"); + } + } if (symbol->structapp.count) { /* Structured Append info as string + ID + + index + count + NUL */ unsigned char sa_src[1 + sizeof(symbol->structapp.id) + 1 + 1 + 1 + 1] = {0}; + char fncs[36] = {0}; /* ' ' + ID (32) + ' ' + 1 + 1 = 36 */ int sa_len; int id_len; @@ -1611,6 +1648,7 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 703, "Structured Append ID cannot contain spaces"); } + /* Starting with M/L U/L signals Structured Append */ bp = z_bin_append_posn(29, 5, binary_string, bp); /* M/L */ bp = z_bin_append_posn(29, 5, binary_string, bp); /* U/L */ @@ -1628,20 +1666,22 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons symbol->structapp.count, symbol->structapp.index, symbol->structapp.id, sa_src); } - (void) az_text_process(sa_src, sa_len, bp, binary_string, 0 /*gs1*/, 0 /*gs1_bp*/, 0 /*eci*/, - 0 /*fast_encode*/, NULL /*p_current_mode*/, &bp, symbol->debug); + (void) az_text_process(sa_src, sa_len, bp, binary_string, fncs, 0 /*eci*/, 0 /*fast_encode*/, + NULL /*p_current_mode*/, &bp, symbol->debug); /* Will be in U/L due to uppercase A-Z index/count indicators at end */ - gs1_bp = bp; /* Initial FNC1 (FLG0) position */ } - if ((error_number = az_text_process_segs(symbol, segs, seg_count, bp, binary_string, gs1, gs1_bp, - &data_length))) { - assert(error_number == ZINT_ERROR_TOO_LONG || error_number == ZINT_ERROR_MEMORY); + if ((error_number = az_text_process_segs(symbol, segs, seg_count, bp, binary_string, gs1, &data_length))) { + assert(error_number == ZINT_ERROR_TOO_LONG || error_number == ZINT_ERROR_MEMORY + || error_number == ZINT_ERROR_INVALID_DATA || error_number == ZINT_ERROR_INVALID_OPTION); if (error_number == ZINT_ERROR_TOO_LONG) { return z_errtxt(error_number, symbol, 502, "Input too long, requires too many codewords (maximum " AZ_BIN_CAP_CWDS_S ")"); } - return z_errtxt(error_number, symbol, 804, "Insufficient memory for optimized encodation"); + if (error_number == ZINT_ERROR_MEMORY) { + return z_errtxt(error_number, symbol, 804, "Insufficient memory for optimized encodation"); + } + return error_number; /* EXTRA_ESCAPE_MODE errors, `errtxt` set */ } assert(data_length > 0); /* Suppress clang-tidy warning: clang-analyzer-core.UndefinedBinaryOperatorResult */ @@ -1859,7 +1899,6 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons break; case 12: if (!zint_rs_uint_init_gf(&rs_uint, 0x1069, 4095)) { /* Can fail on malloc() */ - /* Note using AUSPOST error nos range as out of 50x ones & 51x taken by CODEONE */ return z_errtxt(ZINT_ERROR_MEMORY, symbol, 700, "Insufficient memory for Reed-Solomon log tables"); } zint_rs_uint_init_code(&rs_uint, ecc_blocks, 1); @@ -1880,6 +1919,12 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons bit_pattern[i] = adjusted_string[total_bits - i - 1]; } +#ifdef ZINT_TEST + if (symbol->debug & ZINT_DEBUG_TEST) { + z_debug_test_codeword_dump(symbol, ZCUCP(bit_pattern), total_bits); + } +#endif + /* Now add the symbol descriptor */ memset(desc_data, 0, 4); memset(desc_ecc, 0, 6); diff --git a/backend/code128_based.c b/backend/code128_based.c index 88532deb..44719002 100644 --- a/backend/code128_based.c +++ b/backend/code128_based.c @@ -49,7 +49,7 @@ static int nve18_or_ean14(struct zint_symbol *symbol, const unsigned char source }; const int idx = data_len == 17; unsigned char ean128_equiv[23]; - int i, zeroes; + int i; unsigned char have_check_digit = '\0'; unsigned char check_digit; int error_number; @@ -79,10 +79,8 @@ static int nve18_or_ean14(struct zint_symbol *symbol, const unsigned char source length--; } - zeroes = data_len - length; memcpy(ean128_equiv, prefix[idx][!(symbol->input_mode & GS1PARENS_MODE)], 4); - memset(ean128_equiv + 4, '0', zeroes); - memcpy(ean128_equiv + 4 + zeroes, source, length); + z_zero_fill(source, length, ean128_equiv + 4, data_len); check_digit = (unsigned char) zint_gs1_check_digit(ean128_equiv + 4, data_len); if (have_check_digit && have_check_digit != check_digit) { diff --git a/backend/common.c b/backend/common.c index 8b626baf..a4db539d 100644 --- a/backend/common.c +++ b/backend/common.c @@ -81,6 +81,20 @@ INTERNAL int z_chr_cnt(const unsigned char source[], const int length, const uns return count; } +/* Zero-fill `dest` buffer, appending `source'. Returns no. of zeroes added */ +INTERNAL int z_zero_fill(const unsigned char source[], const int length, unsigned char *dest, const int dest_length) { + const int zeroes = dest_length - length; + if (zeroes >= 0) { + if (zeroes > 0) { + memset(dest, '0', zeroes); + } + memcpy(dest + zeroes, source, length); + } else { + memcpy(dest, source, length); + } + return zeroes; +} + /* Flag table for `is_chr()` and `z_not_sane()` */ #define IS_CLS_F (IS_CLI_F | IS_SIL_F) static const unsigned short flags[256] = { @@ -776,14 +790,38 @@ INTERNAL int z_utf8_to_unicode(struct zint_symbol *symbol, const unsigned char s return 0; } -/* Process `source` for manual FNC1 extra escape sequences, placing result in `dest` with result length in `p_len`, - and setting `fncs` with found FNC1s. `dest` & `fncs` must be at least `length` in size. `eci` is checked to be - ASCII-compatible (UTF-8 & single-byte ECIs, excl. Binary 899). On error sets `errtxt` & returns error no. */ -INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char source[], const int length, - const int eci, unsigned char dest[], char *fncs, int *p_len) { +/* Check if `source` starts with manual FNC1 in 1st or 2nd position, returning length of extra escape sequence if so, + else 0 */ +INTERNAL int z_extra_escape_position_fnc1(const unsigned char source[], const int length) { + if (length >= 3) { + if (source[0] == '\\' && source[1] == '^' && source[2] == '1') { + return 3; + } + if (length >= 4) { + if (z_isalpha(source[0]) && source[1] == '\\' && source[2] == '^' && source[3] == '1') { + return 4; + } + if (length >= 5) { + if (z_isdigit(source[0]) && z_isdigit(source[1]) && source[2] == '\\' && source[3] == '^' + && source[4] == '1') { + return 5; + } + } + } + } + return 0; +} + +/* Process `source` for extra escape sequences, placing result in `dest`, updating `p_length`, and setting `fncs` with + any found FNC1s. Sets `p_have_extra_escapes` if any sequences found. `eci` is checked to be ASCII-compatible (UTF-8 + & single-byte ECIs, excl. Binary 899). On error sets `errtxt` & returns error no. */ +INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char source[], int *p_length, const int eci, + unsigned char *dest, char *fncs, int *p_have_extra_escapes) { + const int length = *p_length; int i, j = 0; + if (eci == 20 || eci == 25 || eci >= 28) { - return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 716, "Extra escape mode requires ASCII-compatible ECI"); + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 716, "Extra Escape mode requires ASCII-compatible ECI"); } for (i = 0; i < length; i++) { if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^') { @@ -806,7 +844,12 @@ INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char sou dest[j++] = source[i]; } } - *p_len = j; + if (j != length) { + assert(j > 0 && j < length); + dest[j] = '\0'; + *p_length = j; + *p_have_extra_escapes = 1; + } return 0; } @@ -1029,7 +1072,6 @@ INTERNAL void z_ct_set_seg_extra_escapes_eci(struct zint_symbol *symbol, const i int i, j = 0; unsigned char *source; int length; - const int no_fnc1_position_check = seg_idx != 0 || eci != 0; assert(symbol->content_segs); assert(seg_idx >= 0 && seg_idx < symbol->content_seg_count); @@ -1047,7 +1089,7 @@ INTERNAL void z_ct_set_seg_extra_escapes_eci(struct zint_symbol *symbol, const i /* Drop second '^' */ } else { /* source[i + 2] == '1' FNC1 */ /* Do not emit if FNC1 in 1st/2nd position */ - if (no_fnc1_position_check || j > 2 || (j == 1 && !z_isalpha(source[0])) + if (seg_idx != 0 || j > 2 || (j == 1 && !z_isalpha(source[0])) || (j == 2 && (!z_isdigit(source[0]) || !z_isdigit(source[1]))) ) { source[j++] = '\x1D'; /* GS */ } diff --git a/backend/common.h b/backend/common.h index 91286870..2573a5e6 100644 --- a/backend/common.h +++ b/backend/common.h @@ -167,6 +167,9 @@ INTERNAL void z_to_upper(unsigned char source[], const int length); /* Returns the number of times a character `ch` occurs in `source` */ INTERNAL int z_chr_cnt(const unsigned char source[], const int length, const unsigned char ch); +/* Zero-fill `dest` buffer, appending `source'. Returns no. of zeroes added */ +INTERNAL int z_zero_fill(const unsigned char source[], const int length, unsigned char *dest, const int dest_length); + /* `z_is_chr()` & `z_not_sane()` flags */ #define IS_SPC_F 0x0001 /* Space */ #define IS_HSH_F 0x0002 /* Hash sign # */ @@ -308,11 +311,15 @@ INTERNAL int z_utf8_to_unicode(struct zint_symbol *symbol, const unsigned char s int *length, const int disallow_4byte); -/* Process `source` for manual FNC1 extra escape sequences, placing result in `dest` with result length in `p_len`, - and setting `fncs` with found FNC1s. `dest` & `fncs` must be at least `length` in size. `eci` is checked to be - ASCII-compatible (UTF-8 & single-byte ECIs, excl. Binary 899). On error sets `errtxt` & returns error no. */ -INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char source[], const int length, - const int eci, unsigned char dest[], char *fncs, int *p_len); +/* Check if `source` starts with manual FNC1 in 1st or 2nd position, returning length of extra escape sequence if so, + else 0 */ +INTERNAL int z_extra_escape_position_fnc1(const unsigned char source[], const int length); + +/* Process `source` for extra escape sequences, placing result in `dest`, updating `p_length`, and setting `fncs` with + any found FNC1s. Sets `p_have_extra_escapes` if any sequences found. `eci` is checked to be ASCII-compatible (UTF-8 + & single-byte ECIs, excl. Binary 899). On error sets `errtxt` & returns error no. */ +INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char source[], int *p_length, const int eci, + unsigned char *dest, char *fncs, int *p_have_extra_escapes); /* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and diff --git a/backend/dmatrix.c b/backend/dmatrix.c index bc8c81da..6297ca15 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -1662,6 +1662,7 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co int tp = 0; int in_macro = 0; int have_extra_escapes = 0; + int position_fnc1 = 0; int tot_length = 0, b256_have_fnc1 = 0; const struct zint_seg *last_seg = &segs[seg_count - 1]; /* gs1 flag values: 0: no GS1, 1: GS1 with FNC1 serparator, 2: GS separator */ @@ -1737,16 +1738,29 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co if (extra_escape_mode && (symbol->symbology != BARCODE_DATAMATRIX || gs1)) { if (symbol->symbology != BARCODE_DATAMATRIX) { - return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 843, - "Can only use extra escape mode with non-variant Data Matrix"); + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 846, + "Can only use Extra Escape mode with non-variant Data Matrix"); } - return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 844, "Cannot use extra escape mode in GS1 mode"); + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 844, "Cannot use Extra Escape mode in GS1 mode"); } if (gs1) { - target[tp++] = 232; + target[tp++] = 232; /* FNC1 */ if (debug_print) fputs("FN1 ", stdout); - } /* FNC1 */ + } else if (extra_escape_mode) { + if ((position_fnc1 = z_extra_escape_position_fnc1(segs[0].source, segs[0].length))) { + if (position_fnc1 == 4) { + target[tp++] = segs[0].source[0] + 1; + if (debug_print) fputs("EEA ", stdout); + } else if (position_fnc1 == 5) { + target[tp++] = z_to_int(segs[0].source, 2) + 130; + if (debug_print) fputs("EED ", stdout); + } + target[tp++] = 232; /* FNC1 */ + if (debug_print) fputs("FN1 ", stdout); + have_extra_escapes = 1; + } + } if (symbol->output_options & READER_INIT) { if (gs1) { @@ -1756,6 +1770,9 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 727, "Cannot have Structured Append and Reader Initialisation at the same time"); } + if (extra_escape_mode) { + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 847, "Cannot use Reader Initialisation in Extra Escape mode"); + } target[tp++] = 234; /* Reader Programming */ if (debug_print) fputs("RP ", stdout); } @@ -1785,8 +1802,6 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co for (i = 0; i < seg_count; i++) { const unsigned char *source; - unsigned char *src_buf; - char *fncs; int length; int src_inc = 0, len_dec = 0; int b256_end = 0, c40_end = 0; @@ -1798,75 +1813,72 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co len_dec += 2; /* Remove RS + EOT from end */ } } - source = segs[i].source + src_inc; - length = segs[i].length - len_dec; + source = segs[i].source + src_inc + position_fnc1; + length = segs[i].length - len_dec - position_fnc1; - src_buf = (unsigned char *) z_alloca(length + 1); - fncs = (char *) z_alloca(length); + if (length) { + unsigned char *src_buf = (unsigned char *) z_alloca(length + 1); + char *fncs = (char *) z_alloca(length); - if (gs1) { - memset(fncs, gs1 == 1, length); - } else { - memset(fncs, 0, length); - if (extra_escape_mode) { - int len; - if ((error_number = z_extra_escapes(symbol, source, length, segs[i].eci, src_buf, fncs, &len))) { - return error_number; - } - if (len != length) { - assert(len < length); - length = len; - assert(length > 0); - src_buf[length] = '\0'; - source = src_buf; - have_extra_escapes = 1; - } - } - } - - if (mailmark) { - assert(seg_count == 1); - assert(length >= 45); - c40_end = 45; /* Min */ - /* Allow specifying greater than 45 */ - if (have_c40 && (symbol->option_1 == 0 || symbol->option_1 > 45)) { - c40_end = symbol->option_1 > 0 && symbol->option_1 < length ? symbol->option_1 : length; - } - /* `DM_C40_START` trumps `DM_B256_START` */ - } else if (have_c40) { - if (symbol->option_1 == 0) { - c40_end = length; - } else if (symbol->option_1 < tot_length) { - c40_end = 0; + if (gs1) { + memset(fncs, gs1 == 1, length); } else { - c40_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length; - } - } else if (have_b256) { - if (b256_have_fnc1) { - b256_end = 0; - } else { - int b256_len; - if (symbol->option_1 == 0) { - b256_end = length; - } else if (symbol->option_1 < tot_length) { - b256_end = 0; - } else { - b256_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length; - } - /* Stop at first FNC1 */ - b256_len = b256_end; - for (b256_end = 0; b256_end < b256_len; b256_end++) { - if (fncs[b256_end] && source[b256_end] == '\x1D') { - break; + memset(fncs, 0, length); + if (extra_escape_mode) { + if ((error_number = z_extra_escapes(symbol, source, &length, segs[i].eci, src_buf, fncs, + &have_extra_escapes))) { + return error_number; + } + if (have_extra_escapes) { + source = src_buf; } } - b256_have_fnc1 = b256_end != b256_len; } - } - if ((error_number = dm_encode(symbol, source, length, segs[i].eci, i + 1 == seg_count, fncs, b256_end, - c40_end, target, &tp))) { - assert(error_number >= ZINT_ERROR); - return error_number; + + if (mailmark) { + assert(seg_count == 1); + assert(length >= 45); + c40_end = 45; /* Min */ + /* Allow specifying greater than 45 */ + if (have_c40 && (symbol->option_1 == 0 || symbol->option_1 > 45)) { + c40_end = symbol->option_1 > 0 && symbol->option_1 < length ? symbol->option_1 : length; + } + /* `DM_C40_START` trumps `DM_B256_START` */ + } else if (have_c40) { + if (symbol->option_1 == 0) { + c40_end = length; + } else if (symbol->option_1 < tot_length) { + c40_end = 0; + } else { + c40_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length; + } + } else if (have_b256) { + if (b256_have_fnc1) { + b256_end = 0; + } else { + int b256_len; + if (symbol->option_1 == 0) { + b256_end = length; + } else if (symbol->option_1 < tot_length) { + b256_end = 0; + } else { + b256_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length; + } + /* Stop at first FNC1 */ + b256_len = b256_end; + for (b256_end = 0; b256_end < b256_len; b256_end++) { + if (fncs[b256_end] && source[b256_end] == '\x1D') { + break; + } + } + b256_have_fnc1 = b256_end != b256_len; + } + } + if ((error_number = dm_encode(symbol, source, length, segs[i].eci, i + 1 == seg_count, fncs, b256_end, + c40_end, target, &tp))) { + assert(error_number >= ZINT_ERROR); + return error_number; + } } if (content_segs) { if (have_extra_escapes) { @@ -1876,6 +1888,7 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co } } tot_length += length; + position_fnc1 = 0; } *p_binlen = tp; diff --git a/backend/library.c b/backend/library.c index 48feefb1..d71f1d96 100644 --- a/backend/library.c +++ b/backend/library.c @@ -367,7 +367,8 @@ static int supports_non_iso8859_1(const int symbology) { /* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE */ static int supports_extra_escape_mode(const struct zint_symbol *const symbol) { return symbol->symbology == BARCODE_CODE128 - || (symbol->symbology == BARCODE_DATAMATRIX && (symbol->input_mode & 0x07) != GS1_MODE); + || ((symbol->symbology == BARCODE_AZTEC || symbol->symbology == BARCODE_DATAMATRIX) + && (symbol->input_mode & 0x07) != GS1_MODE); } /* Returns 1 if symbology supports HRT */ @@ -752,12 +753,15 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char * case '\\': if (escaped_string) escaped_string[out_posn] = vals[z_posn(escs, ch)]; in_posn += 2; + /* Note: if given double backslash following by caret "\\^" then will be passed through as "\^", + i.e. the start of an extra escape sequence, avoiding the check below, so each symbology needs + to also check themselves */ break; case '^': /* Symbology specific */ if (!extra_escape_mode || !can_extra_escape) { if (!extra_escape_mode) { return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 798, - "Escape '\\^' only valid in extra escape mode"); + "Escape '\\^' only valid in Extra Escape mode"); } return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 213, "Extra escape '\\^' not valid for this symbology and/or input mode"); diff --git a/backend/medical.c b/backend/medical.c index b1fc9979..9a8764d7 100644 --- a/backend/medical.c +++ b/backend/medical.c @@ -200,7 +200,7 @@ INTERNAL int zint_pharma_two(struct zint_symbol *symbol, unsigned char source[], /* Italian Pharmacode */ INTERNAL int zint_code32(struct zint_symbol *symbol, unsigned char source[], int length) { static const unsigned char TABELLA[] = "0123456789BCDFGHJKLMNPQRSTUVWXYZ"; - int i, zeroes, checksum, checkpart, checkdigit; + int i, checksum, checkpart, checkdigit; unsigned char local_source[10], risultante[7]; unsigned int pharmacode, devisor; int codeword[6]; @@ -217,9 +217,7 @@ INTERNAL int zint_code32(struct zint_symbol *symbol, unsigned char source[], int } /* Add leading zeros as required */ - zeroes = 8 - length; - memset(local_source, '0', zeroes); - memcpy(local_source + zeroes, source, length); + z_zero_fill(source, length, local_source, 8); /* Calculate the check digit */ checksum = 0; @@ -297,7 +295,7 @@ INTERNAL int zint_code32(struct zint_symbol *symbol, unsigned char source[], int IFA-Info_Check_Digit_Calculations_PZN_PPN_UDI_EN.pdf */ INTERNAL int zint_pzn(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, error_number, zeroes; + int i, error_number; int count, check_digit; unsigned char have_check_digit = '\0'; unsigned char local_source[1 + 8]; /* '-' prefix + 8 digits */ @@ -318,10 +316,7 @@ INTERNAL int zint_pzn(struct zint_symbol *symbol, unsigned char source[], int le } local_source[0] = '-'; - zeroes = 7 - pzn7 - length + 1; - for (i = 1; i < zeroes; i++) - local_source[i] = '0'; - memcpy(local_source + zeroes, source, length); + z_zero_fill(source, length, local_source + 1, 7 - pzn7); count = 0; for (i = 1; i < 8 - pzn7; i++) { diff --git a/backend/postal.c b/backend/postal.c index 5962428b..b8e6a938 100644 --- a/backend/postal.c +++ b/backend/postal.c @@ -181,7 +181,7 @@ INTERNAL int zint_koreapost(struct zint_symbol *symbol, unsigned char source[], {'1','3','1','5','0','6','1','3','1','3'}, {'0','4','1','3','1','3','1','7','1','3'}, { "17131713" }, { "13171713" } }; - int total, i, check, zeroes, error_number = 0; + int total, i, check, error_number = 0; unsigned char local_source[8]; char dest[80]; char *d = dest; @@ -195,9 +195,7 @@ INTERNAL int zint_koreapost(struct zint_symbol *symbol, unsigned char source[], return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 485, "Invalid character at position %d in input (digits only)", i); } - zeroes = 6 - length; - memset(local_source, '0', zeroes); - memcpy(local_source + zeroes, source, length); + z_zero_fill(source, length, local_source, 6); total = 0; for (i = 0; i < 6; i++) { diff --git a/backend/rss.c b/backend/rss.c index 0d5e60c6..42b399ba 100644 --- a/backend/rss.c +++ b/backend/rss.c @@ -181,11 +181,8 @@ static uint64_t dbar_to_uint64(const unsigned char source[], const int length) { /* Helper to construct zero-padded GTIN14 with check digit, returning `buf` for convenience */ static unsigned char *dbar_gtin14(const unsigned char *source, const int length, unsigned char buf[14]) { - const int zeroes = 13 - length; + const int zeroes = z_zero_fill(source, length, buf, 13); - assert(zeroes >= 0); - memset(buf, '0', zeroes); - memcpy(buf + zeroes, source, length); buf[zeroes + length] = zint_gs1_check_digit(buf, 13); return buf; diff --git a/backend/tests/test_auspost.c b/backend/tests/test_auspost.c index 957a3e79..27090f8c 100644 --- a/backend/tests/test_auspost.c +++ b/backend/tests/test_auspost.c @@ -41,25 +41,25 @@ static void test_large(const testCtx *const p_ctx) { int ret; int expected_rows; int expected_width; + const char *expected_errtxt; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_AUSPOST, "1", 23, 0, 3, 133 }, - /* 1*/ { BARCODE_AUSPOST, "1", 24, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 2*/ { BARCODE_AUSPOST, "1", 18, 0, 3, 133 }, - /* 3*/ { BARCODE_AUSPOST, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 4*/ { BARCODE_AUSPOST, "1", 16, 0, 3, 103 }, - /* 5*/ { BARCODE_AUSPOST, "1", 17, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 6*/ { BARCODE_AUSPOST, "1", 13, 0, 3, 103 }, - /* 7*/ { BARCODE_AUSPOST, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 8*/ { BARCODE_AUSPOST, "1", 8, 0, 3, 73 }, - /* 9*/ { BARCODE_AUSPOST, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 10*/ { BARCODE_AUSREPLY, "1", 8, 0, 3, 73 }, - /* 11*/ { BARCODE_AUSREPLY, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 12*/ { BARCODE_AUSROUTE, "1", 8, 0, 3, 73 }, - /* 13*/ { BARCODE_AUSROUTE, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 }, - /* 14*/ { BARCODE_AUSREDIRECT, "1", 8, 0, 3, 73 }, - /* 15*/ { BARCODE_AUSREDIRECT, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 }, + /* 0*/ { BARCODE_AUSPOST, "1", 23, 0, 3, 133, "" }, + /* 1*/ { BARCODE_AUSPOST, "1", 24, ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input length 24 too long (maximum 23)" }, + /* 2*/ { BARCODE_AUSPOST, "1", 8, 0, 3, 73, "" }, + /* 3*/ { BARCODE_AUSPOST, "1", 9, 0, 3, 103, "" }, + /* 4*/ { BARCODE_AUSPOST, "1", 13, 0, 3, 103, "" }, + /* 5*/ { BARCODE_AUSPOST, "1", 16, 0, 3, 103, "" }, + /* 6*/ { BARCODE_AUSPOST, "1", 17, 0, 3, 133, "" }, + /* 7*/ { BARCODE_AUSPOST, "1", 18, 0, 3, 133, "" }, + /* 8*/ { BARCODE_AUSPOST, "1", 22, 0, 3, 133, "" }, + /* 9*/ { BARCODE_AUSREPLY, "1", 8, 0, 3, 73, "" }, + /* 10*/ { BARCODE_AUSREPLY, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, + /* 11*/ { BARCODE_AUSROUTE, "1", 8, 0, 3, 73, "" }, + /* 12*/ { BARCODE_AUSROUTE, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, + /* 13*/ { BARCODE_AUSREDIRECT, "1", 8, 0, 3, 73, "" }, + /* 14*/ { BARCODE_AUSREDIRECT, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -77,17 +77,25 @@ static void test_large(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length); - assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf)); + assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", + i, data[i].length, (int) strlen(data_buf)); - length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data_buf, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(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); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); 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_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 strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected_errtxt); ZBarcode_Delete(symbol); } @@ -108,30 +116,54 @@ static void test_hrt(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_AUSPOST, -1, "12345678", "", "" }, /* None */ + /* 0*/ { BARCODE_AUSPOST, -1, "12345678", "", "" }, /* 1*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678", "", "1112345678" }, - /* 2*/ { BARCODE_AUSPOST, -1, "1234567890123", "", "" }, /* None */ - /* 3*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123", "", "591234567890123" }, - /* 4*/ { BARCODE_AUSPOST, -1, "1234567890123456", "", "" }, /* None */ - /* 5*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123456", "", "591234567890123456" }, - /* 6*/ { BARCODE_AUSPOST, -1, "123456789012345678", "", "" }, /* None */ - /* 7*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "123456789012345678", "", "62123456789012345678" }, - /* 8*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", "" }, /* None */ - /* 9*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678901234567890123", "", "6212345678901234567890123" }, - /* 10*/ { BARCODE_AUSREPLY, -1, "1234567", "", "" }, /* None */ - /* 11*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "1234567", "", "4501234567" }, - /* 12*/ { BARCODE_AUSREPLY, -1, "12345678", "", "" }, /* None */ - /* 13*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "12345678", "", "4512345678" }, - /* 14*/ { BARCODE_AUSROUTE, -1, "123456", "", "" }, /* None */ - /* 15*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "123456", "", "8700123456" }, - /* 16*/ { BARCODE_AUSROUTE, -1, "12345678", "", "" }, /* None */ - /* 17*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345678", "", "8712345678" }, - /* 18*/ { BARCODE_AUSROUTE, -1, "12345", "", "" }, /* None */ - /* 19*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345", "", "8700012345" }, - /* 20*/ { BARCODE_AUSREDIRECT, -1, "12345678", "", "" }, /* None */ - /* 21*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "12345678", "", "9212345678" }, - /* 22*/ { BARCODE_AUSREDIRECT, -1, "1234", "", "" }, /* None */ - /* 23*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "1234", "", "9200001234" }, + /* 2*/ { BARCODE_AUSPOST, -1, "1", "", "" }, + /* 3*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1", "", "1100000001" }, + /* 4*/ { BARCODE_AUSPOST, -1, "12", "", "" }, + /* 5*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12", "", "1100000012" }, + /* 6*/ { BARCODE_AUSPOST, -1, "1234567", "", "" }, + /* 7*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567", "", "1101234567" }, + /* 8*/ { BARCODE_AUSPOST, -1, "0", "", "" }, + /* 9*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "0", "", "0000000000" }, + /* 10*/ { BARCODE_AUSPOST, -1, "123456789", "", "" }, + /* 11*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "123456789", "", "59123456789" }, + /* 12*/ { BARCODE_AUSPOST, -1, "1234567890123", "", "" }, + /* 13*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123", "", "591234567890123" }, + /* 14*/ { BARCODE_AUSPOST, -1, "12345678D0123", "", "" }, + /* 15*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678D0123", "", "5912345678D0123" }, + /* 16*/ { BARCODE_AUSPOST, -1, "00000000D0123", "", "" }, + /* 17*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "00000000D0123", "", "0000000000D0123" }, + /* 18*/ { BARCODE_AUSPOST, -1, "1234567890123456", "", "" }, + /* 19*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123456", "", "591234567890123456" }, + /* 20*/ { BARCODE_AUSPOST, -1, "0000000090123456", "", "" }, + /* 21*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "0000000090123456", "", "000000000090123456" }, + /* 22*/ { BARCODE_AUSPOST, -1, "123456789012345678", "", "" }, + /* 23*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "123456789012345678", "", "62123456789012345678" }, + /* 24*/ { BARCODE_AUSPOST, -1, "12345678901234567D", "", "" }, + /* 25*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678901234567D", "", "6212345678901234567D" }, + /* 26*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", "" }, + /* 27*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678901234567890123", "", "6212345678901234567890123" }, + /* 28*/ { BARCODE_AUSPOST, -1, "00000000901234567890123", "", "" }, + /* 29*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "00000000901234567890123", "", "0000000000901234567890123" }, + /* 30*/ { BARCODE_AUSREPLY, -1, "1234567", "", "" }, + /* 31*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "1234567", "", "4501234567" }, + /* 32*/ { BARCODE_AUSREPLY, -1, "12345678", "", "" }, + /* 33*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "12345678", "", "4512345678" }, + /* 34*/ { BARCODE_AUSREPLY, -1, "00000", "", "" }, + /* 35*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "00000", "", "4500000000" }, + /* 36*/ { BARCODE_AUSROUTE, -1, "123456", "", "" }, + /* 37*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "123456", "", "8700123456" }, + /* 38*/ { BARCODE_AUSROUTE, -1, "12345678", "", "" }, + /* 39*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345678", "", "8712345678" }, + /* 40*/ { BARCODE_AUSROUTE, -1, "12345", "", "" }, + /* 41*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345", "", "8700012345" }, + /* 42*/ { BARCODE_AUSREDIRECT, -1, "12345678", "", "" }, + /* 43*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "12345678", "", "9212345678" }, + /* 44*/ { BARCODE_AUSREDIRECT, -1, "1234", "", "" }, + /* 45*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "1234", "", "9200001234" }, + /* 46*/ { BARCODE_AUSREDIRECT, -1, "0", "", "" }, + /* 47*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "0", "", "9200000000" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -193,31 +225,39 @@ static void test_input(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73, "" }, - /* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (first 8 characters) (digits only)" }, - /* 2*/ { BARCODE_AUSPOST, "0000000A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (first 8 characters) (digits only)" }, - /* 3*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" }, - /* 4*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" }, - /* 5*/ { BARCODE_AUSPOST, "00000000ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" }, - /* 6*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" }, - /* 7*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" }, - /* 8*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 16 in input (digits only for FCC 59 length 16)" }, - /* 9*/ { BARCODE_AUSPOST, "000000009012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 16 in input (digits only for FCC 59 length 16)" }, - /* 10*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133, "" }, /* Length 18 */ - /* 11*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" }, - /* 12*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 23 in input (digits only for FCC 62 length 23)" }, - /* 13*/ { BARCODE_AUSPOST, "0000000090123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 23 in input (digits only for FCC 62 length 23)" }, - /* 14*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input length 7 wrong (8, 13, 16, 18 or 23 characters required)" }, /* No leading zeroes added */ - /* 15*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" }, - /* 16*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, /* Leading zeroes added */ - /* 17*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, - /* 18*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" }, - /* 19*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" }, - /* 20*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, - /* 21*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" }, - /* 22*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" }, - /* 23*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" }, - /* 24*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, + /* 0*/ { BARCODE_AUSPOST, "1", 0, 3, 73, "" }, /* Leading zeroes added */ + /* 1*/ { BARCODE_AUSPOST, "1234567", 0, 3, 73, "" }, + /* 2*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73, "" }, + /* 3*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (digits only for Standard Customer Barcode)" }, + /* 4*/ { BARCODE_AUSPOST, "123456789", 0, 3, 103, "" }, + /* 5*/ { BARCODE_AUSPOST, "1234567A9", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 8 in DPID (digits only)" }, + /* 6*/ { BARCODE_AUSPOST, "12345678A", 0, 3, 103, "" }, + /* 7*/ { BARCODE_AUSPOST, "12345678AB", 0, 3, 103, "" }, + /* 8*/ { BARCODE_AUSPOST, "12345678ABc", 0, 3, 103, "" }, + /* 9*/ { BARCODE_AUSPOST, "12345678ABcd", 0, 3, 103, "" }, + /* 10*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" }, + /* 11*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" }, + /* 12*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" }, /* Barcode 2 all-digits */ + /* 13*/ { BARCODE_AUSPOST, "12345678ABcd #", 0, 3, 133, "" }, /* Barcode 3 */ + /* 14*/ { BARCODE_AUSPOST, "123456789012345A", 0, 3, 133, "" }, /* Barcode 3 */ + /* 15*/ { BARCODE_AUSPOST, "12345678901234567", 0, 3, 133, "" }, + /* 16*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" }, + /* 17*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 407: Invalid character at position 23 in input (digits only for Customer Barcode 3 length 23)" }, + /* 18*/ { BARCODE_AUSPOST, "123456789012345678A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 407: Invalid character at position 19 in input (digits only for Customer Barcode 3 length 19)" }, + /* 19*/ { BARCODE_AUSPOST, "12345678A0123456789012", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 407: Invalid character at position 9 in input (digits only for Customer Barcode 3 length 22)" }, + /* 20*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" }, + /* 21*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, /* Leading zeroes added */ + /* 22*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, + /* 23*/ { BARCODE_AUSREPLY, "12345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 6 in DPID (digits only)" }, + /* 24*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" }, + /* 25*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" }, + /* 26*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, + /* 27*/ { BARCODE_AUSROUTE, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 8 in DPID (digits only)" }, + /* 28*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" }, + /* 29*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" }, + /* 30*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" }, + /* 31*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" }, + /* 32*/ { BARCODE_AUSREDIRECT, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 1 in DPID (digits only)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -237,22 +277,32 @@ static void test_input(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, TCU(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); - assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt); - assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); + assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", + i, ret ? "set" : "empty", symbol->errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", + i, symbol->errtxt, data[i].expected_errtxt); 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_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); if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { char modules_dump[4096]; - assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i); - ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), + NULL); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), + ret); ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump); assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", @@ -494,7 +544,9 @@ static void test_fuzz(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, -1, -1, -1 /*output_options*/, + data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, TCU(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); diff --git a/backend/tests/test_aztec.c b/backend/tests/test_aztec.c index 831d77bf..f36aea58 100644 --- a/backend/tests/test_aztec.c +++ b/backend/tests/test_aztec.c @@ -193,7 +193,7 @@ static void test_large(const testCtx *const p_ctx) { char data_buf[ZINT_MAX_DATA_LEN]; - /* Only do ZXing-C++ test if asked, too slow otherwise */ + /* Only do zxing-cpp test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); testStartSymbol(p_ctx->func_name, &symbol); @@ -420,6 +420,7 @@ static void test_options(const testCtx *const p_ctx) { struct item { int symbology; int input_mode; + int eci; int output_options; int option_1; int option_2; @@ -437,62 +438,75 @@ static void test_options(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, - /* 1*/ { BARCODE_AZTEC, -1, -1, -1, -1, ZINT_AZTEC_FULL, { 0, 0, "" }, "1234567", 0, 19, 19, "", (57 << 8) | 4, 5, ZINT_AZTEC_FULL }, - /* 2*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "", (35 << 8) | 3, 1, 0 }, - /* 3*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, - /* 4*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "", (35 << 8) | 3, 1, 0 }, - /* 5*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "12345678901", 0, 15, 15, "", (29 << 8) | 2, 1, 0 }, - /* 6*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "123456789012", 0, 15, 15, "", (29 << 8) | 2, 1, 0 }, - /* 7*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567890123456", 0, 15, 15, "", (11 << 8) | 1, 1, 0 }, - /* 8*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "123456789012345678", 0, 19, 19, "", (60 << 8) | 4, 2, 0 }, - /* 9*/ { BARCODE_AZTEC, -1, -1, 1, -1, ZINT_AZTEC_FULL, { 0, 0, "" }, "123456789012345678", 0, 19, 19, "", (23 << 8) | 2, 5, ZINT_AZTEC_FULL }, - /* 10*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567890123456789", 0, 19, 19, "", (57 << 8) | 4, 2, 0 }, - /* 11*/ { BARCODE_AZTEC, -1, -1, 2, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "", (35 << 8) | 3, 1, 0 }, - /* 12*/ { BARCODE_AZTEC, -1, -1, 3, -1, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "", (72 << 8) | 4, 2, 0 }, - /* 13*/ { BARCODE_AZTEC, -1, -1, 3, -1, -1, { 0, 0, "" }, "12345678901", 0, 19, 19, "", (70 << 8) | 4, 2, 0 }, - /* 14*/ { BARCODE_AZTEC, -1, -1, 4, -1, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "", (72 << 8) | 4, 2, 0 }, - /* 15*/ { BARCODE_AZTEC, -1, -1, 5, -1, -1, { 0, 0, "" }, "1234567890", ZINT_WARN_INVALID_OPTION, 15, 15, "Warning 503: Error correction level '5' out of range (1 to 4), ignoring", (35 << 8) | 3, 1, 0 }, - /* 16*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, { 0, 0, "" }, "12345678901234567890", ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Input too long for Version 1, requires 15 codewords (maximum 14)", -1, 1, 0 }, - /* 17*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "", (47 << 8) | 4, 5, 0 }, - /* 18*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, { 0, 0, "" }, "12345678901", 0, 19, 19, "", (42 << 8) | 3, 5, 0 }, - /* 19*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890123456", 0, 19, 19, "", (28 << 8) | 2, 5, 0 }, - /* 20*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, { 0, 0, "" }, "123456789012345678901", 0, 19, 19, "", (14 << 8) | 1, 5, 0 }, - /* 21*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, { 0, 0, "" }, "123456789012345678901234", ZINT_WARN_NONCOMPLIANT, 19, 19, "Warning 708: Number of ECC codewords 4 less than 5% + 3 of data codewords 17", (4 << 8) | 0, 5, 0 }, - /* 22*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890123456780123456", ZINT_WARN_NONCOMPLIANT, 19, 19, "Warning 706: Number of ECC codewords 3 at minimum", -1, 5, 0 }, - /* 23*/ { BARCODE_AZTEC, -1, -1, -1, 36, -1, { 0, 0, "" }, "1234567890", 0, 151, 151, "", (99 << 8) | 4, 36, 0 }, - /* 24*/ { BARCODE_AZTEC, -1, -1, -1, 37, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Version '37' out of range (1 to 36)", -1, 37, 0 }, - /* 25*/ { BARCODE_AZTEC, -1, -1, -1, -2, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Version '-2' out of range (1 to 36)", -1, -2, 0 }, - /* 26*/ { BARCODE_AZTEC, GS1_MODE, READER_INIT, -1, -1, -1, { 0, 0, "" }, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 501: Cannot use Reader Initialisation in GS1 mode", -1, 0, 0 }, - /* 27*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, -1, { 0, 0, "" }, "[91]A", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, - /* 28*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(91)A", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, - /* 29*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(91)(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", -1, 0, 0 }, - /* 30*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, /* Escaped parens now work without ESCAPE_MODE */ - /* 31*/ { BARCODE_AZTEC, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, - /* 32*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, -1, { 0, 0, "" }, "A", 0, 109, 109, "", (99 << 8) | 4, 26, 0 }, /* 22 layers */ - /* 33*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 709: Version '27' out of range for Reader Initialisation symbols (maximum 26)", -1, 27, 0 }, /* 23 layers */ - /* 34*/ { BARCODE_AZTEC, -1, READER_INIT, 4, -1, -1, { 0, 0, "" }, "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377", ZINT_ERROR_TOO_LONG, -1, -1, "Error 506: Input too long for Reader Initialisation, requires 23 layers (maximum 22)", 4, 27, 0 }, /* 23 layers */ - /* 35*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Compact 1 layer */ - /* 36*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 3, -1, { 0, 0, "" }, "A", 0, 19, 19, "", (80 << 8) | 4, 5, 0 }, /* Compact 3 layers gets set to full 1 layer if READER_INIT set */ - /* 37*/ { BARCODE_AZTEC, -1, -1, 1, -1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Compact 1 layer */ - /* 38*/ { BARCODE_AZTEC, -1, READER_INIT, 1, -1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Still compact 1 layer if READER_INIT set */ - /* 39*/ { BARCODE_AZTEC, -1, READER_INIT, -1, -1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Compact 1 layer */ - /* 40*/ { BARCODE_AZTEC, -1, READER_INIT, -1, -1, ZINT_AZTEC_FULL, { 0, 0, "" }, "A", 0, 19, 19, "", (80 << 8) | 4, 5, ZINT_AZTEC_FULL }, /* Full 1 layer */ - /* 41*/ { BARCODE_AZRUNE, -1, -1, -1, -1, -1, { 0, 0, "" }, "0001", ZINT_ERROR_TOO_LONG, -1, -1, "Error 507: Input length 4 too long (maximum 3)", -1, 0, 0 }, - /* 42*/ { BARCODE_AZRUNE, -1, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 508: Invalid character at position 1 in input (digits only)", -1, 0, 0 }, - /* 43*/ { BARCODE_AZRUNE, -1, -1, -1, -1, -1, { 0, 0, "" }, "256", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 509: Input value out of range (0 to 255)", -1, 0, 0 }, - /* 44*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 1, 2, "" }, "1234567890", 0, 19, 19, "", (65 << 8) | 4, 2, 0 }, - /* 45*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 1, 2, {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2'} }, "1234567890", 0, 23, 23, "", (41 << 8) | 3, 3, 0 }, - /* 46*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 1, 1, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 701: Structured Append count '1' out of range (2 to 26)", -1, 0, 0 }, - /* 47*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 0, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index '0' out of range (1 to count 2)", -1, 0, 0 }, - /* 48*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 3, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index '3' out of range (1 to count 2)", -1, 0, 0 }, - /* 49*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, { 1, 2, "A B" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 703: Structured Append ID cannot contain spaces", -1, 0, 0 }, - /* 50*/ { BARCODE_HIBC_AZTEC, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890;", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 11 in input (alphanumerics, space and \"-.$/+%\" only)", -1, 0, 0 }, + /* 0*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, + /* 1*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, ZINT_AZTEC_FULL, { 0, 0, "" }, "1234567", 0, 19, 19, "", (57 << 8) | 4, 5, ZINT_AZTEC_FULL }, + /* 2*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "", (35 << 8) | 3, 1, 0 }, + /* 3*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, + /* 4*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "", (35 << 8) | 3, 1, 0 }, + /* 5*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "12345678901", 0, 15, 15, "", (29 << 8) | 2, 1, 0 }, + /* 6*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "123456789012", 0, 15, 15, "", (29 << 8) | 2, 1, 0 }, + /* 7*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567890123456", 0, 15, 15, "", (11 << 8) | 1, 1, 0 }, + /* 8*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "123456789012345678", 0, 19, 19, "", (60 << 8) | 4, 2, 0 }, + /* 9*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, ZINT_AZTEC_FULL, { 0, 0, "" }, "123456789012345678", 0, 19, 19, "", (23 << 8) | 2, 5, ZINT_AZTEC_FULL }, + /* 10*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "1234567890123456789", 0, 19, 19, "", (57 << 8) | 4, 2, 0 }, + /* 11*/ { BARCODE_AZTEC, -1, -1, -1, 2, -1, -1, { 0, 0, "" }, "1234567890", 0, 15, 15, "", (35 << 8) | 3, 1, 0 }, + /* 12*/ { BARCODE_AZTEC, -1, -1, -1, 3, -1, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "", (72 << 8) | 4, 2, 0 }, + /* 13*/ { BARCODE_AZTEC, -1, -1, -1, 3, -1, -1, { 0, 0, "" }, "12345678901", 0, 19, 19, "", (70 << 8) | 4, 2, 0 }, + /* 14*/ { BARCODE_AZTEC, -1, -1, -1, 4, -1, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "", (72 << 8) | 4, 2, 0 }, + /* 15*/ { BARCODE_AZTEC, -1, -1, -1, 5, -1, -1, { 0, 0, "" }, "1234567890", ZINT_WARN_INVALID_OPTION, 15, 15, "Warning 503: Error correction level '5' out of range (1 to 4), ignoring", (35 << 8) | 3, 1, 0 }, + /* 16*/ { BARCODE_AZTEC, -1, -1, -1, -1, 1, -1, { 0, 0, "" }, "12345678901234567890", ZINT_ERROR_TOO_LONG, -1, -1, "Error 505: Input too long for Version 1, requires 15 codewords (maximum 14)", -1, 1, 0 }, + /* 17*/ { BARCODE_AZTEC, -1, -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890", 0, 19, 19, "", (47 << 8) | 4, 5, 0 }, + /* 18*/ { BARCODE_AZTEC, -1, -1, -1, -1, 5, -1, { 0, 0, "" }, "12345678901", 0, 19, 19, "", (42 << 8) | 3, 5, 0 }, + /* 19*/ { BARCODE_AZTEC, -1, -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890123456", 0, 19, 19, "", (28 << 8) | 2, 5, 0 }, + /* 20*/ { BARCODE_AZTEC, -1, -1, -1, -1, 5, -1, { 0, 0, "" }, "123456789012345678901", 0, 19, 19, "", (14 << 8) | 1, 5, 0 }, + /* 21*/ { BARCODE_AZTEC, -1, -1, -1, -1, 5, -1, { 0, 0, "" }, "123456789012345678901234", ZINT_WARN_NONCOMPLIANT, 19, 19, "Warning 708: Number of ECC codewords 4 less than 5% + 3 of data codewords 17", (4 << 8) | 0, 5, 0 }, + /* 22*/ { BARCODE_AZTEC, -1, -1, -1, -1, 5, -1, { 0, 0, "" }, "1234567890123456780123456", ZINT_WARN_NONCOMPLIANT, 19, 19, "Warning 706: Number of ECC codewords 3 at minimum", -1, 5, 0 }, + /* 23*/ { BARCODE_AZTEC, -1, -1, -1, -1, 36, -1, { 0, 0, "" }, "1234567890", 0, 151, 151, "", (99 << 8) | 4, 36, 0 }, + /* 24*/ { BARCODE_AZTEC, -1, -1, -1, -1, 37, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Version '37' out of range (1 to 36)", -1, 37, 0 }, + /* 25*/ { BARCODE_AZTEC, -1, -1, -1, -1, -2, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 510: Version '-2' out of range (1 to 36)", -1, -2, 0 }, + /* 26*/ { BARCODE_AZTEC, GS1_MODE, -1, READER_INIT, -1, -1, -1, { 0, 0, "" }, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 501: Cannot use Reader Initialisation in GS1 mode", -1, 0, 0 }, + /* 27*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[91]A", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, + /* 28*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "(91)A", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, + /* 29*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "(91)(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", -1, 0, 0 }, + /* 30*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, /* Escaped parens now work without ESCAPE_MODE */ + /* 31*/ { BARCODE_AZTEC, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, + /* 32*/ { BARCODE_AZTEC, -1, -1, READER_INIT, -1, 26, -1, { 0, 0, "" }, "A", 0, 109, 109, "", (99 << 8) | 4, 26, 0 }, /* 22 layers */ + /* 33*/ { BARCODE_AZTEC, -1, -1, READER_INIT, -1, 27, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 709: Version '27' out of range for Reader Initialisation symbols (maximum 26)", -1, 27, 0 }, /* 23 layers */ + /* 34*/ { BARCODE_AZTEC, -1, -1, READER_INIT, 4, -1, -1, { 0, 0, "" }, "\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377", ZINT_ERROR_TOO_LONG, -1, -1, "Error 506: Input too long for Reader Initialisation, requires 23 layers (maximum 22)", 4, 27, 0 }, /* 23 layers */ + /* 35*/ { BARCODE_AZTEC, -1, -1, READER_INIT, -1, 1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Compact 1 layer */ + /* 36*/ { BARCODE_AZTEC, -1, -1, READER_INIT, -1, 3, -1, { 0, 0, "" }, "A", 0, 19, 19, "", (80 << 8) | 4, 5, 0 }, /* Compact 3 layers gets set to full 1 layer if READER_INIT set */ + /* 37*/ { BARCODE_AZTEC, -1, -1, -1, 1, -1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Compact 1 layer */ + /* 38*/ { BARCODE_AZTEC, -1, -1, READER_INIT, 1, -1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Still compact 1 layer if READER_INIT set */ + /* 39*/ { BARCODE_AZTEC, -1, -1, READER_INIT, -1, -1, -1, { 0, 0, "" }, "A", 0, 15, 15, "", (76 << 8) | 4, 1, 0 }, /* Compact 1 layer */ + /* 40*/ { BARCODE_AZTEC, -1, -1, READER_INIT, -1, -1, ZINT_AZTEC_FULL, { 0, 0, "" }, "A", 0, 19, 19, "", (80 << 8) | 4, 5, ZINT_AZTEC_FULL }, /* Full 1 layer */ + /* 41*/ { BARCODE_AZRUNE, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "0001", ZINT_ERROR_TOO_LONG, -1, -1, "Error 507: Input length 4 too long (maximum 3)", -1, 0, 0 }, + /* 42*/ { BARCODE_AZRUNE, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 508: Invalid character at position 1 in input (digits only)", -1, 0, 0 }, + /* 43*/ { BARCODE_AZRUNE, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "256", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 509: Input value out of range (0 to 255)", -1, 0, 0 }, + /* 44*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 1, 2, "" }, "1234567890", 0, 19, 19, "", (65 << 8) | 4, 2, 0 }, + /* 45*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 1, 2, {'1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0','1','2'} }, "1234567890", 0, 23, 23, "", (41 << 8) | 3, 3, 0 }, + /* 46*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 1, 1, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 701: Structured Append count '1' out of range (2 to 26)", -1, 0, 0 }, + /* 47*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 0, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index '0' out of range (1 to count 2)", -1, 0, 0 }, + /* 48*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 3, 2, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 702: Structured Append index '3' out of range (1 to count 2)", -1, 0, 0 }, + /* 49*/ { BARCODE_AZTEC, -1, -1, -1, -1, -1, -1, { 1, 2, "A B" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 703: Structured Append ID cannot contain spaces", -1, 0, 0 }, + /* 50*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "12\\^112", 0, 15, 15, "", (47 << 8) | 4, 1, 0 }, + /* 51*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "12\\^A12", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 717: Unrecognized extra escape \"\\^A\"", -1, 0, 0 }, + /* 52*/ { BARCODE_AZTEC, GS1_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 806: Cannot use Extra Escape mode in GS1 mode", -1, 0, 0 }, + /* 53*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, -1, READER_INIT, -1, -1, -1, { 0, 0, "" }, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 807: Cannot use Reader Initialisation in Extra Escape mode", -1, 0, 0 }, + /* 54*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 20, -1, -1, -1, -1, { 0, 0, "" }, "DE\\^1\\^^XY", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra Escape mode requires ASCII-compatible ECI", -1, 0, 0 }, + /* 55*/ { BARCODE_HIBC_AZTEC, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890;", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 11 in input (alphanumerics, space and \"-.$/+%\" only)", -1, 0, 0 }, + /* 56*/ { BARCODE_HIBC_AZTEC, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 805: Can only use Extra Escape mode with non-variant Aztec Code", -1, 0, 0 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; + char escaped[8192]; + char cmp_buf[32768]; + char cmp_msg[8192]; + + /* Only do zxing-cpp test if asked, too slow otherwise */ + int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); + testStartSymbol(p_ctx->func_name, &symbol); for (i = 0; i < data_size; i++) { @@ -502,7 +516,7 @@ static void test_options(const testCtx *const p_ctx) { symbol = ZBarcode_Create(); assert_nonnull(symbol, "Symbol not created\n"); - length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, + length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, data[i].eci, data[i].option_1, data[i].option_2, data[i].option_3, data[i].output_options, data[i].data, -1, debug); if (data[i].structapp.count) { @@ -530,6 +544,25 @@ static void test_options(const testCtx *const p_ctx) { assert_equal(symbol->option_3, data[i].expected_option_3, "i:%d symbol->option_3 %d != %d\n", i, symbol->option_3, data[i].expected_option_3); + if (ret < ZINT_ERROR) { + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[22801 + 1]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, 1 /*zxingcpp_cmp*/, + cmp_buf, sizeof(cmp_buf), &cmp_len); + assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); + + ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, + escaped, &ret_len); + assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n", + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, + escaped); + } + } + ZBarcode_Delete(symbol); } @@ -1135,98 +1168,98 @@ static void test_encode(const testCtx *const p_ctx) { "000011110110101110000111110100000111001011000" }, /* 17*/ { BARCODE_AZTEC, GS1_MODE, 3, -1, -1, -1, -1, { 0, 0, "" }, "[01]04610044273252[21]LRFX)k\350\255\362\357\027\231: S\224\237\303\035\207", -1, 0, 19, 19, 1, 899, "BWIP-JS #354 1st example", + /*190*/ { BARCODE_AZTEC, DATA_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "j>\350\255\362\357\027\231: S\224\237\303\035\207", -1, 0, 19, 19, 1, 899, "BWIP-JS #354 1st example", "1101010010011101000" "1100111010011110011" "1001101000000110101" @@ -6552,7 +6653,7 @@ static void test_encode(const testCtx *const p_ctx) { "1110110001011011110" "0001111011111000101" }, - /*187*/ { BARCODE_AZTEC, FAST_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "j>\350\255\362\357\027\231: S\224\237\303\035\207", -1, 0, 19, 19, 0, 899, "BWIP-JS #354 1st example; BWIPP different encodation, 3 codewords shorter (see above)", + /*191*/ { BARCODE_AZTEC, FAST_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "j>\350\255\362\357\027\231: S\224\237\303\035\207", -1, 0, 19, 19, 0, 899, "BWIP-JS #354 1st example; BWIPP different encodation, 3 codewords shorter (see above)", "1111001111001101001" "1011001011010001101" "0010010101011000011" @@ -6573,7 +6674,7 @@ static void test_encode(const testCtx *const p_ctx) { "0000111100101101101" "1011101101111100011" }, - /*188*/ { BARCODE_AZTEC, DATA_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "\035\316\244. D\004\275\031}\244\311\030\035>t", -1, 0, 19, 19, 1, 899, "BWIP-JS #354 2nd example", + /*192*/ { BARCODE_AZTEC, DATA_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "\035\316\244. D\004\275\031}\244\311\030\035>t", -1, 0, 19, 19, 1, 899, "BWIP-JS #354 2nd example", "1110110111000100010" "1110111001100010100" "1010011100101001011" @@ -6594,7 +6695,7 @@ static void test_encode(const testCtx *const p_ctx) { "0111010000000000111" "0001000001010001010" }, - /*189*/ { BARCODE_AZTEC, FAST_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "\035\316\244. D\004\275\031}\244\311\030\035>t", -1, 0, 19, 19, 0, 899, "BWIP-JS #354 2nd example; BWIPP same as above", + /*193*/ { BARCODE_AZTEC, FAST_MODE, -1, -1, -1, 2, -1, { 0, 0, "" }, "\035\316\244. D\004\275\031}\244\311\030\035>t", -1, 0, 19, 19, 0, 899, "BWIP-JS #354 2nd example; BWIPP same as above", "1110001010011101111" "1001010010100100110" "1100010011111011111" @@ -6615,7 +6716,647 @@ static void test_encode(const testCtx *const p_ctx) { "0001011110011100101" "0000001100111001111" }, - /*190*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "0", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (1st)", + /*194*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 2, -1, { 0, 0, "" }, "DE\\^1\\^1XY", -1, 0, 19, 19, 1, 3, "", + "0011011011000000101" + "1001000001100111010" + "1000110010011111110" + "0110100010110110100" + "1011110100100010001" + "0010111111111110111" + "0001010000000101100" + "0011110111110101110" + "0111010100010111011" + "0001010101010111001" + "0001010100010101110" + "0100010111110101001" + "0001010000000101100" + "0011011111111111000" + "0111000001011000111" + "0001110110100100111" + "0001000101001100100" + "1001010011101100011" + "0001011111101011110" + }, + /*195*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 2, -1, { 0, 0, "" }, "DE\\^1\\^1XY", -1, 0, 19, 19, 1, 3, "", + "0011011011000000101" + "1001000001100111010" + "1000110010011111110" + "0110100010110110100" + "1011110100100010001" + "0010111111111110111" + "0001010000000101100" + "0011110111110101110" + "0111010100010111011" + "0001010101010111001" + "0001010100010101110" + "0100010111110101001" + "0001010000000101100" + "0011011111111111000" + "0111000001011000111" + "0001110110100100111" + "0001000101001100100" + "1001010011101100011" + "0001011111101011110" + }, + /*196*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "\\^1\\^^\\^1", -1, 0, 15, 15, 0, 3, "BWIPP: different encodation, same no. of codewords (does ML after FNC1 in 1st position)", + "000001101000001" + "001101110001001" + "001100000110101" + "011111111111101" + "001100000001100" + "001101111101010" + "011101000101111" + "000101010101010" + "010101000101001" + "111101111101110" + "011100000001111" + "100111111111110" + "100011000110010" + "110110001011011" + "101110000011010" + }, + /*197*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "\\^1\\^^\\^1", -1, 0, 15, 15, 0, 3, "BWIPP: see above", + "000111010010000" + "000001010100001" + "001100000110110" + "011111111111100" + "001100000001111" + "001101111101010" + "011101000101110" + "000101010101000" + "010101000101011" + "111101111101111" + "011100000001111" + "100111111111101" + "100011000110010" + "110001001011101" + "101000000001010" + }, + /*198*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "\\^11234\\^1", -1, 0, 15, 15, 1, 3, "", + "001000011111101" + "111011011010111" + "111100001000111" + "001111111111110" + "000100000001001" + "000101111101010" + "010101000101111" + "001101010101101" + "001101000101101" + "011101111101011" + "000100000001101" + "010111111111100" + "100001010010011" + "000010001001111" + "101110000000011" + }, + /*199*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "\\^11234\\^1", -1, 0, 15, 15, 1, 3, "", + "001000011111101" + "111011011010111" + "111100001000111" + "001111111111110" + "000100000001001" + "000101111101010" + "010101000101111" + "001101010101101" + "001101000101101" + "011101111101011" + "000100000001101" + "010111111111100" + "100001010010011" + "000010001001111" + "101110000000011" + }, + /*200*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "A\\^1\\^^\\^1", -1, 0, 15, 15, 0, 3, "BWIPP: different encodation, same no. of codewords (does ML before FNC1 in 2nd position)", + "001110100001001" + "001000110000000" + "011100001000100" + "001111111111100" + "000100000001001" + "000101111101011" + "010101000101100" + "001101010101111" + "001101000101101" + "011101111101010" + "000100000001110" + "110111111111110" + "100001010010010" + "111011100001111" + "100110110000011" + }, + /*201*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "A\\^1\\^^\\^1", -1, 0, 15, 15, 0, 3, "BWIPP: see above", + "000000011101000" + "001101101100100" + "011100001000100" + "001111111111110" + "000100000001011" + "000101111101001" + "010101000101110" + "001101010101110" + "001101000101110" + "011101111101001" + "000100000001110" + "110111111111111" + "100001010010010" + "111010001001011" + "100110000000011" + }, + /*202*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "A\\^112\\^134", -1, 0, 15, 15, 1, 3, "", + "001011000011101" + "000001000001011" + "011100001000111" + "011111111111111" + "111100000001101" + "100101111101110" + "000101000101101" + "001101010101001" + "001101000101010" + "010101111101000" + "000100000001011" + "000111111111111" + "010001100010010" + "011001001001011" + "010000000000101" + }, + /*203*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "A\\^112\\^134", -1, 0, 15, 15, 1, 3, "", + "001011000011101" + "000001000001011" + "011100001000111" + "011111111111111" + "111100000001101" + "100101111101110" + "000101000101101" + "001101010101001" + "001101000101010" + "010101111101000" + "000100000001011" + "000111111111111" + "010001100010010" + "011001001001011" + "010000000000101" + }, + /*204*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "12\\^112", -1, 0, 15, 15, 1, 3, "", + "001011011111110" + "110010001011001" + "111100000100101" + "001111111111111" + "011100000001101" + "100101111101010" + "101101000101000" + "000101010101000" + "000101000101110" + "011101111101011" + "000100000001100" + "000111111111110" + "010011011110001" + "001110101010101" + "000100101111000" + }, + /*205*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "12\\^112", -1, 0, 15, 15, 1, 3, "", + "001011011111110" + "110010001011001" + "111100000100101" + "001111111111111" + "011100000001101" + "100101111101010" + "101101000101000" + "000101010101000" + "000101000101110" + "011101111101011" + "000100000001100" + "000111111111110" + "010011011110001" + "001110101010101" + "000100101111000" + }, + /*206*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "1\\^112", -1, 0, 15, 15, 1, 3, "", + "000100100101100" + "111010110101101" + "111100000100100" + "001111111111110" + "011100000001101" + "100101111101000" + "001101000101011" + "000101010101000" + "000101000101110" + "011101111101011" + "000100000001110" + "000111111111111" + "010011011110010" + "100111001101111" + "011011101011110" + }, + /*207*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "1\\^112", -1, 0, 15, 15, 1, 3, "", + "000100100101100" + "111010110101101" + "111100000100100" + "001111111111110" + "011100000001101" + "100101111101000" + "001101000101011" + "000101010101000" + "000101000101110" + "011101111101011" + "000100000001110" + "000111111111111" + "010011011110010" + "100111001101111" + "011011101011110" + }, + /*208*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 6, -1, { 0, 0, "" }, "?\\^1123456ABC\\^1\\^^DEXY\\^11234\\^^\\^1", -1, 0, 23, 23, 0, 3, "BWIPP: different encodation, same no. of codewords", + "11111011000000000011111" + "11100000101100100011001" + "00010100111001011100000" + "00110011111110011101011" + "01011100001000000010001" + "10111111111111111111110" + "10010100000000000111101" + "00100101111111110101001" + "00100101000000010100100" + "00111101011111010101010" + "00010101010001010101111" + "01010101010101010101010" + "01100101010001010101110" + "00111101011111010111011" + "00110101000000010111001" + "01000101111111110111110" + "11001100000000000101110" + "01000111111111111111111" + "00010011101000110001001" + "01011111010101110011011" + "01011101001000111001000" + "10110010010101000001010" + "01011011000001010000000" + }, + /*209*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 6, -1, { 0, 0, "" }, "?\\^1123456ABC\\^1\\^^DEXY\\^11234\\^^\\^1", -1, 0, 23, 23, 0, 3, "BWIPP: different encodation, 1 less codeword", + "00000101100000000011101" + "00101100111100100000101" + "01011010100011111010001" + "11010100011110110001010" + "01101100001000000010001" + "00111111111111111110001" + "00100100000000000110100" + "00110101111111110100110" + "01101101000000010101111" + "00110101011111010100010" + "00010101010001010100011" + "01010101010101010101010" + "01011101010001010111001" + "00101101011111010110010" + "11111101000000010100110" + "11000101111111110101111" + "00001100000000000110001" + "01000111111111111110111" + "10010000011001111001010" + "10001011000111110101000" + "00000011010011110110000" + "00101101100100101001010" + "11101100100010010000000" + }, + /*210*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 3, -1, -1, 6, -1, { 0, 0, "" }, "\\^1\241\\^1\\^1\241\241\\^1\241\\^1", -1, 0, 23, 23, 1, 3, "", + "00000000010000100111000" + "00101000000101100011100" + "01110111101010010110110" + "00011111100101110000000" + "00111100001000000010000" + "01111111111111111110100" + "00111100000000000101101" + "00001101111111110110000" + "01011101000000010110100" + "00011101011111010100110" + "00000101010001010110111" + "01010101010101010101010" + "01001101010001010100000" + "00101101011111010111000" + "00011101000000010111010" + "01100101111111110110010" + "10010100000000000111110" + "10100111111111111110100" + "11000010111001101001101" + "11101001011101001010111" + "11100011111010000000011" + "00110000010101001001010" + "00100010000000000000000" + }, + /*211*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, 6, -1, { 0, 0, "" }, "\\^1\241\\^1\\^1\241\241\\^1\241\\^1", -1, 0, 23, 23, 1, 3, "", + "00000000010000100111000" + "00101000000101100011100" + "01110111101010010110110" + "00011111100101110000000" + "00111100001000000010000" + "01111111111111111110100" + "00111100000000000101101" + "00001101111111110110000" + "01011101000000010110100" + "00011101011111010100110" + "00000101010001010110111" + "01010101010101010101010" + "01001101010001010100000" + "00101101011111010111000" + "00011101000000010111010" + "01100101111111110110010" + "10010100000000000111110" + "10100111111111111110100" + "11000010111001101001101" + "11101001011101001010111" + "11100011111010000000011" + "00110000010101001001010" + "00100010000000000000000" + }, + /*212*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 4, -1, -1, 6, -1, { 0, 0, "" }, "A\\^1123456\\^1\\^^\241\\^1", -1, 0, 23, 23, 0, 4, "BWIPP: different encodation (final PS instead of PL) - see below", + "00100010011010011100001" + "01000010101111101100000" + "01111010101010000110011" + "11000011110100100011111" + "10001100001000000010000" + "00011111111111111110000" + "00011100000000000101010" + "00111101111111110110011" + "01101101000000010101100" + "00110101011111010110000" + "00000101010001010101111" + "01010101010101010101010" + "01101101010001010111111" + "00010101011111010100110" + "00010101000000010110111" + "01110101111111110101101" + "00000100000000000101010" + "00100111111111111110110" + "01010011101001010000111" + "01010001111100110111001" + "01111101000011111000111" + "00110111011100001001001" + "10100000101010000000011" + }, + /*213*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, 6, -1, { 0, 0, "" }, "A\\^1123456\\^1\\^^\241\\^1", -1, 0, 23, 23, 1, 4, "", + "00000110100010001000000" + "01000001001100010100100" + "01101111010000001101000" + "11010110101101110001101" + "10111100001000000010000" + "00111111111111111110000" + "00011100000000000101110" + "00001101111111110110011" + "01011101000000010100000" + "00100101011111010111100" + "00110101010001010100111" + "01010101010101010101010" + "01101101010001010110011" + "00010101011111010101010" + "00000101000000010111111" + "01000101111111110100001" + "00010100000000000101110" + "00010111111111111110110" + "01010011101001010000011" + "01011000000100101001001" + "01011001111001100011111" + "00110111011100001001001" + "10100000101010000000011" + }, + /*214*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 5, -1, -1, 2, -1, { 0, 0, "" }, "12\\^1ABCD\\^1\\^^\\^1\241\\^1", -1, 0, 19, 19, 0, 5, "BWIPP: different encodation", + "1111000100110000000" + "1111001100111100100" + "0010101111110110000" + "0100010011001111001" + "1000110101100011010" + "1001111111111110111" + "0000110000000101101" + "0000010111110110101" + "0111010100010100110" + "0000110101010110111" + "0010010100010110010" + "0101010111110111010" + "0001110000000111000" + "0011011111111110000" + "0111000100111001010" + "0000100111100000100" + "0010110111010101100" + "1000110001001000100" + "0001111100001010010" + }, + /*215*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 5, -1, -1, 2, -1, { 0, 0, "" }, "12\\^1ABCD\\^1\\^^\\^1\241\\^1", -1, 0, 19, 19, 0, 5, "BWIPP: different encodation", + "1101000100110000000" + "1100001100111100100" + "0000001000010100000" + "0100101010011001001" + "1000110101100010110" + "1001111111111111111" + "0000110000000100001" + "0001010111110111101" + "0111010100010100010" + "0011110101010111111" + "0000010100010111010" + "0100010111110111110" + "0001110000000110100" + "0011011111111111000" + "0110000100111000010" + "0011000100011111100" + "0001001111110100100" + "1000110001001000100" + "0001111100001010010" + }, + /*216*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "" }, "\\^112\\^134", -1, 0, 19, 19, 1, 3, "", + "1101101101001111011" + "1001010000110010001" + "1110001110010110101" + "1111111000110111011" + "0100110100111011110" + "0000111111111110000" + "0101010000000100000" + "0011010111110111000" + "0011110100010100111" + "1100010101010100110" + "1100010100010110011" + "1010010111110111101" + "1011110000000101001" + "0010011111111111100" + "0000001110000000110" + "0010001101110100000" + "0010011011000110000" + "1001001000001000010" + "0000000001110110000" + }, + /*217*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "" }, "\\^112\\^134", -1, 0, 19, 19, 1, 3, "", + "1101101101001111011" + "1001010000110010001" + "1110001110010110101" + "1111111000110111011" + "0100110100111011110" + "0000111111111110000" + "0101010000000100000" + "0011010111110111000" + "0011110100010100111" + "1100010101010100110" + "1100010100010110011" + "1010010111110111101" + "1011110000000101001" + "0010011111111111100" + "0000001110000000110" + "0010001101110100000" + "0010011011000110000" + "1001001000001000010" + "0000000001110110000" + }, + /*218*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "" }, "A\\^112\\^134", -1, 0, 19, 19, 1, 3, "", + "1100111111000011101" + "1010110010100001110" + "1101110111111000111" + "1101111000110100000" + "0100110100111010000" + "0011111111111111111" + "0110110000000111011" + "0000010111110101001" + "0010110100010100110" + "1100010101010110110" + "0010010100010101010" + "0100110111110110110" + "0110110000000110100" + "1110011111111110000" + "1011001101000001110" + "0001110010010100000" + "0011010111111101100" + "1001001001011101100" + "0000000000000001000" + }, + /*219*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "" }, "A\\^112\\^134", -1, 0, 19, 19, 1, 3, "", + "1100111111000011101" + "1010110010100001110" + "1101110111111000111" + "1101111000110100000" + "0100110100111010000" + "0011111111111111111" + "0110110000000111011" + "0000010111110101001" + "0010110100010100110" + "1100010101010110110" + "0010010100010101010" + "0100110111110110110" + "0110110000000110100" + "1110011111111110000" + "1011001101000001110" + "0001110010010100000" + "0011010111111101100" + "1001001001011101100" + "0000000000000001000" + }, + /*220*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "\\^1", -1, 0, 15, 15, 1, 3, "", + "000110111000001" + "000110001100100" + "001100000010110" + "011111111111111" + "000100000001010" + "001101111101000" + "010101000101100" + "000101010101001" + "010101000101110" + "110101111101111" + "111100000001001" + "110111111111110" + "000000011000000" + "001010011100100" + "100111010100000" + }, + /*221*/ { BARCODE_AZTEC, FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, 1, -1, { 0, 0, "" }, "\\^1", -1, 0, 15, 15, 1, 3, "", + "000110111000001" + "000110001100100" + "001100000010110" + "011111111111111" + "000100000001010" + "001101111101000" + "010101000101100" + "000101010101001" + "010101000101110" + "110101111101111" + "111100000001001" + "110111111111110" + "000000011000000" + "001010011100100" + "100111010100000" + }, + /*222*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 2, -1, { 0, 0, "" }, "A\\^1[", -1, 0, 19, 19, 1, 3, "", + "0010011011101010000" + "0100000111101011001" + "0001011011100010010" + "0001110010100001001" + "0001110100010010100" + "0110111111111110011" + "0000110000000111000" + "0011110111110100010" + "0110110100010101101" + "0001110101010101001" + "0000110100010101001" + "0111010111110100011" + "0001010000000101010" + "1100011111111111000" + "0100001001101000001" + "1100001101011100001" + "1111001101101000101" + "0010011010011101111" + "1001101101110011101" + }, + /*223*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 0, -1, -1, 2, -1, { 0, 0, "" }, "A\\^1[!", -1, 0, 19, 19, 1, 3, "", + "0001010011111110000" + "0100000111110011001" + "0101011011110001101" + "1101100011001010110" + "0101110100010011001" + "1101111111111111011" + "1100110000000111100" + "0001110111110100100" + "0010110100010100101" + "0010110101010100110" + "0000110100010100110" + "0100010111110101111" + "1110010000000100000" + "0111011111111110011" + "1000001001101001001" + "0111101000001010101" + "1001011010110010010" + "1111000000010101001" + "1010111101111100001" + }, + /*224*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 3, -1, -1, 2, -1, { 0, 0, "" }, "A\\^1[", -1, 0, 19, 19, 1, 3, "", + "0000101101110101100" + "0101011010010110111" + "0111100110100101101" + "1110001110111010100" + "0111110100011011000" + "1101111111111111001" + "1101010000000100111" + "0010010111110110001" + "0011110100010110000" + "0010110101010110100" + "0001110100010100111" + "0111110111110110101" + "0011110000000111001" + "0000011111111111100" + "0111001011001001001" + "0000111011100101001" + "1010100100010111001" + "0101011110011001111" + "1111001110010011000" + }, + /*225*/ { BARCODE_AZTEC, EXTRA_ESCAPE_MODE, 3, -1, -1, 2, -1, { 0, 0, "" }, "12\\^1[", -1, 0, 19, 19, 0, 3, "BWIPP: different encodation, same no. of codewords (uses PS instead of PL)", + "1100100011110010111" + "1111001011101100001" + "0000101010011001010" + "0100000100000001010" + "1010110100100010010" + "1000111111111111111" + "0100010000000101101" + "1100110111110100100" + "0100010100010110000" + "1100010101010110000" + "0101010100010101011" + "1101010111110101110" + "1100010000000100011" + "0010011111111111111" + "0010000001011001010" + "0001010000010000111" + "0011001111101001010" + "1001000101001010011" + "0000011111100011011" + }, + /*226*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "0", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (1st)", "11101010101" "11111111111" "01000000010" @@ -6628,7 +7369,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00101010100" }, - /*191*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "25", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (2nd)", + /*227*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "25", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (2nd)", "11101100101" "11111111111" "01000000011" @@ -6641,7 +7382,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00100100000" }, - /*192*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "125", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (3rd)", + /*228*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "125", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (3rd)", "11110101101" "11111111111" "11000000011" @@ -6654,7 +7395,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00111101000" }, - /*193*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "255", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (4th)", + /*229*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "255", -1, 0, 11, 11, 1, 1, "ISO/IEC 24778:2008 Figure A.1 (4th)", "11010101001" "11111111111" "01000000011" @@ -6667,7 +7408,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00110011100" }, - /*194*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "1", -1, 0, 11, 11, 1, 1, "", + /*230*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "1", -1, 0, 11, 11, 1, 1, "", "11101010101" "11111111111" "11000000011" @@ -6680,7 +7421,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00100110100" }, - /*195*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "15", -1, 0, 11, 11, 1, 1, "", + /*231*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "15", -1, 0, 11, 11, 1, 1, "", "11101001001" "11111111111" "11000000011" @@ -6693,7 +7434,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00001111100" }, - /*196*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "16", -1, 0, 11, 11, 1, 1, "", + /*232*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "16", -1, 0, 11, 11, 1, 1, "", "11101110101" "11111111111" "11000000010" @@ -6706,7 +7447,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00111100100" }, - /*197*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "63", -1, 0, 11, 11, 1, 1, "", + /*233*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "63", -1, 0, 11, 11, 1, 1, "", "11100101001" "11111111111" "11000000011" @@ -6719,7 +7460,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00101010000" }, - /*198*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "64", -1, 0, 11, 11, 1, 1, "", + /*234*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "64", -1, 0, 11, 11, 1, 1, "", "11111010101" "11111111111" "01000000010" @@ -6732,7 +7473,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00111011100" }, - /*199*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "65", -1, 0, 11, 11, 1, 1, "", + /*235*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "65", -1, 0, 11, 11, 1, 1, "", "11111010101" "11111111111" "11000000011" @@ -6745,7 +7486,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00110111100" }, - /*200*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "126", -1, 0, 11, 11, 1, 1, "", + /*236*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "126", -1, 0, 11, 11, 1, 1, "", "11110101001" "11111111111" "01000000010" @@ -6758,7 +7499,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00110111000" }, - /*201*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "127", -1, 0, 11, 11, 1, 1, "", + /*237*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "127", -1, 0, 11, 11, 1, 1, "", "11110101001" "11111111111" "11000000011" @@ -6771,7 +7512,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00111011000" }, - /*202*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "128", -1, 0, 11, 11, 1, 1, "", + /*238*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "128", -1, 0, 11, 11, 1, 1, "", "11001010101" "11111111111" "11000000010" @@ -6784,7 +7525,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00100010000" }, - /*203*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "191", -1, 0, 11, 11, 1, 1, "", + /*239*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "191", -1, 0, 11, 11, 1, 1, "", "11000101001" "11111111111" "01000000011" @@ -6797,7 +7538,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00100010100" }, - /*204*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "192", -1, 0, 11, 11, 1, 1, "", + /*240*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "192", -1, 0, 11, 11, 1, 1, "", "11011010101" "11111111111" "11000000010" @@ -6810,7 +7551,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00110011000" }, - /*205*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "225", -1, 0, 11, 11, 1, 1, "", + /*241*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "225", -1, 0, 11, 11, 1, 1, "", "11010010101" "11111111111" "11000000011" @@ -6823,7 +7564,7 @@ static void test_encode(const testCtx *const p_ctx) { "01111111111" "00001100100" }, - /*206*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "254", -1, 0, 11, 11, 1, 1, "", + /*242*/ { BARCODE_AZRUNE, UNICODE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "254", -1, 0, 11, 11, 1, 1, "", "11010101001" "11111111111" "11000000010" @@ -6845,7 +7586,7 @@ static void test_encode(const testCtx *const p_ctx) { char cmp_buf[32768] ZINT_TESTUTIL_SANITIZEM_INIT; char cmp_msg[1024]; - /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */ + /* Only do BWIPP/zxing-cpp tests if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); @@ -6902,7 +7643,7 @@ static void test_encode(const testCtx *const p_ctx) { } } else { ret = testUtilBwipp(i, symbol, data[i].option_1, data[i].option_2, -1, data[i].data, length, - NULL, cmp_buf, sizeof(cmp_buf), NULL); + NULL /*primary*/, cmp_buf, sizeof(cmp_buf), NULL /*p_parsefnc*/); assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); @@ -7454,7 +8195,65 @@ static void test_encode_segs(const testCtx *const p_ctx) { "11000010101111001011001" "00000000010011100110111" }, - /* 20*/ { GS1_MODE, -1, -1, -1, -1, { { TU("[20]01"), -1, 0 }, { TU(""), 0, 0 }, { TU(""), 0, 0 } }, 0, 15, 15, 1, "GS1 with single seg ok", + /* 20*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, ZINT_AZTEC_FULL, { { TU("12\\^1Жф"), -1, 7 }, { TU("\\^1ÓṠé"), -1, 16 }, { TU("12\\^1大ÓфṠéЖ"), -1, 26 } }, 0, 27, 27, 0, "BWIPP: different encodation, same no. of codewords", + "110000000001001100010000000" + "111000100011010110100101000" + "001101111111000000010110001" + "011011010100110000000101100" + "101111010000100110010000110" + "101100010010010110011000011" + "001011110001000000001010011" + "001100111111111111111101010" + "001010110000000000011011111" + "001111010111111111010001010" + "001001110100000001010000111" + "010101110101111101011010110" + "000111110101000101011110101" + "010101010101010101010101010" + "001001010101000101011101101" + "001011010101111101011010011" + "010110010100000001011010010" + "000000010111111111011001100" + "001011010000000000010110011" + "001010011111111111111110011" + "110100001001000000000110110" + "001100111110010110111010100" + "111101001100101001000101000" + "110010101110110010100100110" + "010011001100001000110011100" + "110111011100010010010110000" + "110000110101000000000010000" + }, + /* 21*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, ZINT_AZTEC_FULL, { { TU("12\\^1Жф"), -1, 7 }, { TU("\\^1ÓṠé"), -1, 16 }, { TU("12\\^1大ÓфṠéЖ"), -1, 26 } }, 0, 27, 27, 0, "Same as above; BWIPP: as above", + "110000000001001100010000000" + "111000100011010110100101000" + "001101111111000000010110001" + "011011010100110000000101100" + "101111010000100110010000110" + "101100010010010110011000011" + "001011110001000000001010011" + "001100111111111111111101010" + "001010110000000000011011111" + "001111010111111111010001010" + "001001110100000001010000111" + "010101110101111101011010110" + "000111110101000101011110101" + "010101010101010101010101010" + "001001010101000101011101101" + "001011010101111101011010011" + "010110010100000001011010010" + "000000010111111111011001100" + "001011010000000000010110011" + "001010011111111111111110011" + "110100001001000000000110110" + "001100111110010110111010100" + "111101001100101001000101000" + "110010101110110010100100110" + "010011001100001000110011100" + "110111011100010010010110000" + "110000110101000000000010000" + }, + /* 22*/ { GS1_MODE, -1, -1, -1, -1, { { TU("[20]01"), -1, 0 }, { TU(""), 0, 0 }, { TU(""), 0, 0 } }, 0, 15, 15, 1, "GS1 with single seg ok", "000111011110100" "111001101011110" "111100000100100" @@ -7471,7 +8270,7 @@ static void test_encode_segs(const testCtx *const p_ctx) { "101011011010111" "000001100110010" }, - /* 21*/ { GS1_MODE | FAST_MODE, -1, -1, -1, -1, { { TU("[20]01"), -1, 0 }, { TU(""), 0, 0 }, { TU(""), 0, 0 } }, 0, 15, 15, 1, "Same as above", + /* 23*/ { GS1_MODE | FAST_MODE, -1, -1, -1, -1, { { TU("[20]01"), -1, 0 }, { TU(""), 0, 0 }, { TU(""), 0, 0 } }, 0, 15, 15, 1, "Same as above", "000111011110100" "111001101011110" "111100000100100" @@ -7497,7 +8296,7 @@ static void test_encode_segs(const testCtx *const p_ctx) { char cmp_buf[32768]; char cmp_msg[1024]; - /* Only do BWIPP/ZXing-C++ tests if asked, too slow otherwise */ + /* Only do BWIPP/zxing-cpp tests if asked, too slow otherwise */ int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); @@ -7576,7 +8375,7 @@ static void test_encode_segs(const testCtx *const p_ctx) { if ((data[i].input_mode & 0x7) == DATA_MODE) { if (debug & ZINT_DEBUG_TEST_PRINT) { printf("i:%d %s multiple segments in DATA_MODE not currently supported for" - " ZXing-C++ testing\n", + " zxing-cpp testing\n", i, testUtilBarcodeName(symbol->symbology)); } } else { @@ -7607,7 +8406,7 @@ static void test_encode_segs(const testCtx *const p_ctx) { testFinish(); } -static void test_rt(const testCtx *const p_ctx) { +static void test_ct(const testCtx *const p_ctx) { int debug = p_ctx->debug; struct item { @@ -7635,13 +8434,19 @@ static void test_rt(const testCtx *const p_ctx) { /* 7*/ { BARCODE_AZTEC, UNICODE_MODE, 26, BARCODE_CONTENT_SEGS, "é", -1, 0, 26, "é", -1, 26 }, /* 8*/ { BARCODE_AZTEC, UNICODE_MODE, 899, -1, "é", -1, 0, 899, "", -1, 0 }, /* 9*/ { BARCODE_AZTEC, UNICODE_MODE, 899, BARCODE_CONTENT_SEGS, "é", -1, 0, 899, "é", -1, 899 }, - /* 10*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 0, "", -1, 0 }, - /* 11*/ { BARCODE_AZTEC, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 0, "01049123451234591597033130128\03510(BC123", -1, 3 }, - /* 12*/ { BARCODE_AZTEC, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, BARCODE_CONTENT_SEGS, "(01)04912345123459(15)970331(30)128(10)\\(BC123", -1, 0, 0, "01049123451234591597033130128\03510(BC123", -1, 3 }, - /* 13*/ { BARCODE_AZTEC, GS1_MODE, 26, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 26, "01049123451234591597033130128\03510(BC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */ - /* 14*/ { BARCODE_AZTEC, GS1_MODE, 24, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 24, "01049123451234591597033130128\03510(BC123", -1, 3 }, - /* 15*/ { BARCODE_HIBC_AZTEC, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 }, - /* 16*/ { BARCODE_HIBC_AZTEC, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 }, + /* 10*/ { BARCODE_AZTEC, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, "\\^1é", -1, 0, 0, "", -1, 3 }, + /* 11*/ { BARCODE_AZTEC, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 0, "é", -1, 3 }, + /* 12*/ { BARCODE_AZTEC, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, "12\\^1ABC", -1, 0, 0, "", -1, 3 }, + /* 13*/ { BARCODE_AZTEC, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "12\\^1ABC", -1, 0, 0, "12ABC", -1, 3 }, + /* 14*/ { BARCODE_AZTEC, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "\\^1é", -1, 0, 26, "", -1, 26 }, + /* 15*/ { BARCODE_AZTEC, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 26, "é", -1, 26 }, + /* 16*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 0, "", -1, 0 }, + /* 17*/ { BARCODE_AZTEC, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 0, "01049123451234591597033130128\03510(BC123", -1, 3 }, + /* 18*/ { BARCODE_AZTEC, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, BARCODE_CONTENT_SEGS, "(01)04912345123459(15)970331(30)128(10)\\(BC123", -1, 0, 0, "01049123451234591597033130128\03510(BC123", -1, 3 }, + /* 19*/ { BARCODE_AZTEC, GS1_MODE, 26, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 26, "01049123451234591597033130128\03510(BC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */ + /* 20*/ { BARCODE_AZTEC, GS1_MODE, 24, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10](BC123", -1, 0, 24, "01049123451234591597033130128\03510(BC123", -1, 3 }, + /* 21*/ { BARCODE_HIBC_AZTEC, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 }, + /* 22*/ { BARCODE_HIBC_AZTEC, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -7699,7 +8504,7 @@ static void test_rt(const testCtx *const p_ctx) { testFinish(); } -static void test_rt_segs(const testCtx *const p_ctx) { +static void test_ct_segs(const testCtx *const p_ctx) { int debug = p_ctx->debug; struct item { @@ -8421,7 +9226,7 @@ static void test_fuzz(const testCtx *const p_ctx) { "\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\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", 996, 0, "", 1 - }, /* Padding 11 example causing issue with ZXing-C++ */ + }, /* Padding 11 example causing issue with zxing-cpp */ /* 12*/ { BARCODE_AZTEC, DATA_MODE, -1, -1, "\133\060\060\060\135\060\125\125\125\125\140\060\125\125\125\125\060\060\060\271\060\060\125\103\164\125\125\125\377\377\125\125\125\125\125\125\125\133\060\076" "\060\135\261\177\261\261\261\236\261\261\261\040\261\261\261\261\261\261\261\020\261\261\261\261\261\261\265\261\261\261\261\261\261\261\261\261\261\261\261\040" @@ -8582,7 +9387,7 @@ static void test_fuzz(const testCtx *const p_ctx) { char cmp_buf[32768]; char cmp_msg[8192]; - /* Only do ZXing-C++ test if asked, too slow otherwise */ + /* Only do zxing-cpp test if asked, too slow otherwise */ int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); testStartSymbol(p_ctx->func_name, &symbol); @@ -8642,8 +9447,8 @@ int main(int argc, char *argv[]) { { "test_options", test_options }, { "test_encode", test_encode }, { "test_encode_segs", test_encode_segs }, - { "test_rt", test_rt }, - { "test_rt_segs", test_rt_segs }, + { "test_ct", test_ct }, + { "test_ct_segs", test_ct_segs }, { "test_fuzz", test_fuzz }, }; diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index ad6e5786..e5d5d049 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -173,7 +173,7 @@ static void test_chr_cnt(const testCtx *const p_ctx) { static const struct item data[] = { /* 0*/ { "", -1, 'a', 0 }, /* 1*/ { "BDAaED", -1, 'a', 1 }, - /* 1*/ { "aBDAaaaEaDa", -1, 'a', 6 }, + /* 2*/ { "aBDAaaaEaDa", -1, 'a', 6 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -193,6 +193,44 @@ static void test_chr_cnt(const testCtx *const p_ctx) { testFinish(); } +static void test_zero_fill(const testCtx *const p_ctx) { + + struct item { + const char *data; + int length; + int dest_length; + int ret; + const char *expected; + }; + /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ + static const struct item data[] = { + /* 0*/ { "", -1, 0, 0, "" }, + /* 1*/ { "1", -1, 10, 9, "0000000001" }, + /* 2*/ { "123456789", -1, 10, 1, "0123456789" }, + /* 3*/ { "1234567890", -1, 10, 0, "1234567890" }, + /* 4*/ { "12345678901", -1, 10, -1, "12345678901" }, + }; + const int data_size = ARRAY_SIZE(data); + int i, length, ret; + + testStart(p_ctx->func_name); + + for (i = 0; i < data_size; i++) { + unsigned char dest[200]; + + if (testContinue(p_ctx, i)) continue; + + length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; + + ret = z_zero_fill(ZCUCP(data[i].data), length, dest, data[i].dest_length); + assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); + assert_zero(strcmp(ZCCP(dest), data[i].expected), "i:%d dest (%s) != expected (%s)\n", + i, dest, data[i].expected); + } + + testFinish(); +} + static void test_is_chr(const testCtx *const p_ctx) { struct item { @@ -773,20 +811,21 @@ static void test_extra_escapes(const testCtx *const p_ctx) { int ret; const char *expected; const char expected_fncs[32]; + int expected_extra_escapes; const char *comment; }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { 0, "", -1, 0, "", {0}, "" }, - /* 1*/ { 3, "ABC", -1, 0, "ABC", {0}, "" }, - /* 2*/ { 4, "\\^1ABC", -1, 0, "\035ABC", {1}, "" }, - /* 3*/ { 26, "\\^1\\^1A\\^1BC\\^1", -1, 0, "\035\035A\035BC\035", {1,1,0,1,0,0,1}, "" }, - /* 4*/ { 27, "\\^^\\^1A\\^1BC\\^^1", -1, 0, "\\^\035A\035BC\\^1", {0,0,1,0,1}, "" }, - /* 5*/ { 20, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" }, - /* 6*/ { 25, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" }, - /* 7*/ { 28, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" }, - /* 8*/ { 29, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" }, - /* 9*/ { 899, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" }, + /* 0*/ { 0, "", -1, 0, "", {0}, 0, "" }, + /* 1*/ { 3, "ABC", -1, 0, "ABC", {0}, 0, "" }, + /* 2*/ { 4, "\\^1ABC", -1, 0, "\035ABC", {1}, 1, "" }, + /* 3*/ { 26, "\\^1\\^1A\\^1BC\\^1", -1, 0, "\035\035A\035BC\035", {1,1,0,1,0,0,1}, 1, "" }, + /* 4*/ { 27, "\\^^\\^1A\\^1BC\\^^1", -1, 0, "\\^\035A\035BC\\^1", {0,0,1,0,1}, 1, "" }, + /* 5*/ { 20, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" }, + /* 6*/ { 25, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" }, + /* 7*/ { 28, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" }, + /* 8*/ { 29, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" }, + /* 9*/ { 899, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -800,9 +839,9 @@ static void test_extra_escapes(const testCtx *const p_ctx) { symbol->debug = debug; for (i = 0; i < data_size; i++) { - int len = 0; unsigned char dest[32] = {0}; char fncs[32] = {0}; + int have_extra_escapes = 0; if (testContinue(p_ctx, i)) continue; @@ -813,14 +852,17 @@ static void test_extra_escapes(const testCtx *const p_ctx) { assert_nonzero(expected_length < (int) sizeof(dest), "i:%d expected_length %d >= sizeof(dest) %d\n", i, expected_length, (int) sizeof(dest)); - ret = z_extra_escapes(symbol, ZCUCP(data[i].data), length, data[i].eci, dest, fncs, &len); + ret = z_extra_escapes(symbol, ZCUCP(data[i].data), &length, data[i].eci, dest, fncs, &have_extra_escapes); assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret); if (ret < ZINT_ERROR) { - assert_equal(len, expected_length, "i:%d len %d != expected_length %d (%s)\n", - i, len, expected_length, dest); + assert_equal(length, expected_length, "i:%d length %d != expected_length %d (%s)\n", + i, length, expected_length, dest); assert_zero(strcmp(ZCCP(dest), data[i].expected), "i:%d dest (%s) != expected (%s)\n", i, dest, data[i].expected); assert_zero(memcmp(fncs, data[i].expected_fncs, expected_length), "i:%d fncs != expected_fncs\n", i); + assert_equal(have_extra_escapes, data[i].expected_extra_escapes, + "i:%d have_extra_escapes %d != expected %d\n", + i, have_extra_escapes, data[i].expected_extra_escapes); } } @@ -1313,18 +1355,20 @@ static void test_ct_set_seg_extra_escapes_eci(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { 0, 1, 3, { { TU("\\^1A"), 0, 0 } }, { { TU("\035A"), 2, 3 } } }, + /* 0*/ { 0, 1, 3, { { TU("\\^1A"), 0, 0 } }, { { TU("A"), 1, 3 } } }, /* 1*/ { 0, 1, 0, { { TU("\\^1A"), 0, 0 } }, { { TU("A"), 1, 3 } } }, - /* 2*/ { 0, 1, 4, { { TU("A\\^1"), 0, 0 } }, { { TU("A\035"), 2, 4 } } }, + /* 2*/ { 0, 1, 4, { { TU("A\\^1"), 0, 0 } }, { { TU("A"), 1, 4 } } }, /* 3*/ { 0, 1, 0, { { TU("A\\^1"), 0, 0 } }, { { TU("A"), 1, 3 } } }, /* 4*/ { 0, 1, 0, { { TU("a\\^1"), 0, 0 } }, { { TU("a"), 1, 3 } } }, /* 5*/ { 0, 1, 0, { { TU("12\\^1"), 0, 0 } }, { { TU("12"), 2, 3 } } }, - /* 6*/ { 0, 1, 0, { { TU("?\\^1"), 0, 0 } }, { { TU("?\035"), 2, 3 } } }, - /* 7*/ { 0, 1, 0, { { TU("1A\\^1"), 0, 0 } }, { { TU("1A\035"), 3, 3 } } }, - /* 8*/ { 0, 1, 0, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 3 } } }, - /* 9*/ { 0, 1, 5, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\035\\^1A\035"), 6, 5 } } }, - /* 10*/ { 1, 2, 27, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 27 } } }, - /* 11*/ { 1, 2, 0, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 3 } } }, + /* 6*/ { 0, 1, 5, { { TU("12\\^1"), 0, 0 } }, { { TU("12"), 2, 5 } } }, + /* 7*/ { 0, 1, 0, { { TU("?\\^1"), 0, 0 } }, { { TU("?\035"), 2, 3 } } }, + /* 8*/ { 0, 1, 0, { { TU("1A\\^1"), 0, 0 } }, { { TU("1A\035"), 3, 3 } } }, + /* 9*/ { 0, 1, 0, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 3 } } }, + /* 10*/ { 0, 1, 5, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 5 } } }, + /* 11*/ { 1, 2, 27, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 27 } } }, + /* 12*/ { 1, 2, 0, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 3 } } }, + /* 13*/ { 1, 2, 6, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 6 } } }, }; const int data_size = ARRAY_SIZE(data); int i, ret; @@ -1619,6 +1663,7 @@ int main(int argc, char *argv[]) { { "test_to_int", test_to_int }, { "test_to_upper", test_to_upper }, { "test_chr_cnt", test_chr_cnt }, + { "test_zero_fill", test_zero_fill }, { "test_is_chr", test_is_chr }, { "test_not_sane", test_not_sane }, { "test_not_sane_lookup", test_not_sane_lookup }, diff --git a/backend/tests/test_dmatrix.c b/backend/tests/test_dmatrix.c index 5abe4ae4..d1ab65b8 100644 --- a/backend/tests/test_dmatrix.c +++ b/backend/tests/test_dmatrix.c @@ -654,9 +654,9 @@ static void test_options(const testCtx *const p_ctx) { /* 46*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "__________________________________________________", 0, 32, 32, "", 10, 1, "50 data" }, /* 47*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "__________________________________________________", 0, 20, 44, "", 41, 1, "" }, /* 48*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, DM_SQUARE, -1, { 0, 0, "" }, "__________________________________________________", 0, 32, 32, "", 10, 1, "" }, - /* 49*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "51 data; BWIPP different encodation" }, + /* 49*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "51 data; BWIPP different encodation, same no. of codewords (begins in C40, ends single ASCII, zint vice versa)" }, /* 50*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 20, 44, "", 41, 0, "BWIPP DMRE requires dimensions" }, - /* 51*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, 9999, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "Ignored; BWIPP different encodation" }, + /* 51*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, 9999, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "Ignored; BWIPP different encodation, see 2 above" }, /* 52*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "_____________________________________________________________", 0, 32, 32, "", 10, 1, "61 data" }, /* 53*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "______________________________________________________________", 0, 32, 32, "", 10, 1, "62 data" }, /* 54*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "_______________________________________________________________", 0, 36, 36, "", 11, 1, "63 data" }, @@ -699,34 +699,35 @@ static void test_options(const testCtx *const p_ctx) { /* 91*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^^1\\^1", 0, 12, 12, "", 2, 1, "" }, /* 92*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^^\\^", 0, 12, 12, "", 2, 1, "" }, /* 93*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^^\\^2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 717: Unrecognized extra escape \"\\^2\"", 0, 1, "" }, - /* 94*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[90]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 844: Cannot use extra escape mode in GS1 mode", 0, 1, "" }, + /* 94*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[90]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 844: Cannot use Extra Escape mode in GS1 mode", 0, 1, "" }, /* 95*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 9, -1, -1, -1, -1, { 0, 0, "" }, "α\\^1β", 0, 14, 14, "", 3, 1, "ECI ISO/IEC 8859-7 Greek" }, - /* 96*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, -1, -1, -1, -1, { 0, 0, "" }, "あ\\^1ば", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, 1, "ECI Shift JIS" }, - /* 97*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, 1, "ECI 8-bit binary" }, - /* 98*/ { BARCODE_HIBC_DM, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 843: Can only use extra escape mode with non-variant Data Matrix", 0, 1, "" }, - /* 99*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "", 2, 1, "" }, - /*100*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "", 2, 1, "" }, - /*101*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 1, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '1' out of range (2 to 16)", 0, 1, "" }, - /*102*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 17, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '17' out of range (2 to 16)", 0, 1, "" }, - /*103*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '0' out of range (1 to count 16)", 0, 1, "" }, - /*104*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 17, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '17' out of range (1 to count 16)", 0, 1, "" }, - /*105*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "1", 0, 12, 12, "", 2, 1, "" }, - /*106*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "A" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 723: Invalid Structured Append ID (digits only)", 0, 1, "" }, - /*107*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "0" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '000' and ID2 '000' out of range (001 to 254) (ID \"000000\")", 0, 1, "" }, - /*108*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '000' out of range (001 to 254) (ID \"000001\")", 0, 1, "" }, - /*109*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1000" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '000' out of range (001 to 254) (ID \"001000\")", 0, 1, "" }, - /*110*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "001255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '255' out of range (001 to 254) (ID \"001255\")", 0, 1, "" }, - /*111*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '255' out of range (001 to 254) (ID \"255001\")", 0, 1, "" }, - /*112*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '255' and ID2 '255' out of range (001 to 254) (ID \"255255\")", 0, 1, "" }, - /*113*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1234567" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 722: Structured Append ID length 7 too long (6 digit maximum)", 0, 1, "" }, - /*114*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, READER_INIT, { 2, 3, "1001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 727: Cannot have Structured Append and Reader Initialisation at the same time", 0, 1, "" }, - /*115*/ { BARCODE_DATAMATRIX, ESCAPE_MODE, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "[)>\\R05\\GA\\R\\E", 0, 12, 26, "", 27, 1, "Macro05/06 ignored if have Structured Append TODO: error/warning " }, - /*116*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234,67", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 5 in input (alphanumerics, space and \"-.$/+%\" only)", 0, 1, "" }, - /*117*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" }, - /*118*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" }, - /*119*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 18, 18, "", 5, 1, "" }, - /*120*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_B256_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 20, 20, "", 6, 0, "BWIPP: same as above" }, - /*121*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_C40_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" }, + /* 96*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, -1, -1, -1, -1, { 0, 0, "" }, "あ\\^1ば", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, 1, "ECI Shift JIS" }, + /* 97*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, 1, "ECI 8-bit binary" }, + /* 98*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1", 0, 10, 10, "", 1, 1, "" }, + /* 99*/ { BARCODE_HIBC_DM, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 846: Can only use Extra Escape mode with non-variant Data Matrix", 0, 1, "" }, + /*100*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "", 2, 1, "" }, + /*101*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "", 2, 1, "" }, + /*102*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 1, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '1' out of range (2 to 16)", 0, 1, "" }, + /*103*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 17, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '17' out of range (2 to 16)", 0, 1, "" }, + /*104*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '0' out of range (1 to count 16)", 0, 1, "" }, + /*105*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 17, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '17' out of range (1 to count 16)", 0, 1, "" }, + /*106*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "1", 0, 12, 12, "", 2, 1, "" }, + /*107*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "A" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 723: Invalid Structured Append ID (digits only)", 0, 1, "" }, + /*108*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "0" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '000' and ID2 '000' out of range (001 to 254) (ID \"000000\")", 0, 1, "" }, + /*109*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '000' out of range (001 to 254) (ID \"000001\")", 0, 1, "" }, + /*110*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1000" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '000' out of range (001 to 254) (ID \"001000\")", 0, 1, "" }, + /*111*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "001255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '255' out of range (001 to 254) (ID \"001255\")", 0, 1, "" }, + /*112*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '255' out of range (001 to 254) (ID \"255001\")", 0, 1, "" }, + /*113*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '255' and ID2 '255' out of range (001 to 254) (ID \"255255\")", 0, 1, "" }, + /*114*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1234567" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 722: Structured Append ID length 7 too long (6 digit maximum)", 0, 1, "" }, + /*115*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, READER_INIT, { 2, 3, "1001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 727: Cannot have Structured Append and Reader Initialisation at the same time", 0, 1, "" }, + /*116*/ { BARCODE_DATAMATRIX, ESCAPE_MODE, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "[)>\\R05\\GA\\R\\E", 0, 12, 26, "", 27, 1, "Macro05/06 ignored if have Structured Append TODO: error/warning " }, + /*117*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234,67", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 5 in input (alphanumerics, space and \"-.$/+%\" only)", 0, 1, "" }, + /*118*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" }, + /*119*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" }, + /*120*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 18, 18, "", 5, 1, "" }, + /*121*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_B256_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 20, 20, "", 6, 0, "BWIPP: same as above" }, + /*122*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_C40_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -861,6 +862,7 @@ static void test_reader_init(const testCtx *const p_ctx) { static const struct item data[] = { /* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, READER_INIT, "A", 0, 10, 10, "EA 42 81 19 A4 53 21 DF", "" }, /* 1*/ { BARCODE_DATAMATRIX, GS1_MODE, READER_INIT, "[91]A", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 521: Cannot use Reader Initialisation in GS1 mode", "" }, + /* 2*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, READER_INIT, "\\^112", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 847: Cannot use Reader Initialisation in Extra Escape mode", "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -1215,7 +1217,7 @@ static void test_input(const testCtx *const p_ctx) { /*232*/ { UNICODE_MODE, 16382, -1, -1, -1, -1, { 0, 0, "" }, "A", 0, 16382, 12, 12, 1, 1, "F1 BF FE 42 81 29 57 AA A0 92 B2 45", "ECI 16383 A41", 0 }, /*233*/ { UNICODE_MODE | FAST_MODE, 810899, -1, -1, -1, -1, { 0, 0, "" }, "A", 0, 810899, 12, 12, 1, 1, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41", 0 }, /*234*/ { UNICODE_MODE, 810899, -1, -1, -1, -1, { 0, 0, "" }, "A", 0, 810899, 12, 12, 1, 1, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41", 0 }, - /*235*/ { UNICODE_MODE | ESCAPE_MODE | FAST_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, 1, 1, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41", 0 }, + /*235*/ { UNICODE_MODE | FAST_MODE | ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, 1, 1, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41", 0 }, /*236*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, 1, 1, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41", 0 }, /*237*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLM*", 0, 0, 16, 16, 1, 1, "EE 59 E9 6D 24 80 5F 93 9A FE 4E 2B 09 FF 50 A2 83 BE 32 E1 2F 17 1E F3", "C40 == X12, p_r_6_2_1 true", 0 }, /*238*/ { UNICODE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLM*", 0, 0, 16, 16, 0, 1, "42 F0 08 31 05 18 72 09 28 B3 0D 2B 63 64 96 E4 6C CE D3 47 9A 5F E8 70", "AEEEEEEEEEEEEA; BWIPP same as FAST_MODE", 0 }, @@ -1264,15 +1266,32 @@ static void test_input(const testCtx *const p_ctx) { /*281*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A*B>C 1A*B>C 1*\013B>C 1A*B>C 1A*", 0, 0, 22, 22, 1, 1, "(50) EE 57 B8 0F 04 21 72 5E 21 13 8A FE 0C EE 5E 21 13 97 08 9B 64 7E FE 42 2B 81 68 FE", "process_p 0", 1 }, /*282*/ { GS1_MODE, 0, -1, -1, -1, -1, { 1, 2, "" }, "[20]01", 0, 0, 14, 14, 1, 1, "E9 0F 01 01 E8 96 83 81 DE 06 E8 61 E2 B5 19 CE A3 F8", "", 0 }, /*283*/ { GS1_MODE, 3, -1, -1, -1, -1, { 1, 2, "123234" }, "[20]01", 0, 3, 8, 32, 1, 1, "E9 0F 7B EA E8 F1 04 96 83 81 47 4D F5 6F E8 62 DA 1C 06 7F 03", "", 0 }, - /*284*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", 0, 0, 10, 10, 1, 1, "42 E8 43 E5 E2 F8 F5 E5", "", 1 }, - /*285*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "a\\^1B", 0, 0, 10, 10, 1, 1, "62 E8 43 52 07 83 91 CF", "", 1 }, - /*286*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "9\\^1A", 0, 0, 10, 10, 1, 1, "3A E8 42 12 19 12 42 F6", "", 1 }, - /*287*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "99\\^1A", 0, 0, 10, 10, 1, 1, "E5 E8 42 B0 7D B7 7B 6F", "", 1 }, - /*288*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1A", 0, 0, 10, 10, 1, 1, "40 E8 42 E7 07 1A 88 26", "", 1 }, - /*289*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 1, 2, "" }, "A\\^1B", 0, 0, 14, 14, 1, 1, "E9 0F 01 01 42 E8 43 81 F4 7B DC 13 EA 49 14 75 EA 25", "", 1 }, - /*290*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^1\\^1", 0, 0, 10, 10, 1, 1, "E8 E8 E8 88 6E 8B A4 5E", "", 1 }, - /*291*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 1, 1, "E6 59 E9 6D 24 0A 8D 86 C8 96 44 FE 4D 4E E8 81 33 8F 19 0F D7 59 96 B4 D8 43 49 D7 F3 B6", "BWIPP: different encodation", 0 }, - /*292*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 0, 1, "E6 59 E9 6D 24 0A 8D 86 C8 FE 4C E8 4D 4E E8 81 49 98 C6 DD DA A6 89 B1 83 08 56 71 C1 51", "BWIPP: same as FAST_MODE", 0 }, + /*284*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1", 0, 0, 10, 10, 1, 1, "E8 81 46 77 14 C6 DF 66", "", 0 }, + /*285*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1", 0, 0, 10, 10, 1, 1, "E8 81 46 77 14 C6 DF 66", "", 0 }, + /*286*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^112", 0, 0, 10, 10, 1, 1, "E8 8E 81 57 8D 75 FB 06", "", 0 }, + /*287*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1", 0, 0, 10, 10, 1, 1, "42 E8 81 93 B4 12 AB 40", "", 0 }, + /*288*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1", 0, 0, 10, 10, 1, 1, "42 E8 81 93 B4 12 AB 40", "", 0 }, + /*289*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "12\\^1", 0, 0, 10, 10, 1, 1, "8E E8 81 DE FB 11 5D 6E", "", 0 }, + /*290*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", 0, 0, 10, 10, 1, 1, "42 E8 43 E5 E2 F8 F5 E5", "", 0 }, + /*291*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^11234", 0, 0, 12, 12, 1, 1, "42 E8 8E A4 81 89 64 EB FC D4 55 50", "", 0 }, + /*292*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "a\\^1B", 0, 0, 10, 10, 1, 1, "62 E8 43 52 07 83 91 CF", "", 0 }, + /*293*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "9\\^1A", 0, 0, 10, 10, 1, 1, "3A E8 42 12 19 12 42 F6", "", 0 }, + /*294*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "99\\^1A", 0, 0, 10, 10, 1, 1, "E5 E8 42 B0 7D B7 7B 6F", "", 0 }, + /*295*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1A", 0, 0, 10, 10, 1, 1, "40 E8 42 E7 07 1A 88 26", "", 0 }, + /*296*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 1, 2, "" }, "A\\^1B", 0, 0, 14, 14, 1, 1, "E9 0F 01 01 42 E8 43 81 F4 7B DC 13 EA 49 14 75 EA 25", "", 0 }, + /*297*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^1\\^1", 0, 0, 10, 10, 1, 1, "E8 E8 E8 88 6E 8B A4 5E", "", 0 }, + /*298*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 1, 1, "E6 59 E9 6D 24 0A 8D 86 C8 96 44 FE 4D 4E E8 81 33 8F 19 0F D7 59 96 B4 D8 43 49 D7 F3 B6", "", 0 }, + /*299*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 0, 1, "E6 59 E9 6D 24 0A 8D 86 C8 FE 4C E8 4D 4E E8 81 49 98 C6 DD DA A6 89 B1 83 08 56 71 C1 51", "BWIPP: same as FAST_MODE", 0 }, + /*300*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1123456ABC\\^1\\^^DEXY\\^11234\\^^\\^1", 0, 0, 20, 20, 1, 1, "(40) 40 E8 8E A4 BA 42 43 44 E8 5D 5F 45 46 59 5A E8 8E A4 5D 5F E8 81 F9 B4 2C 94 C0 29", "", 0 }, + /*301*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1123456ABC\\^1\\^^DEXY\\^11234\\^^\\^1", 0, 0, 20, 20, 1, 1, "(40) 40 E8 8E A4 BA 42 43 44 E8 5D 5F 45 46 59 5A E8 8E A4 5D 5F E8 81 F9 B4 2C 94 C0 29", "", 0 }, + /*302*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 0, 0, "" }, "\\^1ABCD\\^1", 0, 4, 14, 14, 1, 1, "E8 F1 05 42 43 44 45 E8 B0 05 33 74 B3 6E 79 FB 4F D2", "", 0 }, + /*303*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 0, 0, "" }, "\\^1ABCD\\^1", 0, 4, 14, 14, 0, 1, "E8 F1 05 F0 04 20 C4 E8 C8 58 2A 5C 98 0A 7B C6 2B 65", "BWIPP: same as FAST_MODE", 1 }, + /*304*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 5, -1, -1, -1, -1, { 0, 0, "" }, "A\\^112\\^1Ħ", 0, 5, 14, 14, 1, 1, "42 E8 F1 06 8E E8 EB 22 94 9C C7 17 9E 51 80 CB 86 1A", "", 0 }, + /*305*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 5, -1, -1, -1, -1, { 0, 0, "" }, "A\\^112\\^1Ħ", 0, 5, 14, 14, 1, 1, "42 E8 F1 06 8E E8 EB 22 94 9C C7 17 9E 51 80 CB 86 1A", "", 0 }, + /*306*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "001001" }, "\\^11234\\^1", 0, 3, 8, 32, 1, 1, "E9 0F 01 01 E8 F1 04 8E A4 E8 C1 D2 2C 58 06 98 9E 54 39 C0 48", "", 0 }, + /*307*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "001001" }, "\\^11234\\^1", 0, 3, 8, 32, 1, 1, "E9 0F 01 01 E8 F1 04 8E A4 E8 C1 D2 2C 58 06 98 9E 54 39 C0 48", "", 0 }, + /*308*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 1, 2, "001001" }, "12\\^11234\\^1", 0, 4, 16, 16, 1, 1, "E9 0F 01 01 8E E8 F1 05 8E A4 E8 81 5B 4D 22 4E 82 0A 9C B4 32 CF 84 EB", "", 0 }, + /*309*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 1, 2, "001001" }, "12\\^11234\\^1", 0, 4, 16, 16, 1, 1, "E9 0F 01 01 8E E8 F1 05 8E A4 E8 81 5B 4D 22 4E 82 0A 9C B4 32 CF 84 EB", "", 0 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -6781,20 +6800,28 @@ static void test_ct(const testCtx *const p_ctx) { /* 8*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, -1, "é", -1, 0, 26, "", -1, 0 }, /* 9*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, BARCODE_CONTENT_SEGS, "é", -1, 0, 26, "é", -1, 26 }, /* 10*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, -1, "é", -1, 0, 899, "", -1, 0 }, - /* 11*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, "\\^1é", -1, 0, 0, "", -1, 0 }, - /* 12*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 0, "é", -1, 3 }, - /* 13*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, BARCODE_CONTENT_SEGS, "é", -1, 0, 899, "é", -1, 899 }, - /* 14*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "é\\^1", -1, 0, 26, "", -1, 0 }, - /* 15*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "é\\^1", -1, 0, 26, "é\035", -1, 26 }, - /* 16*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "\\^^é\\^1\\^1\\^", -1, 0, 26, "", -1, 0 }, - /* 17*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "\\^^é\\^1\\^1\\^", -1, 0, 26, "\\^é\035\035\\^", -1, 26 }, - /* 18*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 }, - /* 19*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 }, - /* 20*/ { BARCODE_DATAMATRIX, GS1_MODE, 28, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 28, "01049123451234591597033130128\03510ABC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */ - /* 21*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "https://example.com/01/09506000134369", -1, 0, 0, "", -1, 0 }, - /* 22*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "https://example.com/01/09506000134369", -1, 0, 0, "https://example.com/01/09506000134369", -1, 3 }, - /* 23*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 }, - /* 24*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 }, + /* 11*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, BARCODE_CONTENT_SEGS, "é", -1, 0, 899, "é", -1, 899 }, + /* 12*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, "\\^1é", -1, 0, 0, "", -1, 0 }, + /* 13*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 0, "é", -1, 3 }, + /* 14*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, "\\^1é", -1, 0, 3, "", -1, 3 }, + /* 15*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 3, "é", -1, 3 }, + /* 16*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, "A\\^1é", -1, 0, 3, "", -1, 3 }, + /* 17*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, BARCODE_CONTENT_SEGS, "A\\^1é", -1, 0, 3, "Aé", -1, 3 }, + /* 18*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 9, -1, "12\\^1α", -1, 0, 9, "", -1, 9 }, + /* 19*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 9, BARCODE_CONTENT_SEGS, "12\\^1α", -1, 0, 9, "12α", -1, 9 }, + /* 20*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, "1\\^1é", -1, 0, 3, "", -1, 3 }, + /* 21*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, BARCODE_CONTENT_SEGS, "1\\^1é", -1, 0, 3, "1\035é", -1, 3 }, + /* 22*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "é\\^1", -1, 0, 26, "", -1, 0 }, + /* 23*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "é\\^1", -1, 0, 26, "é\035", -1, 26 }, + /* 24*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "\\^^é\\^1\\^1\\^", -1, 0, 26, "", -1, 0 }, + /* 25*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "\\^^é\\^1\\^1\\^", -1, 0, 26, "\\^é\035\035\\^", -1, 26 }, + /* 26*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 }, + /* 27*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 }, + /* 28*/ { BARCODE_DATAMATRIX, GS1_MODE, 28, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 28, "01049123451234591597033130128\03510ABC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */ + /* 29*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "https://example.com/01/09506000134369", -1, 0, 0, "", -1, 0 }, + /* 30*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "https://example.com/01/09506000134369", -1, 0, 0, "https://example.com/01/09506000134369", -1, 3 }, + /* 31*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 }, + /* 32*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 689607db..8af660f5 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -764,25 +764,35 @@ static void test_escape_char_process(const testCtx *const p_ctx) { /* 77*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 35, "\\U10FFFF", "", 0, 14, "F1 24 EB 80 EB 80 11 01 17 BA C6 05 9F 4C EA E5 18 31", 0, "" }, /* 78*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[20]10", "[10]A", 0, 99, "(7) 105 102 20 10 100 59 106", 0, "" }, /* 79*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" }, - /* 80*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" }, - /* 81*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "" }, - /* 82*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" }, - /* 83*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" }, - /* 84*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" }, - /* 85*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, - /* 86*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "Not allowed of DATAMATRIX in GS1_MODE" }, - /* 87*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "F1 13 42 E8 43 C3 1B 02 5A 6B 37 CC", 0, "" }, - /* 88*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" }, - /* 89*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "バ\\^1ーコ\\^1ード\\^1東京\\^1都", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" }, - /* 90*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 25, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" }, - /* 91*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 33, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" }, - /* 92*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 170, "A\\^1B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 244: Invalid character in input for ECI '170'", 0, "" }, - /* 93*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" }, - /* 94*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" }, - /* 95*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" }, - /* 96*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" }, - /* 97*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" }, - /* 98*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" }, + /* 80*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /* 81*/ { BARCODE_AZTEC, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /* 82*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "" }, + /* 83*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\\\^11", "", 0, 15, "(102) 30 31 31 30 31 31 31 30 31 31 30 30 31 31 31 31 30 31 31 30 31 31 30 30 31 31 31 31", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" }, + /* 84*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "Treated as backslash caret 1 (FNC1)" }, + /* 85*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, + /* 86*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /* 87*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /* 88*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" }, + /* 89*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, + /* 90*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "Not allowed of DATAMATRIX in GS1_MODE" }, + /* 91*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\\\^11", "", 0, 10, "5D 5F 8D 5C FB D1 69 3F", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" }, + /* 92*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "Treated as backslash caret 1 (FNC1)" }, + /* 93*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^B2", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^B\"", 0, "Passed thru as backslash caret B" }, + /* 94*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "42 E8 F1 13 43 F5 A4 26 80 68 7A AD", 0, "" }, + /* 95*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /* 96*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "バ\\^1ーコ\\^1ード\\^1東京\\^1都", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /* 97*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 25, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /* 98*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 33, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /* 99*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 170, "A\\^1B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 244: Invalid character in input for ECI '170'", 0, "" }, + /*100*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, "" }, + /*101*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" }, + /*102*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*103*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" }, + /*104*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" }, + /*105*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" }, + /*106*/ { BARCODE_CODE128, DATA_MODE, -1, "\\\\^A1", "", 0, 79, "(7) 104 60 62 33 17 43 106", 0, "Treated as literal backslash caret A" }, + /*107*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "Treated as backslash caret A (manual Code Set A)" }, + /*108*/ { BARCODE_CODE128, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input", 0, "" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_pdf417.c b/backend/tests/test_pdf417.c index 2721cde1..5c073b70 100644 --- a/backend/tests/test_pdf417.c +++ b/backend/tests/test_pdf417.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2025 Robin Stuart + Copyright (C) 2019-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index aec5ffc3..8cfeb102 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -2385,9 +2385,9 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol { "auspost", BARCODE_AUSPOST, 63, 0, 0, 0, 0, 0, }, { "", -1, 64, 0, 0, 0, 0, 0, }, { "", -1, 65, 0, 0, 0, 0, 0, }, - { "", BARCODE_AUSREPLY, 66, 0, 0, 0, 0, 0, }, - { "", BARCODE_AUSROUTE, 67, 0, 0, 0, 0, 0, }, - { "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, }, + { "auspost", BARCODE_AUSREPLY, 66, 0, 0, 0, 0, 0, }, + { "auspost", BARCODE_AUSROUTE, 67, 0, 0, 0, 0, 0, }, + { "auspost", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, }, { "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, }, { "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, }, { "datamatrix", BARCODE_DATAMATRIX, 71, 1, 1, 1, 1, 0, }, @@ -2672,7 +2672,8 @@ static char *testUtilBwippCvtGS1Data(char *bwipp_data, const int bwipp_data_size /* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE */ static int supports_extra_escape_mode(const struct zint_symbol *const symbol) { return symbol->symbology == BARCODE_CODE128 - || (symbol->symbology == BARCODE_DATAMATRIX && (symbol->input_mode & 0x07) != GS1_MODE); + || ((symbol->symbology == BARCODE_AZTEC || symbol->symbology == BARCODE_DATAMATRIX) + && (symbol->input_mode & 0x07) != GS1_MODE); } #define z_isxdigit(c) (z_isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) @@ -2691,9 +2692,24 @@ static char *testUtilBwippEscape(const struct zint_symbol *const symbol, char *b int have_done_single_caret = 0; /* Flag to help debug escaping of carets */ if (eci) { - sprintf(bwipp_data, "^ECI%06d", eci); + int position_fnc1; + /* Check if have extra escape position FNC1s first, and put before ECI if so */ + if (is_extra_escaped && (position_fnc1 = z_extra_escape_position_fnc1(d, length))) { + assert(b + 7 < be); + if (position_fnc1 == 4) { + *b++ = d[0]; + } else if (position_fnc1 == 5) { + *b++ = d[0]; + *b++ = d[1]; + } + strcpy(b, "^FNC1"); + b += 5; + d += position_fnc1; + } + assert(b + 10 < be); + sprintf(b, "^ECI%06d", eci); *parsefnc = 1; - b = bwipp_data + 10; + b += 10; } while (b < be && d < de) { @@ -2933,7 +2949,7 @@ static char *testUtilBwippUtf8Convert(const int index, const int symbology, cons /* Create bwipp_dump.ps command and run */ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, - const char *data, int length, const char *primary, char *buffer, int buffer_size, int *p_parsefnc) { + const char *data, int length, const char *primary, char *buffer, int buffer_size, const int *p_parsefnc) { static const char fn[] = "testUtilBwipp"; static const char cmd_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s'" " backend/tests/tools/bwipp_dump.ps"; @@ -3232,7 +3248,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int } } else if (symbology == BARCODE_POSTNET || symbology == BARCODE_PLANET || symbology == BARCODE_RM4SCC || symbology == BARCODE_JAPANPOST || symbology == BARCODE_KIX || symbology == BARCODE_DAFT - || symbology == BARCODE_USPS_IMAIL || symbology == BARCODE_AUSPOST + || symbology == BARCODE_USPS_IMAIL + || (symbology >= BARCODE_AUSPOST && symbology <= BARCODE_AUSREDIRECT) || symbology == BARCODE_PHARMA_TWO) { for (r = 0; r < symbol->rows; r++) bwipp_row_height[r] = 1; /* Zap */ if (symbology == BARCODE_RM4SCC || symbology == BARCODE_KIX || symbology == BARCODE_JAPANPOST @@ -3243,32 +3260,26 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int if (dash) { memmove(dash, dash + 1, strlen(dash)); } - } else if (symbology == BARCODE_AUSPOST) { + } else if (symbology >= BARCODE_AUSPOST && symbology <= BARCODE_AUSREDIRECT) { const char *prefix; - if (data_len == 8) { - prefix = "11"; - } else if (data_len == 13 || data_len == 16) { - prefix = "59"; - if (data_len == 16) { - sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%scustinfoenc=numeric", - strlen(bwipp_opts_buf) ? " " : ""); - bwipp_opts = bwipp_opts_buf; - } + if (symbology != BARCODE_AUSPOST || data_len <= 8) { + static const char zeroes[] = "0000000"; + char buf[10 + 1]; + prefix = symbology == BARCODE_AUSREPLY ? "45" : symbology == BARCODE_AUSROUTE ? "87" + : symbology == BARCODE_AUSREDIRECT ? "92" : "11"; + sprintf(buf, "%s%.*s%s", prefix, 8 - data_len, zeroes, bwipp_data); + memcpy(bwipp_data, buf, 10 + 1); } else { - prefix = "62"; - if (data_len == 23) { + int not_all_digits = z_not_sane(NEON_F, ZCUCP(bwipp_data), data_len); + prefix = data_len > 16 || (data_len > 13 && not_all_digits) ? "62" : "59"; + if (!not_all_digits) { sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%scustinfoenc=numeric", strlen(bwipp_opts_buf) ? " " : ""); bwipp_opts = bwipp_opts_buf; } + memmove(bwipp_data + 2, bwipp_data, data_len + 1); + memmove(bwipp_data, prefix, 2); } - /* Check for Null - for when supported by BWIPP */ - for (i = 0; i < 8 && data[i] == '0'; i++); - if (i == 8) { - prefix = "00"; - } - memmove(bwipp_data + 2, bwipp_data, data_len + 1); - memmove(bwipp_data, prefix, 2); } } else if (symbology == BARCODE_CODE128AB) { sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%ssuppressc", strlen(bwipp_opts_buf) ? " " : ""); @@ -4424,7 +4435,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in /* FNC1 in 1st position treated as GS1 and in 2nd position AIM, neither transmitted - need to skip AIM (single alphabetic or Code Set C double digit) TODO: guessing about whether in Code Set C for double digit */ - if (symbol->eci || have_position_fnc1 || j > 2 || (j == 1 && !z_isalpha(escaped[0])) + if (have_position_fnc1 || j > 2 || (j == 1 && !z_isalpha(escaped[0])) || (j == 2 && !(z_isdigit(escaped[0]) && z_isdigit(escaped[1]) && !have_manual_ab))) { /* Probably not AIM */ @@ -4553,14 +4564,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in } } else if (symbology == BARCODE_DPLEIT || symbology == BARCODE_DPIDENT) { const int len = symbology == BARCODE_DPLEIT ? 13 : 11; - int zeroes = len - expected_len; unsigned int count = 0; int factor = 4; - for (i = 0; i < zeroes; i++) { - c25inter[i] = '0'; - } - memcpy(c25inter + zeroes, expected, expected_len); - expected_len += zeroes; + expected_len += z_zero_fill(ZCUCP(expected), expected_len, ZUCP(c25inter), len); for (i = len - 1; i >= 0; i--) { count += factor * z_ctoi(c25inter[i]); factor ^= 0x0D; /* Toggles 4 and 9 */ @@ -4569,12 +4575,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in c25inter[++expected_len] = '\0'; expected = c25inter; } else if (symbology == BARCODE_ITF14) { - int zeroes = 13 - expected_len; - for (i = 0; i < zeroes; i++) { - c25inter[i] = '0'; - } - memcpy(c25inter + zeroes, expected, expected_len); - expected_len += zeroes; + expected_len += z_zero_fill(ZCUCP(expected), expected_len, ZUCP(c25inter), 13); c25inter[expected_len] = zint_gs1_check_digit((const unsigned char *) c25inter, 13); c25inter[++expected_len] = '\0'; expected = c25inter; @@ -4664,11 +4665,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in } else if (symbology == BARCODE_EAN14 || symbology == BARCODE_NVE18) { int len = symbology == BARCODE_NVE18 ? 17 : 13; - int zeroes = expected_len < len ? len - expected_len: 0; ean14_nve18[0] = '0'; ean14_nve18[1] = symbology == BARCODE_NVE18 ? '0' : '1'; - memset(ean14_nve18 + 2, '0', zeroes); - memcpy(ean14_nve18 + 2 + zeroes, expected, expected_len); + z_zero_fill(ZCUCP(expected), expected_len, ZUCP(ean14_nve18 + 2), len); ean14_nve18[len + 2] = zint_gs1_check_digit((unsigned char *) (ean14_nve18 + 2), len); expected = ean14_nve18; expected_len = len + 3; diff --git a/backend/tests/testcommon.h b/backend/tests/testcommon.h index 8ec16eb2..ca49ad0d 100644 --- a/backend/tests/testcommon.h +++ b/backend/tests/testcommon.h @@ -215,7 +215,7 @@ int testUtilVerifyTiffInfo(const char *filename, int debug); int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, int debug); int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3, - const char *data, int length, const char *primary, char *buffer, int buffer_size, int *p_parsefnc); + const char *data, int length, const char *primary, char *buffer, int buffer_size, const int *p_parsefnc); int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int option_2, int option_3, const struct zint_seg segs[], const int seg_count, const char *primary, char *buffer, int buffer_size); int testUtilBwippCmp(const struct zint_symbol *symbol, char *msg, char *cmp_buf, const char *expected); diff --git a/backend/tests/tools/bwipp_dump.ps.tar.xz b/backend/tests/tools/bwipp_dump.ps.tar.xz index 25640ba2..d8202c3a 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/backend/tests/tools/run_zxingcpp_tests.sh b/backend/tests/tools/run_zxingcpp_tests.sh index cb955972..8b27660d 100755 --- a/backend/tests/tools/run_zxingcpp_tests.sh +++ b/backend/tests/tools/run_zxingcpp_tests.sh @@ -18,6 +18,7 @@ run_zxingcpp_test "test_2of5" "encode" run_zxingcpp_test "test_aztec" "large" run_zxingcpp_test "test_aztec" "bs" run_zxingcpp_test "test_aztec" "many_states" +run_zxingcpp_test "test_aztec" "options" run_zxingcpp_test "test_aztec" "encode" run_zxingcpp_test "test_aztec" "encode_segs" run_zxingcpp_test "test_aztec" "fuzz" diff --git a/backend/zint.h b/backend/zint.h index 1173e7eb..a369acd8 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -324,7 +324,7 @@ extern "C" { #define FAST_MODE 0x0080 /* Use faster if less optimal encodation or other shortcuts if available */ /* (affects AZTEC, DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only) */ #define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences as well as others */ - /* Note: currently Code 128 and Data Matrix only */ + /* Note: currently Aztec Code, Code 128 and Data Matrix only */ #define GS1SYNTAXENGINE_MODE 0x0200 /* Use the GS1 Syntax Engine (if available) to strictly validate GS1 input */ #define GS1RAW_MODE 0x0400 /* Process GS1 data literally (no AI delimiters), parsing GSs as FNC1s */ diff --git a/backend_tcl/zint.c b/backend_tcl/zint.c index f0380ef4..1d9a3311 100644 --- a/backend_tcl/zint.c +++ b/backend_tcl/zint.c @@ -577,7 +577,7 @@ static const char help_message[] = "zint tcl(stub,obj) dll\n" " -eci choice: ECI to use\n" /* cli option --embedfont not supported (vector output only) */ " -esc bool: process escape sequences in input data\n" - " -extraesc bool: process symbology-specific escape sequences (Code 128 and Data Matrix only)\n" + " -extraesc bool: process symbology-specific escape sequences (Aztec Code, Code 128, Data Matrix)\n" " -fast bool: use fast encodation (Aztec, Data Matrix, MicroPDF417, PDF417, QR, UPNQR)\n" " -fg color: set foreground color as 6 or 8 hex rrggbbaa\n" /* replaces cli options --binary and --gs1 */ diff --git a/docs/manual.html b/docs/manual.html index 9996b2de..5f7447d3 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -1515,25 +1515,25 @@ Sequences \^1 Insert FNC1 character -Code128, Data Matrix +Aztec Code, Code 128, Data Matrix \^^ Literal \^ -Code128, Data Matrix +Aztec Code, Code 128, Data Matrix \^A, \^B, \^C Select Code Set A, B or C respectively -Code128 only +Code 128 only \^@ Exit manual Code Set selection and resume automatic Code Set selection -Code128 only +Code 128 only @@ -4297,7 +4297,8 @@ other shortcuts if available (affects AZTEC, EXTRA_ESCAPE_MODE Process special symbology-specific escape -sequences (CODE128 and DATAMATRIX only). +sequences (AZTEC, CODE128 and +DATAMATRIX only). GS1SYNTAXENGINE_MODE @@ -4740,8 +4741,8 @@ alt="zint -b C25INTER --compliantheight -d "9212320967"" />

No check digit is added by default, but can be set the same as for 6.1.2.1 Standard Code 2 of 5.

6.1.2.5 Code 2 of 5 Data Logic

-

Data Logic can encode numeric input (digits 0-9) up to a maximum of -113 digits.

+

Data Logic, also known as China Post or Hong Kong 2 of 5, can encode +numeric input (digits 0-9) up to a maximum of 113 digits.

zint -b C25LOGIC -d "9212320967" @@ -5998,7 +5999,7 @@ alt="zint -b PHARMA_TWO --compliantheight -d "29876543"" />

6.4.2 POSTNET

Used by the United States Postal Service until 2009, the POSTNET -barcode was used for encoding zip-codes on mail items. POSTNET uses +barcode was used for encoding ZIP codes on mail items. POSTNET uses numerical input data and includes a modulo-10 check digit. While Zint will encode POSTNET symbols of up to 38 digits in length, standard lengths as used by USPS were PostNet6 (5-digit ZIP input), @@ -6085,69 +6086,75 @@ alt="zint -b AUSPOST --compliantheight -d "96184209"" />

Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control Code (FCC) is added by Zint and should not be included in the input data. Reed-Solomon error correction data is generated by Zint. -Encoding behaviour is determined by the length of the input data -according to the formula shown in the following table. The first 8 -digits is the DPID.

+Encoding behaviour is determined by the length and type of the input +data as shown in the following table, where C means any +valid character.

--+++-+ - - + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + +
Table 23: Australia Post Input Formats
Input LengthRequired Input FormatSymbol LengthDPID (required)Customer Data (optional)Symbol Length FCC Encoding Table(s)
89999999937-bar1-81 to 8 digitsNone37 bars 11 N
1399999999AAAAA52-bar9-138 digits1 to 5 C52 bars 59 N and C
16999999999999999952-bar9-168 digits1 to 8 digits52 bars 59 N
1899999999AAAAAAAAAA67-bar9-188 digits1 to 10 C67 bars 62 N and C
239999999999999999999999967-bar9-238 digits1 to 15 digits67 bars 62 N
-

The special Null FCC 00, non-machine readable and intended for -customer use only, is used (all input lengths) if the DPID is all -zeroes.

+

The special Null FCC 00, intended for customer use only, is used (all +input lengths) if the DPID is all zeroes.

6.5.1.2 Reply Paid Barcode

A Reply Paid version of the Australia Post 4-State Barcode (FCC 45) which requires an 8-digit DPID input.

@@ -6282,10 +6289,10 @@ alt="zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234&qu
Figure 108: zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"
-

Intelligent Mail is a fixed length (65-bar) symbol which combines +

Intelligent Mail is a fixed length 65-bar symbol which combines routing and customer information in a single symbol. Input data consists of a 20-digit tracking code, followed by a dash (-), -followed by a delivery point zip-code which can be 0, 5, 9 or 11 digits +followed by a delivery point ZIP code which can be 0, 5, 9 or 11 digits in length. For example all of the following inputs are valid data entries:

    @@ -7764,6 +7771,14 @@ length of approximately 3823 numeric or 3067 alphabetic characters or 1914 bytes of data. A separate symbology ID (BARCODE_HIBC_AZTEC) can be used to encode Health Industry Barcode (HIBC) data.

    +

    Manual insertion of FNC1 is possible using the +--extraesc option (API +input_mode |= EXTRA_ESCAPE_MODE), which apart from +processing normal escape sequences also processes the extra escape +sequences given in Table 3: Extra Escape +Sequences - see 6.6.1 Data +Matrix (ISO 16022) for details.

    For a faster but less optimal encodation, the --fast option (API input_mode |= FAST_MODE) may be used.

    Aztec Code supports Structured Append of up to 26 symbols and an @@ -8520,12 +8535,12 @@ reply mail with a B Used for business reply mail without a -pre-printed zip code. +pre-printed ZIP code. C Used for business reply mail with a -pre-printed zip code. +pre-printed ZIP code. D @@ -9421,9 +9436,9 @@ are:

    --extraesc

    As well as processing the normal escape sequences above, process the -special escape sequences beginning with \^. For Code 128 -and Data Matrix, process the escape sequence \^1 that -inserts an FNC1 character, and the escaping sequence +special escape sequences beginning with \^. For Aztec Code, +Code 128 and Data Matrix, process the escape sequence \^1 +that inserts an FNC1 character, and the escaping sequence \^^ that encodes a literal \^. For Code 128 only, process the escape sequences \^A, \^B, \^C and \^@ that allow manual switching of diff --git a/docs/manual.pmd b/docs/manual.pmd index c209524c..bda1c160 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -603,14 +603,16 @@ the sequence backslash caret ("`\^`"): Extra Escape Interpretation Available for Symbology Sequence ----------------- ------------------------------ ----------------------- -`\^1` Insert `FNC1` character Code128, Data Matrix +`\^1` Insert `FNC1` character Aztec Code, Code 128, + Data Matrix -`\^^` Literal `\^` Code128, Data Matrix +`\^^` Literal `\^` Aztec Code, Code 128, + Data Matrix -`\^A`, `\^B`, `\^C` Select Code Set A, B or C Code128 only +`\^A`, `\^B`, `\^C` Select Code Set A, B or C Code 128 only respectively -`\^@` Exit manual Code Set selection Code128 only +`\^@` Exit manual Code Set selection Code 128 only and resume automatic Code Set selection --------------------------------------------------------------------------- @@ -2552,7 +2554,7 @@ Value Effect `MICROPDF417`, `PDF417`, `QRCODE` and `UPNQR` only). `EXTRA_ESCAPE_MODE` Process special symbology-specific escape sequences - (`CODE128` and `DATAMATRIX` only). + (`AZTEC`, `CODE128` and `DATAMATRIX` only). `GS1SYNTAXENGINE_MODE` Use the GS1 Syntax Engine (if available) to strictly validate GS1 input. @@ -3007,7 +3009,8 @@ Standard Code 2 of 5]. #### 6.1.2.5 Code 2 of 5 Data Logic -Data Logic can encode numeric input (digits 0-9) up to a maximum of 113 digits. +Data Logic, also known as China Post or Hong Kong 2 of 5, can encode numeric +input (digits 0-9) up to a maximum of 113 digits. ![`zint -b C25LOGIC -d "9212320967"`](images/c25logic.svg){.lin} @@ -4056,7 +4059,7 @@ pharmaceuticals. The symbology is able to encode whole numbers between 4 and ### 6.4.2 POSTNET Used by the United States Postal Service until 2009, the POSTNET barcode was -used for encoding zip-codes on mail items. POSTNET uses numerical input data and +used for encoding ZIP codes on mail items. POSTNET uses numerical input data and includes a modulo-10 check digit. While Zint will encode POSTNET symbols of up to 38 digits in length, standard lengths as used by USPS were `PostNet6` (5-digit ZIP input), `PostNet10` (5-digit ZIP + 4-digit user data) and @@ -4141,28 +4144,28 @@ on mail items. Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control Code (FCC) is added by Zint and should not be included in the input data. Reed-Solomon error correction data is generated by Zint. Encoding behaviour is -determined by the length of the input data according to the formula shown in the -following table. The first 8 digits is the DPID. +determined by the length and type of the input data as shown in the following +table, where `C` means any valid character. ------------------------------------------------------------- -Input Required Input Format Symbol FCC Encoding -Length Length Table(s) ------- ------------------------- ------ --- -------- -8 `99999999` 37-bar 11 N +Input DPID Customer Data Symbol FCC Encoding +Length (required) (optional) Length Table(s) +------ ------------- -------------- ------- --- -------- +1-8 1 to 8 digits None 37 bars 11 N -13 `99999999AAAAA` 52-bar 59 N and C +9-13 8 digits 1 to 5 `C` 52 bars 59 N and C -16 `9999999999999999` 52-bar 59 N +9-16 8 digits 1 to 8 digits 52 bars 59 N -18 `99999999AAAAAAAAAA` 67-bar 62 N and C +9-18 8 digits 1 to 10 `C` 67 bars 62 N and C -23 `99999999999999999999999` 67-bar 62 N +9-23 8 digits 1 to 15 digits 67 bars 62 N ------------------------------------------------------------- Table: Australia Post Input Formats {#tbl:auspost_input_formats} -The special Null FCC 00, non-machine readable and intended for customer use -only, is used (all input lengths) if the DPID is all zeroes. +The special Null FCC 00, intended for customer use only, is used (all input +lengths) if the DPID is all zeroes. #### 6.5.1.2 Reply Paid Barcode @@ -4256,9 +4259,9 @@ PLANET symbologies in 2009. ![`zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"`](images/usps_imail.svg){.trk} -Intelligent Mail is a fixed length (65-bar) symbol which combines routing and +Intelligent Mail is a fixed length 65-bar symbol which combines routing and customer information in a single symbol. Input data consists of a 20-digit -tracking code, followed by a dash (`-`), followed by a delivery point zip-code +tracking code, followed by a dash (`-`), followed by a delivery point ZIP code which can be 0, 5, 9 or 11 digits in length. For example all of the following inputs are valid data entries: @@ -4887,6 +4890,11 @@ approximately 3823 numeric or 3067 alphabetic characters or 1914 bytes of data. A separate symbology ID (`BARCODE_HIBC_AZTEC`) can be used to encode Health Industry Barcode (HIBC) data. +Manual insertion of `FNC1` is possible using the `--extraesc` option (API +`input_mode |= EXTRA_ESCAPE_MODE`), which apart from processing normal escape +sequences also processes the extra escape sequences given in +[#tbl:extra_escapes] - see [6.6.1 Data Matrix (ISO 16022)] for details. + For a faster but less optimal encodation, the `--fast` option (API `input_mode |= FAST_MODE`) may be used. @@ -5164,8 +5172,8 @@ Code Letter Usage ----------- -------------------------------------------------------------- A Used for courtesy reply mail and metered reply mail with a pre-printed POSTNET symbol. -B Used for business reply mail without a pre-printed zip code. -C Used for business reply mail with a pre-printed zip code. +B Used for business reply mail without a pre-printed ZIP code. +C Used for business reply mail with a pre-printed ZIP code. D Used for Information Based Indicia (IBI) postage. E Used for customized mail with a USPS Intelligent Mail barcode. diff --git a/docs/manual.txt b/docs/manual.txt index c12cc136..48f41f83 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -755,14 +755,16 @@ the sequence backslash caret (“\^”): Extra Escape Interpretation Available for Symbology Sequence -------------------- ------------------------------- ----------------------- - \^1 Insert FNC1 character Code128, Data Matrix + \^1 Insert FNC1 character Aztec Code, Code 128, + Data Matrix - \^^ Literal \^ Code128, Data Matrix + \^^ Literal \^ Aztec Code, Code 128, + Data Matrix - \^A, \^B, \^C Select Code Set A, B or C Code128 only + \^A, \^B, \^C Select Code Set A, B or C Code 128 only respectively - \^@ Exit manual Code Set selection Code128 only + \^@ Exit manual Code Set selection Code 128 only and resume automatic Code Set selection ---------------------------------------------------------------------------- @@ -2509,7 +2511,7 @@ member: MICROPDF417, PDF417, QRCODE and UPNQR only). EXTRA_ESCAPE_MODE Process special symbology-specific escape sequences - (CODE128 and DATAMATRIX only). + (AZTEC, CODE128 and DATAMATRIX only). GS1SYNTAXENGINE_MODE Use the GS1 Syntax Engine (if available) to strictly validate GS1 input. @@ -2909,7 +2911,8 @@ Standard Code 2 of 5. 6.1.2.5 Code 2 of 5 Data Logic -Data Logic can encode numeric input (digits 0-9) up to a maximum of 113 digits. +Data Logic, also known as China Post or Hong Kong 2 of 5, can encode numeric +input (digits 0-9) up to a maximum of 113 digits. [zint -b C25LOGIC -d "9212320967"] @@ -3874,7 +3877,7 @@ pharmaceuticals. The symbology is able to encode whole numbers between 4 and 6.4.2 POSTNET Used by the United States Postal Service until 2009, the POSTNET barcode was -used for encoding zip-codes on mail items. POSTNET uses numerical input data and +used for encoding ZIP codes on mail items. POSTNET uses numerical input data and includes a modulo-10 check digit. While Zint will encode POSTNET symbols of up to 38 digits in length, standard lengths as used by USPS were PostNet6 (5-digit ZIP input), PostNet10 (5-digit ZIP + 4-digit user data) and PostNet12 (5-digit @@ -3948,28 +3951,28 @@ on mail items. Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control Code (FCC) is added by Zint and should not be included in the input data. Reed-Solomon error correction data is generated by Zint. Encoding behaviour is -determined by the length of the input data according to the formula shown in the -following table. The first 8 digits is the DPID. +determined by the length and type of the input data as shown in the following +table, where C means any valid character. - --------------------------------------------------------------- - Input Required Input Format Symbol FCC Encoding - Length Length Table(s) - --------- --------------------------- -------- ----- ---------- - 8 99999999 37-bar 11 N + ----------------------------------------------------------------- + Input DPID Customer Data Symbol FCC Encoding + Length (required) (optional) Length Table(s) + -------- -------------- --------------- -------- ----- ---------- + 1-8 1 to 8 digits None 37 bars 11 N - 13 99999999AAAAA 52-bar 59 N and C + 9-13 8 digits 1 to 5 C 52 bars 59 N and C - 16 9999999999999999 52-bar 59 N + 9-16 8 digits 1 to 8 digits 52 bars 59 N - 18 99999999AAAAAAAAAA 67-bar 62 N and C + 9-18 8 digits 1 to 10 C 67 bars 62 N and C - 23 99999999999999999999999 67-bar 62 N - --------------------------------------------------------------- + 9-23 8 digits 1 to 15 digits 67 bars 62 N + ----------------------------------------------------------------- Table 23: Australia Post Input Formats -The special Null FCC 00, non-machine readable and intended for customer use -only, is used (all input lengths) if the DPID is all zeroes. +The special Null FCC 00, intended for customer use only, is used (all input +lengths) if the DPID is all zeroes. 6.5.1.2 Reply Paid Barcode @@ -4062,9 +4065,9 @@ PLANET symbologies in 2009. [zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"] -Intelligent Mail is a fixed length (65-bar) symbol which combines routing and +Intelligent Mail is a fixed length 65-bar symbol which combines routing and customer information in a single symbol. Input data consists of a 20-digit -tracking code, followed by a dash (-), followed by a delivery point zip-code +tracking code, followed by a dash (-), followed by a delivery point ZIP code which can be 0, 5, 9 or 11 digits in length. For example all of the following inputs are valid data entries: @@ -4663,6 +4666,11 @@ approximately 3823 numeric or 3067 alphabetic characters or 1914 bytes of data. A separate symbology ID (BARCODE_HIBC_AZTEC) can be used to encode Health Industry Barcode (HIBC) data. +Manual insertion of FNC1 is possible using the --extraesc option (API +input_mode |= EXTRA_ESCAPE_MODE), which apart from processing normal escape +sequences also processes the extra escape sequences given in Table 3: Extra +Escape Sequences - see 6.6.1 Data Matrix (ISO 16022) for details. + For a faster but less optimal encodation, the --fast option (API input_mode |= FAST_MODE) may be used. @@ -4933,8 +4941,8 @@ as shown in the table below. ------------- ---------------------------------------------------------------- A Used for courtesy reply mail and metered reply mail with a pre-printed POSTNET symbol. - B Used for business reply mail without a pre-printed zip code. - C Used for business reply mail with a pre-printed zip code. + B Used for business reply mail without a pre-printed ZIP code. + C Used for business reply mail with a pre-printed ZIP code. D Used for Information Based Indicia (IBI) postage. E Used for customized mail with a USPS Intelligent Mail barcode. @@ -5459,11 +5467,11 @@ OPTIONS --extraesc As well as processing the normal escape sequences above, process the special - escape sequences beginning with \^. For Code 128 and Data Matrix, process - the escape sequence \^1 that inserts an FNC1 character, and the escaping - sequence \^^ that encodes a literal \^. For Code 128 only, process the - escape sequences \^A, \^B, \^C and \^@ that allow manual switching of Code - Sets. The sequence \^@ turns off manual switching. + escape sequences beginning with \^. For Aztec Code, Code 128 and Data + Matrix, process the escape sequence \^1 that inserts an FNC1 character, and + the escaping sequence \^^ that encodes a literal \^. For Code 128 only, + process the escape sequences \^A, \^B, \^C and \^@ that allow manual + switching of Code Sets. The sequence \^@ turns off manual switching. --fast diff --git a/docs/zint.1 b/docs/zint.1 index a031b0d9..0ad2ba31 100644 --- a/docs/zint.1 +++ b/docs/zint.1 @@ -215,7 +215,7 @@ The escape sequences are: \f[CR]\-\-extraesc\f[R] As well as processing the normal escape sequences above, process the special escape sequences beginning with \f[CR]\(rs\(ha\f[R]. -For Code 128 and Data Matrix, process the escape sequence +For Aztec Code, Code 128 and Data Matrix, process the escape sequence \f[CR]\(rs\(ha1\f[R] that inserts an \f[CR]FNC1\f[R] character, and the escaping sequence \f[CR]\(rs\(ha\(ha\f[R] that encodes a literal \f[CR]\(rs\(ha\f[R]. diff --git a/docs/zint.1.pmd b/docs/zint.1.pmd index 555543fc..be987f09 100644 --- a/docs/zint.1.pmd +++ b/docs/zint.1.pmd @@ -194,9 +194,9 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S `--extraesc` : As well as processing the normal escape sequences above, process the special escape sequences beginning with `\^`. - For Code 128 and Data Matrix, process the escape sequence `\^1` that inserts an `FNC1` character, and the escaping - sequence `\^^` that encodes a literal `\^`. For Code 128 only, process the escape sequences `\^A`, `\^B`, `\^C` - and `\^@` that allow manual switching of Code Sets. The sequence `\^@` turns off manual switching. + For Aztec Code, Code 128 and Data Matrix, process the escape sequence `\^1` that inserts an `FNC1` character, and + the escaping sequence `\^^` that encodes a literal `\^`. For Code 128 only, process the escape sequences `\^A`, + `\^B`, `\^C` and `\^@` that allow manual switching of Code Sets. The sequence `\^@` turns off manual switching. `--fast` diff --git a/frontend_qt/grpAztec.ui b/frontend_qt/grpAztec.ui index f47c915d..81db24aa 100644 --- a/frontend_qt/grpAztec.ui +++ b/frontend_qt/grpAztec.ui @@ -369,6 +369,18 @@ the data with a slash "/" + + + + Manual FN&C1s (Extra Escape) + + + Process special escape sequence "\^1" +allowing manual FNC1s +(literal "\^" may be escaped with "\^^") + + + diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 00343e4f..a0e217ae 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -1856,6 +1856,7 @@ void MainWindow::change_options() connect(get_widget(QSL("radAztecStand")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("radAztecGS1")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("radAztecHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview())); + connect(get_widget(QSL("radAztecExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("chkAztecFull")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("chkAztecFast")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("cmbAztecStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview())); @@ -2026,9 +2027,9 @@ void MainWindow::change_options() dm_startmode_ui_set(); tabMain->insertTab(1, m_optionWidget, tr("D&ata Matrix")); connect(get_widget(QSL("radDMStand")), SIGNAL(toggled(bool)), SLOT(update_preview())); - connect(get_widget(QSL("radDMExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("radDMGS1")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("radDMHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview())); + connect(get_widget(QSL("radDMExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("cmbDMSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview())); connect(get_widget(QSL("chkDMRectangle")), SIGNAL(toggled(bool)), SLOT(update_preview())); connect(get_widget(QSL("chkDMRE")), SIGNAL(toggled(bool)), SLOT(update_preview())); @@ -2952,10 +2953,14 @@ void MainWindow::update_preview() break; case BARCODE_AZTEC: - if (get_rad_val(QSL("radAztecHIBC"))) + if (get_rad_val(QSL("radAztecHIBC"))) { m_bc.bc.setSymbol(BARCODE_HIBC_AZTEC); - else + } else { m_bc.bc.setSymbol(BARCODE_AZTEC); + if (get_rad_val(QSL("radAztecExtraEsc"))) { + m_bc.bc.setInputMode(m_bc.bc.inputMode() | EXTRA_ESCAPE_MODE); + } + } if (get_rad_val(QSL("radAztecSize"))) { m_bc.bc.setOption2(get_cmb_index(QSL("cmbAztecSize")) + 1); @@ -4458,7 +4463,8 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) settings.setValue(QSL("studio/bc/aztec/size"), m_aztecSizeIndex); settings.setValue(QSL("studio/bc/aztec/ecc"), m_aztecECCIndex); settings.setValue(QSL("studio/bc/aztec/encoding_mode"), get_rad_grp_index( - QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC"))); + QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC") + << QSL("radAztecExtraEsc"))); settings.setValue(QSL("studio/bc/aztec/structapp_count"), get_cmb_index(QSL("cmbAztecStructAppCount"))); settings.setValue(QSL("studio/bc/aztec/chk_full"), get_chk_val(QSL("chkAztecFull"))); settings.setValue(QSL("studio/bc/aztec/chk_fast"), get_chk_val(QSL("chkAztecFast"))); @@ -4933,7 +4939,8 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) } set_cmb_from_setting(settings, QSL("studio/bc/aztec/ecc"), QSL("cmbAztecECC")); set_rad_from_setting(settings, QSL("studio/bc/aztec/encoding_mode"), - QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC")); + QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC") + << QSL("radAztecExtraEsc")); set_chk_from_setting(settings, QSL("studio/bc/aztec/chk_full"), QSL("chkAztecFull")); set_chk_from_setting(settings, QSL("studio/bc/aztec/chk_fast"), QSL("chkAztecFast")); set_cmb_from_setting(settings, QSL("studio/bc/aztec/structapp_count"), QSL("cmbAztecStructAppCount"));