diff --git a/ChangeLog b/ChangeLog index bc9339f5..2cd97934 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,9 @@ -Version 2.16.0.9 (dev) not released yet (2026-04-27) +Version 2.16.0.9 (dev) not released yet (2026-05-26) ==================================================== **Incompatible changes** ------------------------ -- Code 128 now errors on unrecognized extra escape sequences +- Code 128 now errors on unrecognised extra escape sequences (previously just passed them through) - Aztec error codeword percentages adjusted to be at least advertised values (may cause symbol size change, and generation failure if specified) @@ -13,6 +13,7 @@ Version 2.16.0.9 (dev) not released yet (2026-04-27) option for processing GS1 input - CLI now warns if both "--dmre" and "--square" are given (previously silently ignored "--dmre") +- New escape sequences `\L` (DLE), `\F` (FS), `\N` (US) Changes ------- @@ -20,6 +21,7 @@ Changes `BARCODE_MEMORY_FILE` and use in GUI for pasting to clipboard instead of creating temporary file - CLI: allow "tiff" as filetype (saved as ".tif"); + make args for "--scalexdimdp" and "--scmvv" optional; add `ZINT_TEST`-only "--test" option to do various internal tests - GS1SE: exclude GS1_128 from requisite AIs check as may be spread across more than one barcode (ticket #348, props Harald Oehlmann and Terry Burton) @@ -31,12 +33,17 @@ Changes - GS1: new `GS1RAW_MODE` (CLI "--gs1raw") and GS1 Syntax Engine "Unbracketed AI element strings" (caret) options for specifying GS1 input (ticket #350, props Mario Verbruggen) -- DATAMATRIX: new options "--dmb256=" (`option_3 = DM_B256_START`) & "--dmc40=" +- 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 - AZTEC/DATAMATRIX: add manual FNC1 support - AUSPOST: support FCC 00 Null (DPID all zeroes) and allow variable length data input +- general: new escape sequences `\L` (DLE), `\F` (FS), `\N` (US) +- TELEPEN/TELEPEN_NUM: support AIM-defined Start/Stop characters with option + "--vers=1" (API `option_2 = 1`) +- TELEPEN_NUM: support switching to Full ASCII mode with DLE +- TELEPEN: support switching to Compressed Numeric Mode with DLE if AIM enabled Bugs ---- diff --git a/backend/aztec.c b/backend/aztec.c index 30dddb44..00df7ec1 100644 --- a/backend/aztec.c +++ b/backend/aztec.c @@ -1625,7 +1625,8 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons 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"); + return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 807, + "Cannot use Reader Initialisation in Extra Escape mode"); } } diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 6297ca15..bb28ef5c 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -1771,7 +1771,8 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co "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"); + 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); diff --git a/backend/library.c b/backend/library.c index d71f1d96..cea5097c 100644 --- a/backend/library.c +++ b/backend/library.c @@ -716,13 +716,18 @@ static int esc_base(struct zint_symbol *symbol, const unsigned char *input_strin /* Helper to parse escape sequences. If `escaped_string` NULL, calculates length only */ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *input_string, int *p_length, unsigned char *escaped_string) { - /* NUL EOT BEL BS HT LF VT FF CR ESC GS RS \ */ - static const char escs[] = { '0', 'E', 'a', 'b', 't', 'n', 'v', 'f', 'r', 'e', 'G', 'R', '\\', '\0' }; - static const char vals[] = { 0x00, 0x04, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x1B, 0x1D, 0x1E, 0x5C }; + /* NOTE: if add escape character, must also update regex `escRE` in "frontend_qt/datawindow.php" */ + static const char escs[] = { + /* NUL EOT BEL BS HT LF VT FF CR DLE ESC FS GS RS US \ */ + '0', 'E', 'a', 'b', 't', 'n', 'v', 'f', 'r', 'L', 'e', 'F', 'G', 'R', 'N', '\\', '\0' + }; + static const char vals[] = { + 0x00, 0x04, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x10, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x5C + }; const int length = *p_length; int in_posn = 0, out_posn = 0; unsigned char ch; - int val; + int val, esc_posn; int i; unsigned int unicode; const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE; @@ -736,135 +741,123 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char * return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 236, "Incomplete escape character in input"); } ch = input_string[in_posn + 1]; - /* NOTE: if add escape character, must also update regex in "frontend_qt/datawindow.php" */ - switch (ch) { - case '0': - case 'E': - case 'a': - case 'b': - case 't': - case 'n': - case 'v': - case 'f': - case 'r': - case 'e': - case 'G': - case 'R': - 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"); + if ((esc_posn = z_posn(escs, ch)) != -1) { + if (escaped_string) escaped_string[out_posn] = vals[esc_posn]; + 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 */ + } else { + switch (ch) { + 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"); + } + return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 213, + "Extra escape '\\^' not valid for this symbology and/or input mode"); } - return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 213, - "Extra escape '\\^' not valid for this symbology and/or input mode"); - } - /* Pass thru unaltered */ - if (escaped_string) { - escaped_string[out_posn++] = '\\'; - escaped_string[out_posn] = '^'; - } else { - out_posn++; - } - in_posn += 2; - if (in_posn < length) { /* Note allowing '\\^' on its own at end */ + /* Pass thru unaltered */ if (escaped_string) { - escaped_string[++out_posn] = input_string[in_posn++]; - } else { - ++out_posn; - in_posn++; - } - } - break; - case '(': - case ')': - if (!escape_parens) { - return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 853, - "Escaped parentheses only valid in GS1 mode with GS1 parentheses flag"); - } - /* Pass through unaltered */ - if (escaped_string) { - escaped_string[out_posn++] = '\\'; - escaped_string[out_posn] = ch; - } else { - out_posn++; - } - in_posn += 2; - break; - case 'd': - case 'o': - case 'x': - if ((val = esc_base(symbol, input_string, length, in_posn + 2, ch)) == -1) { - return ZINT_ERROR_INVALID_DATA; - } - if (escaped_string) escaped_string[out_posn] = val; - in_posn += 4 + (ch != 'x'); - break; - case 'u': - case 'U': - if (in_posn + 6 > length || (ch == 'U' && in_posn + 8 > length)) { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 209, - "Incomplete '\\%c' escape sequence in input", ch); - } - unicode = 0; - for (i = 0; i < 6; i++) { - if ((val = z_ctoi(input_string[in_posn + i + 2])) == -1) { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 211, - "Invalid character for '\\%c' escape sequence in input (hexadecimal only)", - ch); - } - unicode = (unicode << 4) | val; - if (i == 3 && ch == 'u') { - break; - } - } - /* Exclude reversed BOM and surrogates and out-of-range */ - if (unicode == 0xFFFE || (unicode >= 0xD800 && unicode < 0xE000) || unicode > 0x10FFFF) { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 216, - "Value of escape sequence '%.*s' in input out of range", - ch == 'u' ? 6 : 8, input_string + in_posn); - } - if (unicode < 0x80) { - if (escaped_string) escaped_string[out_posn] = (unsigned char) unicode; - } else if (unicode < 0x800) { - if (escaped_string) { - escaped_string[out_posn++] = (unsigned char) (0xC0 | (unicode >> 6)); - escaped_string[out_posn] = (unsigned char) (0x80 | (unicode & 0x3F)); + escaped_string[out_posn++] = '\\'; + escaped_string[out_posn] = '^'; } else { out_posn++; } - } else if (unicode < 0x10000) { - if (escaped_string) { - escaped_string[out_posn++] = (unsigned char) (0xE0 | (unicode >> 12)); - escaped_string[out_posn++] = (unsigned char) (0x80 | ((unicode >> 6) & 0x3F)); - escaped_string[out_posn] = (unsigned char) (0x80 | (unicode & 0x3F)); - } else { - out_posn += 2; + in_posn += 2; + if (in_posn < length) { /* Note allowing '\\^' on its own at end */ + if (escaped_string) { + escaped_string[++out_posn] = input_string[in_posn++]; + } else { + ++out_posn; + in_posn++; + } } - } else { - if (escaped_string) { - escaped_string[out_posn++] = (unsigned char) (0xF0 | (unicode >> 18)); - escaped_string[out_posn++] = (unsigned char) (0x80 | ((unicode >> 12) & 0x3F)); - escaped_string[out_posn++] = (unsigned char) (0x80 | ((unicode >> 6) & 0x3F)); - escaped_string[out_posn] = (unsigned char) (0x80 | (unicode & 0x3F)); - } else { - out_posn += 3; + break; + case '(': + case ')': + if (!escape_parens) { + return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 853, + "Escaped parentheses only valid in GS1 mode with GS1 parentheses flag"); } - } - in_posn += 6 + (ch == 'U') * 2; - break; - default: - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 234, - "Unrecognised escape character '\\%c' in input", - !z_isascii(ch) || z_iscntrl(ch) ? '?' : ch); - break; + /* Pass through unaltered */ + if (escaped_string) { + escaped_string[out_posn++] = '\\'; + escaped_string[out_posn] = ch; + } else { + out_posn++; + } + in_posn += 2; + break; + case 'd': + case 'o': + case 'x': + if ((val = esc_base(symbol, input_string, length, in_posn + 2, ch)) == -1) { + return ZINT_ERROR_INVALID_DATA; + } + if (escaped_string) escaped_string[out_posn] = val; + in_posn += 4 + (ch != 'x'); + break; + case 'u': + case 'U': + if (in_posn + 6 > length || (ch == 'U' && in_posn + 8 > length)) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 209, + "Incomplete '\\%c' escape sequence in input", ch); + } + unicode = 0; + for (i = 0; i < 6; i++) { + if ((val = z_ctoi(input_string[in_posn + i + 2])) == -1) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 211, + "Invalid character for '\\%c' escape sequence in input (hexadecimal only)", + ch); + } + unicode = (unicode << 4) | val; + if (i == 3 && ch == 'u') { + break; + } + } + /* Exclude reversed BOM and surrogates and out-of-range */ + if (unicode == 0xFFFE || (unicode >= 0xD800 && unicode < 0xE000) || unicode > 0x10FFFF) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 216, + "Value of escape sequence '%.*s' in input out of range", + ch == 'u' ? 6 : 8, input_string + in_posn); + } + if (unicode < 0x80) { + if (escaped_string) escaped_string[out_posn] = (unsigned char) unicode; + } else if (unicode < 0x800) { + if (escaped_string) { + escaped_string[out_posn++] = (unsigned char) (0xC0 | (unicode >> 6)); + escaped_string[out_posn] = (unsigned char) (0x80 | (unicode & 0x3F)); + } else { + out_posn++; + } + } else if (unicode < 0x10000) { + if (escaped_string) { + escaped_string[out_posn++] = (unsigned char) (0xE0 | (unicode >> 12)); + escaped_string[out_posn++] = (unsigned char) (0x80 | ((unicode >> 6) & 0x3F)); + escaped_string[out_posn] = (unsigned char) (0x80 | (unicode & 0x3F)); + } else { + out_posn += 2; + } + } else { + if (escaped_string) { + escaped_string[out_posn++] = (unsigned char) (0xF0 | (unicode >> 18)); + escaped_string[out_posn++] = (unsigned char) (0x80 | ((unicode >> 12) & 0x3F)); + escaped_string[out_posn++] = (unsigned char) (0x80 | ((unicode >> 6) & 0x3F)); + escaped_string[out_posn] = (unsigned char) (0x80 | (unicode & 0x3F)); + } else { + out_posn += 3; + } + } + in_posn += 6 + (ch == 'U') * 2; + break; + default: + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 234, + "Unrecognised escape character '\\%c' in input", + !z_isascii(ch) || z_iscntrl(ch) ? '?' : ch); + break; + } } } else { if (escaped_string) escaped_string[out_posn] = input_string[in_posn]; @@ -2096,7 +2089,7 @@ float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm, cons return 0.0f; } if (filetype && *filetype) { - if ((i = filetype_idx(filetype)) < 0 || filetypes[i].filetype == 0) { /* Not found or TXT */ + if ((i = filetype_idx(filetype)) < 0) { /* Not found */ return 0.0f; } } else { diff --git a/backend/output.c b/backend/output.c index d5bdb666..a5e7d8b9 100644 --- a/backend/output.c +++ b/backend/output.c @@ -486,8 +486,7 @@ static int out_quiet_zones(const struct zint_symbol *symbol, const int hide_text case BARCODE_TELEPEN: case BARCODE_TELEPEN_NUM: - /* Appears to be ~10X from diagram in Telepen Barcode Symbology information and History */ - /* TODO: Find better doc */ + /* AIM Europe USS Telepen - 10X */ *left = *right = 10.0f; done = 1; break; diff --git a/backend/telepen.c b/backend/telepen.c index 1e170566..70982b9c 100644 --- a/backend/telepen.c +++ b/backend/telepen.c @@ -31,88 +31,193 @@ /* SPDX-License-Identifier: BSD-3-Clause */ /* Telepen Barcode Symbology information and History (BSiH) - https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf */ + https://advanova.co.uk/wp-content/uploads/2022/05/Barcode-Symbology-information-and-History.pdf */ +/* AIM Europe USS Telepen (1991) */ #define SODIUM_X_F (IS_NUM_F | IS_UX__F | IS_LX__F) /* SODIUM "0123456789Xx" */ +#define TELE_SYMBOL_MAX 69 /* 16 * (1 (Start) + 69 + 1 (check digit) + 1 (Stop)) = 1152 */ +#define TELE_SYMBOL_MAX_S "69" /* String version of above */ +#define TELE_LENGTH_MAX 200 /* Max possible is 138 - use > for better error messages */ + +#include #include #include "common.h" -static const char TeleTable[128][16] = { - { "31313131" }, { "1131313111" }, { "33313111" }, { "1111313131" }, - { "3111313111" }, { "11333131" }, { "13133131" }, { "111111313111" }, - { "31333111" }, { "1131113131" }, { "33113131" }, { "1111333111" }, - { "3111113131" }, { "1113133111" }, { "1311133111" }, { "111111113131" }, - { "3131113111" }, { "11313331" }, { "333331" }, { "111131113111" }, - { "31113331" }, { "1133113111" }, { "1313113111" }, { "1111113331" }, - { "31131331" }, { "113111113111" }, { "3311113111" }, { "1111131331" }, - { "311111113111" }, { "1113111331" }, { "1311111331" }, { "11111111113111" }, - { "31313311" }, { "1131311131" }, { "33311131" }, { "1111313311" }, - { "3111311131" }, { "11333311" }, { "13133311" }, { "111111311131" }, - { "31331131" }, { "1131113311" }, { "33113311" }, { "1111331131" }, - { "3111113311" }, { "1113131131" }, { "1311131131" }, { "111111113311" }, - { "3131111131" }, { "1131131311" }, { "33131311" }, { "111131111131" }, - { "3111131311" }, { "1133111131" }, { "1313111131" }, { "111111131311" }, - { "3113111311" }, { "113111111131" }, { "3311111131" }, { "111113111311" }, - { "311111111131" }, { "111311111311" }, { "131111111311" }, { "11111111111131" }, - { "3131311111" }, { "11313133" }, { "333133" }, { "111131311111" }, - { "31113133" }, { "1133311111" }, { "1313311111" }, { "1111113133" }, - { "313333" }, { "113111311111" }, { "3311311111" }, { "11113333" }, - { "311111311111" }, { "11131333" }, { "13111333" }, { "11111111311111" }, - { "31311133" }, { "1131331111" }, { "33331111" }, { "1111311133" }, - { "3111331111" }, { "11331133" }, { "13131133" }, { "111111331111" }, - { "3113131111" }, { "1131111133" }, { "33111133" }, { "111113131111" }, - { "3111111133" }, { "111311131111" }, { "131111131111" }, { "111111111133" }, - { "31311313" }, { "113131111111" }, { "3331111111" }, { "1111311313" }, - { "311131111111" }, { "11331313" }, { "13131313" }, { "11111131111111" }, - { "3133111111" }, { "1131111313" }, { "33111313" }, { "111133111111" }, - { "3111111313" }, { "111313111111" }, { "131113111111" }, { "111111111313" }, - { "313111111111" }, { "1131131113" }, { "33131113" }, { "11113111111111" }, - { "3111131113" }, { "113311111111" }, { "131311111111" }, { "111111131113" }, - { "3113111113" }, { "11311111111111" }, { "331111111111" }, { "111113111113" }, - { "31111111111111" }, { "111311111113" }, { "131111111113" }, - {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}, +/* Copied into "test_telepen.c" for lengths generator - see below */ +static const char TeleTable[132][16] = { + { "31313131" }, { "1131313111" }, { "33313111" }, { "1111313131" }, /*00-03*/ + { "3111313111" }, { "11333131" }, { "13133131" }, { "111111313111" }, /*04-07*/ + { "31333111" }, { "1131113131" }, { "33113131" }, { "1111333111" }, /*08-0B*/ + { "3111113131" }, { "1113133111" }, { "1311133111" }, { "111111113131" }, /*0C-0F*/ + { "3131113111" }, { "11313331" }, { "333331" }, { "111131113111" }, /*10-13*/ + { "31113331" }, { "1133113111" }, { "1313113111" }, { "1111113331" }, /*14-17*/ + { "31131331" }, { "113111113111" }, { "3311113111" }, { "1111131331" }, /*18-1B*/ + { "311111113111" }, { "1113111331" }, { "1311111331" }, { "11111111113111" }, /*1C-1F*/ + { "31313311" }, { "1131311131" }, { "33311131" }, { "1111313311" }, /*20-23*/ + { "3111311131" }, { "11333311" }, { "13133311" }, { "111111311131" }, /*24-27*/ + { "31331131" }, { "1131113311" }, { "33113311" }, { "1111331131" }, /*28-2B*/ + { "3111113311" }, { "1113131131" }, { "1311131131" }, { "111111113311" }, /*2C-2F*/ + { "3131111131" }, { "1131131311" }, { "33131311" }, { "111131111131" }, /*30-33*/ + { "3111131311" }, { "1133111131" }, { "1313111131" }, { "111111131311" }, /*34-37*/ + { "3113111311" }, { "113111111131" }, { "3311111131" }, { "111113111311" }, /*38-3B*/ + { "311111111131" }, { "111311111311" }, { "131111111311" }, { "11111111111131" }, /*3C-3F*/ + { "3131311111" }, { "11313133" }, { "333133" }, { "111131311111" }, /*40-43*/ + { "31113133" }, { "1133311111" }, { "1313311111" }, { "1111113133" }, /*44-47*/ + { "313333" }, { "113111311111" }, { "3311311111" }, { "11113333" }, /*48-4B*/ + { "311111311111" }, { "11131333" }, { "13111333" }, { "11111111311111" }, /*4C-4F*/ + { "31311133" }, { "1131331111" }, { "33331111" }, { "1111311133" }, /*50-53*/ + { "3111331111" }, { "11331133" }, { "13131133" }, { "111111331111" }, /*54-57*/ + { "3113131111" }, { "1131111133" }, { "33111133" }, { "111113131111" }, /*58-5B*/ + { "3111111133" }, { "111311131111" }, { "131111131111" }, { "111111111133" /*START*/ }, /*5C-5F*/ + { "31311313" }, { "113131111111" }, { "3331111111" }, { "1111311313" }, /*60-63*/ + { "311131111111" }, { "11331313" }, { "13131313" }, { "11111131111111" }, /*64-67*/ + { "3133111111" }, { "1131111313" }, { "33111313" }, { "111133111111" }, /*68-6B*/ + { "3111111313" }, { "111313111111" }, { "131113111111" }, { "111111111313" }, /*6C-6F*/ + { "313111111111" }, { "1131131113" }, { "33131113" }, { "11113111111111" }, /*70-73*/ + { "3111131113" }, { "113311111111" }, { "131311111111" }, { "111111131113" }, /*74-77*/ + { "3113111113" }, { "11311111111111" }, { "331111111111" /*STOP*/ }, { "111113111113" }, /*78-7B*/ + { "31111111111111" }, { "111311111113" }, { "131111111113" }, /*7C-7E*/ + {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}, /*7F*/ + { "111111113113" /*START 2*/ }, { "311311111111" /*STOP 2*/ }, /*80-81*/ + { "111111311113" /*START 3*/ }, { "311113111111" /*STOP 3*/ }, /*82-83*/ }; /* Generated by "backend/tests/test_telepen -f generate_lens -g" */ static const char TeleLens[128] = { - 8, 10, 8, 10, 10, 8, 8, 12, 8, 10, 8, 10, 10, 10, 10, 12, - 10, 8, 6, 12, 8, 10, 10, 10, 8, 12, 10, 10, 12, 10, 10, 14, - 8, 10, 8, 10, 10, 8, 8, 12, 8, 10, 8, 10, 10, 10, 10, 12, - 10, 10, 8, 12, 10, 10, 10, 12, 10, 12, 10, 12, 12, 12, 12, 14, - 10, 8, 6, 12, 8, 10, 10, 10, 6, 12, 10, 8, 12, 8, 8, 14, - 8, 10, 8, 10, 10, 8, 8, 12, 10, 10, 8, 12, 10, 12, 12, 12, - 8, 12, 10, 10, 12, 8, 8, 14, 10, 10, 8, 12, 10, 12, 12, 12, - 12, 10, 8, 14, 10, 12, 12, 12, 10, 14, 12, 12, 14, 12, 12, 16 + 8, 10, 8, 10, 10, 8, 8, 12, 8, 10, 8, 10, 10, 10, 10, 12, /*00-0F*/ + 10, 8, 6, 12, 8, 10, 10, 10, 8, 12, 10, 10, 12, 10, 10, 14, /*10-1F*/ + 8, 10, 8, 10, 10, 8, 8, 12, 8, 10, 8, 10, 10, 10, 10, 12, /*20-2F*/ + 10, 10, 8, 12, 10, 10, 10, 12, 10, 12, 10, 12, 12, 12, 12, 14, /*30-3F*/ + 10, 8, 6, 12, 8, 10, 10, 10, 6, 12, 10, 8, 12, 8, 8, 14, /*40-4F*/ + 8, 10, 8, 10, 10, 8, 8, 12, 10, 10, 8, 12, 10, 12, 12, 12, /*50-5F*/ + 8, 12, 10, 10, 12, 8, 8, 14, 10, 10, 8, 12, 10, 12, 12, 12, /*60-6F*/ + 12, 10, 8, 14, 10, 12, 12, 12, 10, 14, 12, 12, 14, 12, 12, 16 /*70-7F*/ }; +/* Expand numeric data */ +static char *tele_num(struct zint_symbol *symbol, const unsigned char source[], const int length, int i, char *d, + int *p_count) { + assert((length & 1) == (i & 1)); + for (; i < length; i += 2) { + int glyph; + if (source[i] == 'X') { + (void) z_errtxtf(0, symbol, 394, "Invalid odd position %d of \"X\" in Telepen data", i + 1); + return NULL; + } + glyph = source[i + 1] == 'X' ? z_ctoi(source[i]) + 17 : 10 * z_ctoi(source[i]) + z_ctoi(source[i + 1]) + 27; + *p_count += glyph; + memcpy(d, TeleTable[glyph], TeleLens[glyph]); + d += TeleLens[glyph]; + } + return d; +} + +/* Set height according to various Telepen docs and AIM USS Telepen (1991) */ +static int tele_set_height(struct zint_symbol *symbol, const int asc_length, const int num_length, + const int have_dle) { + int warn_number = 0; + + assert(asc_length > 0 || num_length > 0); + assert(!(num_length & 1)); + + if (symbol->output_options & COMPLIANT_HEIGHT) { + /* Following based on various Telepen docs and USS Telepen Section 3.2 Dimensions. + Recommended X between 0.01" & 0.0125" (0.254mm & 0.3175mm), so average is 0.01125" (0.28575mm). + Default height based on default 26pt at average X 0.01125" is then (26 / 72) / 0.01125 ~ 32X. + Per USS Telepen min height is 6.35mm or 15% of the symbol length whichever is greater, with + symbol length calculated as 16 * X * (3 + C + D/2 + S) + 2Q where + C is ASCII count, D numeric count, S whether have DLE or not, and Q quiet zone width (10X). + As don't have max X, use 15% as min height */ + const float mult = 0.4584f; /* 0.191 * 16 * 15% */ + const float min_height = z_stripf(mult * (3.0f + asc_length + num_length / 2 + have_dle) + 3.0f /*20*15%*/); + if (symbol->debug & ZINT_DEBUG_PRINT) printf("Min height: %.8g\n", min_height); + warn_number = z_set_height(symbol, min_height, min_height > 32.0f ? min_height : 32.0f, 0, 0 /*no_errtxt*/); + } else { + (void) z_set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/); + } + return warn_number; +} + +/* Telepen Alpha (Full ASCII) */ INTERNAL int zint_telepen(struct zint_symbol *symbol, unsigned char source[], int length) { - int i, count, check_digit; + int count, check_digit; int error_number; + int i; + int symbol_chars = length; char dest[1145]; /* 12 (Start) + 69 * 16 (max for DELs) + 16 (Check) + 12 (stop) + 1 = 1145 */ char *d = dest; + unsigned char local_source[138]; + int asc_length = length, num_length = 0, have_dle = 0; + const int asc_comp_num = symbol->option_2 == 1; /* AIM Full ASCII + Compressed Numeric mode */ const int content_segs = symbol->output_options & BARCODE_CONTENT_SEGS; - error_number = 0; - - count = 0; - - if (length > 69) { /* 16 (Start) + 69 * 16 + 16 (Check) + 16 (Stop) = 1152 */ - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 390, "Input length %d too long (maximum 69)", length); + /* Check for DLE (Compressed Numeric tail) only if AIM mode enabled */ + if (asc_comp_num && length <= TELE_LENGTH_MAX) { + for (i = 0; i < length; i++) { + if (source[i] == 0x10 /*DLE*/) { + if (i == 0) { + return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 397, + "DLE (ASCII 16) cannot be first character in Full ASCII + Compressed Numeric Mode"); + } + asc_length = i + 1; /* Include DLE */ + num_length = length - asc_length; + symbol_chars = asc_length + ((num_length + 1) >> 1); + have_dle = 1; + break; + } + } } + + if (symbol_chars > TELE_SYMBOL_MAX) { + if (length <= TELE_LENGTH_MAX) { + return ZEXT z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 390, + "Input length %1$d too long, requires %2$d symbol characters (maximum " + TELE_SYMBOL_MAX_S ")", length, symbol_chars); + } + return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 399, + "Input length %d too long, requires too many symbol characters (maximum " + TELE_SYMBOL_MAX_S ")", length); + } + /* Start character */ - memcpy(d, TeleTable['_'], 12); + memcpy(d, TeleTable[asc_comp_num ? 0x82 : 0x5F], 12); d += 12; - for (i = 0; i < length; i++) { - if (!z_isascii(source[i])) { + count = 0; + for (i = 0; i < asc_length; i++) { + const unsigned char ch = source[i]; + if (!z_isascii(ch)) { /* Cannot encode extended ASCII */ return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 391, "Invalid character at position %d in input, extended ASCII not allowed", i + 1); } - memcpy(d, TeleTable[source[i]], TeleLens[source[i]]); - d += TeleLens[source[i]]; - count += source[i]; + memcpy(d, TeleTable[ch], TeleLens[ch]); + d += TeleLens[ch]; + count += ch; + } + if (num_length) { + /* Compressed Numeric Mode tail */ + if ((i = z_not_sane(SODIUM_X_F, source + asc_length, num_length))) { + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 396, + "Invalid character at position %d in input (digits and \"X\" only)", asc_length + i); + } + + memcpy(local_source, source, asc_length - 1); /* Exclude DLE */ + /* Add a leading zero if required */ + if (num_length & 1) { + local_source[asc_length - 1] = '0'; /* Replaces DLE */ + memcpy(local_source + asc_length, source + asc_length, num_length++); + } else { + memcpy(local_source + asc_length - 1, source + asc_length, num_length); + length--; /* Less DLE */ + } + asc_length--; /* Less DLE */ + z_to_upper(local_source + asc_length, num_length); + + if (!(d = tele_num(symbol, local_source, length, asc_length, d, &count))) { + return ZINT_ERROR_INVALID_DATA; + } } check_digit = 127 - (count % 127); @@ -125,76 +230,110 @@ INTERNAL int zint_telepen(struct zint_symbol *symbol, unsigned char source[], in if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check digit: %d\n", check_digit); /* Stop character */ - memcpy(d, TeleTable['z'], 12); + memcpy(d, TeleTable[asc_comp_num ? 0x83 : 0x7A], 12); d += 12; z_expand(symbol, dest, (int) (d - dest)); - if (symbol->output_options & COMPLIANT_HEIGHT) { - /* Default height from various Telepen docs is based on default 26pt at X 0.01125" - (average of 0.01" - 0.0125") = (26 / 72) / 0.01125 ~ 32; no min height specified */ - (void) z_set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/); + error_number = tele_set_height(symbol, asc_length, num_length, have_dle); + + if (num_length) { + z_hrt_cpy_iso8859_1(symbol, local_source, length); /* `local_source` HRT-ready */ } else { - (void) z_set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/); + /* Chop off any trailing DLE if Full ASCII + Compressed Numeric mode */ + z_hrt_cpy_iso8859_1(symbol, source, length - (asc_comp_num && source[length - 1] == 0x10)); } - z_hrt_cpy_iso8859_1(symbol, source, length); - - if (content_segs && z_ct_cpy_cat(symbol, source, length, (char) check_digit, NULL /*cat*/, 0)) { - return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ + if (content_segs) { + if (asc_length < length) { + local_source[length++] = check_digit; + if (z_ct_cpy_cat(symbol, source, asc_length, '\x10' /*DLE*/, + local_source + asc_length, length - asc_length)) { + return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ + } + } else if (z_ct_cpy_cat(symbol, source, length, (char) check_digit, NULL /*cat*/, 0)) { + return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ + } } return error_number; } +/* Telepen Numeric (Compressed Numeric Mode) */ INTERNAL int zint_telepen_num(struct zint_symbol *symbol, unsigned char source[], int length) { - int count, check_digit, glyph; + int count, check_digit; int error_number = 0; int i; - char dest[1129]; /* 12 (Start) + 68 * 16 (max for DELs) + 16 (Check) + 12 (Stop) + 1 = 1129 */ + int symbol_chars = (length + 1) >> 1; + char dest[1145]; /* 12 (Start) + 69 * 16 (max for DELs) + 16 (Check) + 12 (stop) + 1 = 1145 */ char *d = dest; - unsigned char local_source[137]; + unsigned char local_source[136 + 1 + 1]; + int num_length = length, have_dle = 0; + const int comp_num_asc = symbol->option_2 == 1; /* AIM Compressed Numeric + Full ASCII mode */ const int content_segs = symbol->output_options & BARCODE_CONTENT_SEGS; - count = 0; - - if (length > 136) { /* 68*2 */ - return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 392, "Input length %d too long (maximum 136)", length); + /* Check for DLE (Full ASCII tail) whether AIM mode or not */ + if (length <= TELE_LENGTH_MAX) { /* Max possible is 138 digits */ + for (i = 0; i < length; i++) { + if (source[i] == 0x10 /*DLE*/) { + if (i == 0) { + return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 398, + "DLE (ASCII 16) cannot be first character in Compressed Numeric Mode"); + } + num_length = i; /* DLE not counted */ + symbol_chars = length - num_length + ((num_length + 1) >> 1); + have_dle = 1; + break; + } + } } - if ((i = z_not_sane(SODIUM_X_F, source, length))) { + + if (symbol_chars > TELE_SYMBOL_MAX) { + if (length <= TELE_LENGTH_MAX) { + return ZEXT z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 392, + "Input length %1$d too long, requires %2$d symbol characters (maximum " + TELE_SYMBOL_MAX_S ")", length, symbol_chars); + } + return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 400, + "Input length %d too long, requires too many symbol characters (maximum " + TELE_SYMBOL_MAX_S ")", length); + } + + if ((i = z_not_sane(SODIUM_X_F, source, num_length))) { return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 393, "Invalid character at position %d in input (digits and \"X\" only)", i); } /* Add a leading zero if required */ - if (length & 1) { + if (num_length & 1) { memcpy(local_source + 1, source, length++); local_source[0] = '0'; + num_length++; } else { memcpy(local_source, source, length); } - z_to_upper(local_source, length); + z_to_upper(local_source, num_length); /* Start character */ - memcpy(d, TeleTable['_'], 12); + memcpy(d, TeleTable[comp_num_asc ? 0x80 : 0x5F], 12); d += 12; - for (i = 0; i < length; i += 2) { - if (local_source[i] == 'X') { - return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 394, "Invalid odd position %d of \"X\" in Telepen data", - i + 1); + count = 0; + if (!(d = tele_num(symbol, local_source, num_length, 0 /*i*/, d, &count))) { + return ZINT_ERROR_INVALID_DATA; + } + for (i = num_length; i < length; i++) { + /* Full ASCII tail */ + const unsigned char ch = local_source[i]; + assert(i > num_length || ch == '\x10'); /* 1st char DLE */ + if (!z_isascii(ch)) { + /* Cannot encode extended ASCII */ + return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 395, + "Invalid character at position %d in input, extended ASCII not allowed", i + 1); } - - if (local_source[i + 1] == 'X') { - glyph = z_ctoi(local_source[i]) + 17; - count += glyph; - } else { - glyph = 10 * z_ctoi(local_source[i]) + z_ctoi(local_source[i + 1]); - glyph += 27; - count += glyph; - } - memcpy(d, TeleTable[glyph], TeleLens[glyph]); - d += TeleLens[glyph]; + memcpy(d, TeleTable[ch], TeleLens[ch]); + d += TeleLens[ch]; + count += ch; } check_digit = 127 - (count % 127); @@ -207,21 +346,31 @@ INTERNAL int zint_telepen_num(struct zint_symbol *symbol, unsigned char source[] if (symbol->debug & ZINT_DEBUG_PRINT) printf("Check digit: %d\n", check_digit); /* Stop character */ - memcpy(d, TeleTable['z'], 12); + memcpy(d, TeleTable[comp_num_asc ? 0x81 : 0x7A], 12); d += 12; z_expand(symbol, dest, (int) (d - dest)); - if (symbol->output_options & COMPLIANT_HEIGHT) { - (void) z_set_height(symbol, 0.0f, 32.0f, 0, 1 /*no_errtxt*/); /* Same as alphanumeric Telepen */ + error_number = tele_set_height(symbol, length - num_length /*asc_length*/, num_length, have_dle); + + if (num_length < length) { + /* Omit DLE */ + z_hrt_cpy_cat_nochk(symbol, local_source, num_length, '\xFF' /*separator (none)*/, + local_source + num_length + 1, length - (num_length + 1)); } else { - (void) z_set_height(symbol, 0.0f, 50.0f, 0, 1 /*no_errtxt*/); + z_hrt_cpy_nochk(symbol, local_source, length); } - z_hrt_cpy_nochk(symbol, local_source, length); - - if (content_segs && z_ct_cpy_cat(symbol, local_source, length, (char) check_digit, NULL /*cat*/, 0)) { - return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ + if (content_segs) { + if (num_length < length) { + local_source[length++] = check_digit; + if (z_ct_cpy_cat(symbol, local_source, num_length, '\xFF' /*separator (none)*/, + local_source + num_length, length - num_length)) { + return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ + } + } else if (z_ct_cpy_cat(symbol, local_source, length, (char) check_digit, NULL /*cat*/, 0)) { + return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */ + } } return error_number; diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 8af660f5..0d91f9d4 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -256,7 +256,7 @@ static void test_checks(const testCtx *const p_ctx) { symbol->warn_level = data[i].warn_level; } - ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); + ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt); @@ -298,18 +298,18 @@ static void test_checks_segs(const testCtx *const p_ctx) { /* 0*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 0, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 205: No input data" }, /* 1*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 257, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 771: Too many input segments (maximum 256)" }, /* 2*/ { BARCODE_CODE128, -1, { { NULL, 0, 0 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 772: Input segment 0 source NULL" }, - /* 3*/ { BARCODE_CODE128, -1, { { TU(""), 0, 0 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 778: No input data" }, - /* 4*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 0 }, { NULL, 0, 0 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 772: Input segment 1 source NULL" }, - /* 5*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 0 }, { TU(""), 0, 0 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 773: Input segment 1 empty" }, - /* 6*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 0 } }, 2, -1, 4, -1, ZINT_ERROR_INVALID_OPTION, "Error 774: Symbol ECI '4' must match segment zero ECI '3'" }, - /* 7*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 775: Symbology does not support multiple segments" }, - /* 8*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching" }, - /* 9*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 1 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1' out of range (0 to 999999, excluding 1, 2, 14 and 19)" }, - /* 10*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, GS1_MODE, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 776: GS1 mode not supported for multiple segments" }, - /* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input" }, - /* 12*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, -1, -1, -1, 0, "" }, - /* 13*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 0 }, { TU("B"), 0, 4 } }, 2, -1, 3, -1, 0, "" }, - /* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 214: Input too long" }, + /* 3*/ { BARCODE_CODE128, -1, { { ZUCP(""), 0, 0 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 778: No input data" }, + /* 4*/ { BARCODE_CODE128, -1, { { ZUCP("A"), 0, 0 }, { NULL, 0, 0 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 772: Input segment 1 source NULL" }, + /* 5*/ { BARCODE_CODE128, -1, { { ZUCP("A"), 0, 0 }, { ZUCP(""), 0, 0 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 773: Input segment 1 empty" }, + /* 6*/ { BARCODE_CODE128, -1, { { ZUCP("A"), 0, 3 }, { ZUCP("B"), 0, 0 } }, 2, -1, 4, -1, ZINT_ERROR_INVALID_OPTION, "Error 774: Symbol ECI '4' must match segment zero ECI '3'" }, + /* 7*/ { BARCODE_CODE128, -1, { { ZUCP("A"), 0, 3 }, { ZUCP("B"), 0, 4 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 775: Symbology does not support multiple segments" }, + /* 8*/ { BARCODE_CODE128, -1, { { ZUCP("A"), 0, 3 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching" }, + /* 9*/ { BARCODE_AZTEC, -1, { { ZUCP("A"), 0, 3 }, { ZUCP("B"), 0, 1 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1' out of range (0 to 999999, excluding 1, 2, 14 and 19)" }, + /* 10*/ { BARCODE_AZTEC, -1, { { ZUCP("A"), 0, 3 }, { ZUCP("B"), 0, 4 } }, 2, GS1_MODE, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 776: GS1 mode not supported for multiple segments" }, + /* 11*/ { BARCODE_AZTEC, -1, { { ZUCP("A"), 0, 3 }, { ZUCP("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input" }, + /* 12*/ { BARCODE_AZTEC, -1, { { ZUCP("A"), 0, 3 }, { ZUCP("B"), 0, 4 } }, 2, -1, -1, -1, 0, "" }, + /* 13*/ { BARCODE_AZTEC, -1, { { ZUCP("A"), 0, 0 }, { ZUCP("B"), 0, 4 } }, 2, -1, 3, -1, 0, "" }, + /* 14*/ { BARCODE_AZTEC, -1, { { ZUCP("A"), ZINT_MAX_DATA_LEN, 3 }, { ZUCP("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 214: Input too long" }, }; const int data_size = ARRAY_SIZE(data); int i, ret; @@ -393,7 +393,7 @@ static void test_input_data(const testCtx *const p_ctx) { -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, text, -1, debug); - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode(%d) ret %d != %d (%s)\n", i, data[i].symbology, ret, data[i].ret, symbol->errtxt); @@ -579,7 +579,7 @@ static void test_symbologies(const testCtx *const p_ctx) { if (testContinue(p_ctx, i)) continue; symbol->symbology = i; - ret = ZBarcode_Encode(symbol, TCU(""), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(""), 0); assert_notequal(ret, ZINT_ERROR_ENCODING_PROBLEM, "i:%d Encoding problem (%s)\n", i, symbol->errtxt); if (!ZBarcode_ValidID(i)) { @@ -654,7 +654,7 @@ static void test_input_mode(const testCtx *const p_ctx) { -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, data[i].data, -1, debug); - ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); + ret = ZBarcode_Encode(symbol, ZCUCP(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->input_mode, data[i].expected_input_mode, "i:%d symbol->input_mode %d != %d\n", @@ -684,115 +684,146 @@ static void test_escape_char_process(const testCtx *const p_ctx) { const char *comment; }; static const struct item data[] = { - /* 0*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 26, "01 05 08 09 0A 0B 0C 0D 0E 1C 1E 1F EB 02 5D 81 21 0D 92 2E 3D FD B6 9A 37 2A CD 61 FB 95", 0, "" }, - /* 1*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 101, "(45) 67 62 43 40 44 47 48 29 6A 67 62 0B 49 4A 4B 4C 18 6A 67 62 0C 4D 5B 5D 5E 62 6A 67", 0, "" }, - /* 2*/ { BARCODE_CODE16K, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 70, "(20) 14 64 68 71 72 73 74 75 76 77 91 93 94 101 65 60 103 103 45 61", 0, "" }, - /* 3*/ { BARCODE_DOTCODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 28, "65 40 44 47 48 49 4A 4B 4C 4D 5B 5D 5E 6E 41 3C 6A", 0, "" }, - /* 4*/ { BARCODE_GRIDMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 30, "30 1A 00 02 01 61 00 48 28 16 0C 06 46 63 51 74 05 38 00", 0, "" }, - /* 5*/ { BARCODE_HANXIN, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 23, "2F 80 10 72 09 28 B3 0D 6F F3 00 20 E8 F4 0A E0 00", 0, "" }, - /* 6*/ { BARCODE_MAXICODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 30, "(144) 04 3E 3E 00 04 07 08 09 0A 0B 03 3D 2C 24 19 1E 23 1B 18 0E 0C 0D 1E 3F 1D 1E 3C 31", 0, "" }, - /* 7*/ { BARCODE_PDF417, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 120, "(24) 16 901 0 23 655 318 98 18 461 639 893 122 129 92 900 900 872 438 359 646 522 773 831", 0, "" }, - /* 8*/ { BARCODE_ULTRA, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\", "", 0, 20, "(28) 257 17 262 228 6 273 193 226 91 24 283 4 0 4 7 8 9 10 11 12 13 27 29 30 129 92 284 7", 0, "" }, - /* 9*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\d129\\o201\\\\", "", 0, 18, "(32) 01 05 08 09 0A 0B 0C 0D 0E 1C 1E 1F E7 32 45 DB 70 5D E3 16 7B 2B 44 60 E1 55 F7 08", 0, "" }, - /* 10*/ { BARCODE_HANXIN, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\d129\\o201\\\\", "", 0, 23, "2F 80 10 72 09 28 B3 0D 6F F3 00 30 E8 F4 0C 0C 0A E0 00 00 00", 0, "" }, + /* 0*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 18, "(32) 01 05 08 09 0A 0B 0C 0D 0E 11 1C 1D 1E 1F 20 EB 02 5D EE 69 A6 C6 63 7C FC 73 CE F7", 0, "" }, + /* 1*/ { BARCODE_CODABLOCKF, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 101, "(54) 67 62 44 40 44 47 48 2B 6A 67 62 0B 49 4A 4B 4C 18 6A 67 62 0C 4D 50 5B 5C 20 6A 67", 0, "" }, + /* 2*/ { BARCODE_CODE16K, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 70, "(25) 21 64 68 71 72 73 74 75 76 77 80 91 92 93 94 95 101 65 60 103 103 103 103 38 59", 0, "" }, + /* 3*/ { BARCODE_DOTCODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 29, "65 40 44 47 48 49 4A 4B 4C 4D 50 5B 5C 5D 5E 5F 6E 41 3C", 0, "" }, + /* 4*/ { BARCODE_GRIDMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 30, "30 20 00 02 01 61 00 48 28 16 0C 06 44 03 31 60 74 3C 1F 40 57 00", 0, "" }, + /* 5*/ { BARCODE_HANXIN, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 23, "2F 80 10 72 09 28 B3 0D 41 BF CC 00 C3 83 A3 C3 F0 2B 80 00 00", 0, "" }, + /* 6*/ { BARCODE_MAXICODE, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 30, "(144) 04 3E 3E 00 04 07 08 09 0A 0B 03 3D 2C 24 19 1E 23 1B 18 0E 0C 0D 10 1E 20 21 22 23", 0, "" }, + /* 7*/ { BARCODE_PDF417, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 120, "(27) 19 901 0 23 655 318 98 18 461 639 91 512 29 30 31 129 92 900 900 114 476 670 717 35", 0, "" }, + /* 8*/ { BARCODE_ULTRA, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\", "", 0, 22, "(30) 257 20 227 30 152 79 176 10 152 27 283 4 0 4 7 8 9 10 11 12 13 16 27 28 29 30 31 129", 0, "" }, + /* 9*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\d129\\o201\\\\", "", 0, 20, "(40) 01 05 08 09 0A 0B 0C 0D 0E 11 1C 1D 1E 1F 20 E7 F2 06 9C 31 5D 81 AE E5 8D 14 8D 36", 0, "" }, + /* 10*/ { BARCODE_HANXIN, DATA_MODE, -1, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\d129\\o201\\\\", "", 0, 23, "2F 80 10 72 09 28 B3 0D 41 BF CC 01 03 83 A3 C3 F0 30 30 2B 80", 0, "" }, /* 11*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input", 0, "" }, - /* 12*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\", "", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input", 0, "" }, - /* 13*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input", 0, "" }, - /* 14*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input", 0, "" }, - /* 15*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1g", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\x1g' in input (hexadecimal only)", 0, "" }, - /* 16*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" }, - /* 17*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" }, - /* 18*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" }, - /* 19*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12a", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\d12a' in input (decimal only)", 0, "" }, - /* 20*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d256", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\d256' in input out of range (000 to 255)", 0, "" }, - /* 21*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" }, - /* 22*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" }, - /* 23*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" }, - /* 24*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o128", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\o128' in input (octal only)", 0, "" }, - /* 25*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o400", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\o400' in input out of range (000 to 377)", 0, "" }, - /* 26*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\xA01\\xFF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 0, "" }, - /* 27*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1601\\d255", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, - /* 28*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o2401\\o377", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, - /* 29*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u00A01\\u00FF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, - /* 30*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U0000A01\\U0000FF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, - /* 31*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\xc3\\xbF", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 0, "" }, - /* 32*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d195\\d191", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, - /* 33*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o303\\o277", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, - /* 34*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00fF", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, - /* 35*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000fF", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, - /* 36*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\xc3\\xbF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 0, "" }, - /* 37*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\d195\\d191", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, - /* 38*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\o303\\o277", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, - /* 39*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u00fF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, - /* 40*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U0000fF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, - /* 41*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, - /* 42*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, - /* 43*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, - /* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, - /* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, - /* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 211: Invalid character for '\\u' escape sequence in input (hexadecimal only)", 0, "" }, - /* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" }, - /* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" }, - /* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" }, - /* 50*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uffff", "", 0, 12, "E7 2C B0 16 AB A1 1F 85 EB 50 A1 4C", 0, "" }, - /* 51*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\xE2\\x82\\xAC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 0, "Zint manual 4.10 Ex1" }, - /* 52*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\u20AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" }, - /* 53*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\U0020AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" }, - /* 54*/ { BARCODE_DATAMATRIX, DATA_MODE, 17, "\\xA4", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" }, - /* 55*/ { BARCODE_DATAMATRIX, DATA_MODE, 28, "\\xB1\\x60", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 0, "Zint manual 4.10 Ex2" }, - /* 56*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 28, "\\u5E38", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 1, "" }, - /* 57*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 28, "\\U005E38", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 1, "" }, - /* 58*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u007F", "", 0, 10, "80 81 46 73 64 88 6A 84", 0, "" }, - /* 59*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U00007F", "", 0, 10, "80 81 46 73 64 88 6A 84", 0, "" }, - /* 60*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 61*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 62*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 63*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 64*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 65*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 66*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Reversed BOM" }, - /* 67*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" }, - /* 68*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" }, - /* 69*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 70*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, - /* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\U110000' in input out of range", 0, "" }, - /* 72*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 25, "\\U10FFFF", "", 0, 14, "F1 1A E7 57 C7 81 F7 AC 09 06 28 51 F3 00 E1 8C 2A 1C", 0, "" }, - /* 73*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, "\\U10FFFF", "", 0, 14, "F1 1B E7 57 E0 11 D7 6C 4F 45 E2 B3 FF F1 72 AB 54 9F", 0, "" }, - /* 74*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 32, "\\U10FFFF", "", 0, 14, "F1 21 EB 64 33 EB 1B 36 1D F7 B1 6D 8C A6 34 64 19 3A", 0, "" }, - /* 75*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 33, "\\U10FFFF", "", 0, 14, "F1 22 E7 57 EB 5D 17 8C C1 B0 B6 B2 53 78 E4 7D 61 CB", 0, "" }, - /* 76*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 34, "\\U10FFFF", "", 0, 14, "F1 23 01 11 EB 80 EB 80 90 33 51 1B FA AE 78 F7 05 44", 0, "" }, - /* 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, 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, "" }, + /* 12*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\g", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\g' in input", 0, "" }, + /* 13*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\h", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\h' in input", 0, "" }, + /* 14*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\i", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\i' in input", 0, "" }, + /* 15*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\j", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\j' in input", 0, "" }, + /* 16*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\k", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\k' in input", 0, "" }, + /* 17*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\l", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\l' in input", 0, "" }, + /* 18*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\m", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\m' in input", 0, "" }, + /* 19*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\p", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\p' in input", 0, "" }, + /* 20*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\q", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\q' in input", 0, "" }, + /* 21*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\s", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\s' in input", 0, "" }, + /* 22*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" }, + /* 23*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\y", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\y' in input", 0, "" }, + /* 24*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\z", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\z' in input", 0, "" }, + /* 25*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\A", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\A' in input", 0, "" }, + /* 26*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\B' in input", 0, "" }, + /* 27*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\C", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\C' in input", 0, "" }, + /* 28*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\D", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\D' in input", 0, "" }, + /* 29*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\H", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\H' in input", 0, "" }, + /* 30*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\I", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\I' in input", 0, "" }, + /* 31*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\J", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\J' in input", 0, "" }, + /* 32*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\K", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\K' in input", 0, "" }, + /* 33*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\M", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\M' in input", 0, "" }, + /* 34*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\O", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\O' in input", 0, "" }, + /* 35*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\P", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\P' in input", 0, "" }, + /* 36*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Q", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\Q' in input", 0, "" }, + /* 37*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\S", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\S' in input", 0, "" }, + /* 38*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\T", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\T' in input", 0, "" }, + /* 39*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\V", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\V' in input", 0, "" }, + /* 40*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\W", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\W' in input", 0, "" }, + /* 41*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\X", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\X' in input", 0, "" }, + /* 42*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Y", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\Y' in input", 0, "" }, + /* 43*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Z", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\Z' in input", 0, "" }, + /* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\", "", ZINT_ERROR_INVALID_DATA, 0, "Error 236: Incomplete escape character in input", 0, "" }, + /* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input", 0, "" }, + /* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\x' escape sequence in input", 0, "" }, + /* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\x1g", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\x1g' in input (hexadecimal only)", 0, "" }, + /* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" }, + /* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" }, + /* 50*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\d' escape sequence in input", 0, "" }, + /* 51*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d12a", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\d12a' in input (decimal only)", 0, "" }, + /* 52*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d256", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\d256' in input out of range (000 to 255)", 0, "" }, + /* 53*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" }, + /* 54*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" }, + /* 55*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o12", "", ZINT_ERROR_INVALID_DATA, 0, "Error 232: Incomplete '\\o' escape sequence in input", 0, "" }, + /* 56*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o128", "", ZINT_ERROR_INVALID_DATA, 0, "Error 238: Invalid character in escape sequence '\\o128' in input (octal only)", 0, "" }, + /* 57*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o400", "", ZINT_ERROR_INVALID_DATA, 0, "Error 237: Value of escape sequence '\\o400' in input out of range (000 to 377)", 0, "" }, + /* 58*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\xA01\\xFF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 0, "" }, + /* 59*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d1601\\d255", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, + /* 60*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o2401\\o377", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, + /* 61*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u00A01\\u00FF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, + /* 62*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U0000A01\\U0000FF", "", 0, 12, "EB 21 32 EB 80 D8 49 44 DC 7D 9E 3B", 1, "" }, + /* 63*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\xc3\\xbF", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 0, "" }, + /* 64*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\d195\\d191", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, + /* 65*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\o303\\o277", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, + /* 66*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00fF", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, + /* 67*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000fF", "", 0, 12, "EB 44 EB 40 81 30 87 17 C5 68 5C 91", 1, "" }, + /* 68*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\xc3\\xbF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 0, "" }, + /* 69*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\d195\\d191", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, + /* 70*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\o303\\o277", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, + /* 71*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u00fF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, + /* 72*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U0000fF", "", 0, 10, "EB 80 81 47 1E 45 FC 93", 1, "" }, + /* 73*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, + /* 74*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, + /* 75*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, + /* 76*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, + /* 77*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" }, + /* 78*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 211: Invalid character for '\\u' escape sequence in input (hexadecimal only)", 0, "" }, + /* 79*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" }, + /* 80*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" }, + /* 81*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" }, + /* 82*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uffff", "", 0, 12, "E7 2C B0 16 AB A1 1F 85 EB 50 A1 4C", 0, "" }, + /* 83*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\xE2\\x82\\xAC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 0, "Zint manual 4.10 Ex1" }, + /* 84*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\u20AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" }, + /* 85*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\U0020AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" }, + /* 86*/ { BARCODE_DATAMATRIX, DATA_MODE, 17, "\\xA4", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" }, + /* 87*/ { BARCODE_DATAMATRIX, DATA_MODE, 28, "\\xB1\\x60", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 0, "Zint manual 4.10 Ex2" }, + /* 88*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 28, "\\u5E38", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 1, "" }, + /* 89*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 28, "\\U005E38", "", 0, 12, "F1 1D EB 32 61 D9 1C 0C C2 46 C3 B2", 1, "" }, + /* 90*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\u007F", "", 0, 10, "80 81 46 73 64 88 6A 84", 0, "" }, + /* 91*/ { BARCODE_DATAMATRIX, UNICODE_MODE, -1, "\\U00007F", "", 0, 10, "80 81 46 73 64 88 6A 84", 0, "" }, + /* 92*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /* 93*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UF", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /* 94*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /* 95*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\UFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /* 96*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /* 97*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /* 98*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Reversed BOM" }, + /* 99*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" }, + /*100*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" }, + /*101*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /*102*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" }, + /*103*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\U110000' in input out of range", 0, "" }, + /*104*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 25, "\\U10FFFF", "", 0, 14, "F1 1A E7 57 C7 81 F7 AC 09 06 28 51 F3 00 E1 8C 2A 1C", 0, "" }, + /*105*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, "\\U10FFFF", "", 0, 14, "F1 1B E7 57 E0 11 D7 6C 4F 45 E2 B3 FF F1 72 AB 54 9F", 0, "" }, + /*106*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 32, "\\U10FFFF", "", 0, 14, "F1 21 EB 64 33 EB 1B 36 1D F7 B1 6D 8C A6 34 64 19 3A", 0, "" }, + /*107*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 33, "\\U10FFFF", "", 0, 14, "F1 22 E7 57 EB 5D 17 8C C1 B0 B6 B2 53 78 E4 7D 61 CB", 0, "" }, + /*108*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 34, "\\U10FFFF", "", 0, 14, "F1 23 01 11 EB 80 EB 80 90 33 51 1B FA AE 78 F7 05 44", 0, "" }, + /*109*/ { 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, "" }, + /*110*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[20]10", "[10]A", 0, 99, "(7) 105 102 20 10 100 59 106", 0, "" }, + /*111*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" }, + /*112*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*113*/ { BARCODE_AZTEC, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*114*/ { 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, "" }, + /*115*/ { 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" }, + /*116*/ { 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)" }, + /*117*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, + /*118*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*119*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*120*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" }, + /*121*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" }, + /*122*/ { 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" }, + /*123*/ { 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" }, + /*124*/ { 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)" }, + /*125*/ { 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" }, + /*126*/ { 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, "" }, + /*127*/ { 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, "" }, + /*128*/ { 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, "" }, + /*129*/ { 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, "" }, + /*130*/ { 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, "" }, + /*131*/ { 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, "" }, + /*132*/ { 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, "" }, + /*133*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" }, + /*134*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" }, + /*135*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" }, + /*136*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" }, + /*137*/ { BARCODE_CODE128, DATA_MODE, -1, "\\\\^A1", "", 0, 79, "(7) 104 60 62 33 17 43 106", 0, "Treated as literal backslash caret A" }, + /*138*/ { 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)" }, + /*139*/ { 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; @@ -827,7 +858,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) { -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, text, -1, debug); - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); @@ -911,7 +942,7 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) { }; static const struct item data[] = { /* 0*/ { 0, 0, "BLANK", 0, "BLANK", 5 }, - /* 1*/ { 0, 0, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\e\\G\\R\\x81\\\\\\o201\\d255", 0, "\000\004\a\b\t\n\v\f\r\033\035\036\201\\\201\377", 16 }, + /* 1*/ { 0, 0, "\\0\\E\\a\\b\\t\\n\\v\\f\\r\\L\\e\\F\\G\\R\\N\\x81\\\\\\o201\\d255", 0, "\000\004\a\b\t\n\v\f\r\020\033\034\035\036\037\201\\\201\377", 19 }, /* 2*/ { 0, 0, "\\U010283", 0, "\360\220\212\203", 4 }, /* 3*/ { 0, 0, "\\u007F\\u0080\\u011E\\u13C9\\U010283", 0, "\177\302\200\304\236\341\217\211\360\220\212\203", 12 }, /* 4*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, "\\^A\\^^\\^B", 0, "\\^A\\^^\\^B", 9 }, @@ -1249,7 +1280,7 @@ static void test_cap_stackable(const testCtx *const p_ctx) { -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/, text, -1, debug); - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_zero(ret, "i:%d ZBarcode_Encode prestacked ret %d != 0 %s\n", i, ret, symbol->errtxt); prestacked_rows = symbol->rows; @@ -1259,7 +1290,7 @@ static void test_cap_stackable(const testCtx *const p_ctx) { symbol->option_1 = -1; symbol->option_2 = symbol->option_3 = 0; - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_zero(ret, "i:%d ZBarcode_Encode stacked ret %d != 0 %s\n", i, ret, symbol->errtxt); stacked_rows = symbol->rows; @@ -1328,14 +1359,14 @@ static void test_bindable(const testCtx *const p_ctx) { text, -1, debug); if (stackable) { - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_zero(ret, "i:%d ZBarcode_Encode prebind ret %d != 0 %s\n", i, ret, symbol->errtxt); symbol->option_1 = -1; symbol->option_2 = 0; symbol->option_3 = option_3; } - ret = ZBarcode_Encode_and_Print(symbol, TCU(text), length, 0 /*rotate*/); + ret = ZBarcode_Encode_and_Print(symbol, ZCUCP(text), length, 0 /*rotate*/); assert_zero(ret, "i:%d ZBarcode_Encode_and_Print prebind ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_nonzero(symbol->memfile_size, "i:%d prebind memfile_size zero\n", i); @@ -1361,14 +1392,14 @@ static void test_bindable(const testCtx *const p_ctx) { text, -1, debug); if (stackable) { - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_zero(ret, "i:%d ZBarcode_Encode bind ret %d != 0 %s\n", i, ret, symbol->errtxt); symbol->option_1 = -1; symbol->option_2 = 0; symbol->option_3 = option_3; } - ret = ZBarcode_Encode_and_Print(symbol, TCU(text), length, 0 /*rotate*/); + ret = ZBarcode_Encode_and_Print(symbol, ZCUCP(text), length, 0 /*rotate*/); assert_zero(ret, "i:%d ZBarcode_Encode_and_Print bind ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_nonzero(symbol->memfile_size, "i:%d bind memfile_size zero\n", i); @@ -1645,7 +1676,7 @@ static void test_encode_print_outfile_directory(const testCtx *const p_ctx) { assert_zero(ret, "testUtilMkDir(%s) %d != 0 (%d: %s)\n", dirname, ret, errno, strerror(errno)); strcpy(symbol->outfile, dirname); - ret = ZBarcode_Encode_and_Print(symbol, TCU("1"), 0, 0); + ret = ZBarcode_Encode_and_Print(symbol, ZCUCP("1"), 0, 0); assert_equal(ret, ZINT_ERROR_FILE_ACCESS, "ret %d != ZINT_ERROR_FILE_ACCESS (%s)\n", ret, symbol->errtxt); assert_zero(strncmp(symbol->errtxt, expected, sizeof(expected) - 1), "strncmp(%s, %s) != 0\n", symbol->errtxt, expected); @@ -1665,9 +1696,9 @@ static void test_bad_args(const testCtx *const p_ctx) { const char *data = "1"; const char *filename = "1.png"; const char *empty = ""; - struct zint_seg seg = { TU("1"), -1, 4 }; - struct zint_seg seg_empty = { TU(""), -1, 4 }; - struct zint_seg seg_too_long = { TU("1"), ZINT_MAX_DATA_LEN + 1, 4 }; + struct zint_seg seg = { ZUCP("1"), -1, 4 }; + struct zint_seg seg_empty = { ZUCP(""), -1, 4 }; + struct zint_seg seg_too_long = { ZUCP("1"), ZINT_MAX_DATA_LEN + 1, 4 }; const char *expected[] = { "Error 772: Input segment 0 source NULL", "Error 200: Input segments NULL", @@ -1701,7 +1732,7 @@ static void test_bad_args(const testCtx *const p_ctx) { assert_zero(uret, "ZBarcode_Cap(17, ~0) uret 0x%X != 0\n", uret); /* NULL symbol */ - assert_equal(ZBarcode_Encode(NULL, TCU(data), 1), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode(NULL, ZCUCP(data), 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(NULL, data, 1) != ZINT_ERROR_INVALID_DATA\n"); assert_equal(ZBarcode_Encode_Segs(NULL, &seg, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(NULL, &seg, 1) != ZINT_ERROR_INVALID_DATA\n"); @@ -1711,15 +1742,15 @@ static void test_bad_args(const testCtx *const p_ctx) { "ZBarcode_Buffer(NULL, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_equal(ZBarcode_Buffer_Vector(NULL, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Buffer_Vector(NULL, 0) != ZINT_ERROR_INVALID_DATA\n"); - assert_equal(ZBarcode_Encode_and_Print(NULL, TCU(data), 1, 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode_and_Print(NULL, ZCUCP(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_equal(ZBarcode_Encode_Segs_and_Print(NULL, &seg, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Seg_and_Print(NULL, &seg, 1, 0) != ZINT_ERROR_INVALID_DATA\n"); - assert_equal(ZBarcode_Encode_and_Buffer(NULL, TCU(data), 1, 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode_and_Buffer(NULL, ZCUCP(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_equal(ZBarcode_Encode_Segs_and_Buffer(NULL, &seg, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer(NULL, &seg, 1, 0) != ZINT_ERROR_INVALID_DATA\n"); - assert_equal(ZBarcode_Encode_and_Buffer_Vector(NULL, TCU(data), 1, 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode_and_Buffer_Vector(NULL, ZCUCP(data), 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(NULL, data, 1, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_equal(ZBarcode_Encode_Segs_and_Buffer_Vector(NULL, &seg, 1, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs_and_Buffer_Vector(NULL, &seg, 1, 0) != ZINT_ERROR_INVALID_DATA\n"); @@ -1797,26 +1828,26 @@ static void test_bad_args(const testCtx *const p_ctx) { /* Empty data/segs/filename */ symbol->errtxt[0] = '\0'; - assert_equal(ZBarcode_Encode(symbol, TCU(empty), 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode(symbol, ZCUCP(empty), 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode(symbol, empty, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_zero(strcmp(expected[3], symbol->errtxt), - "ZBarcode_Encode(symbol, TCU(empty), 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); + "ZBarcode_Encode(symbol, ZCUCP(empty), 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_Segs(symbol, &seg_empty, 1), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) != ZINT_ERROR_INVALID_DATA\n"); assert_zero(strcmp(expected[3], symbol->errtxt), "ZBarcode_Encode_Segs(symbol, &seg_empty, 1) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); symbol->errtxt[0] = '\0'; - assert_equal(ZBarcode_Encode_and_Print(symbol, TCU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode_and_Print(symbol, ZCUCP(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Print(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_zero(strcmp(expected[3], symbol->errtxt), - "ZBarcode_Encode_and_Print(symbol, TCU(empty), 0, 0) strcmp(%s, %s) != 0\n", + "ZBarcode_Encode_and_Print(symbol, ZCUCP(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); symbol->errtxt[0] = '\0'; - assert_equal(ZBarcode_Encode_and_Buffer(symbol, TCU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode_and_Buffer(symbol, ZCUCP(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_zero(strcmp(expected[3], symbol->errtxt), - "ZBarcode_Encode_and_Buffer(symbol, TCU(empty), 0, 0) strcmp(%s, %s) != 0\n", + "ZBarcode_Encode_and_Buffer(symbol, ZCUCP(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0), ZINT_ERROR_INVALID_DATA, @@ -1825,10 +1856,10 @@ static void test_bad_args(const testCtx *const p_ctx) { "ZBarcode_Encode_Segs_and_Buffer(symbol, &seg_empty, 1, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); symbol->errtxt[0] = '\0'; - assert_equal(ZBarcode_Encode_and_Buffer_Vector(symbol, TCU(empty), 0, 0), ZINT_ERROR_INVALID_DATA, + assert_equal(ZBarcode_Encode_and_Buffer_Vector(symbol, ZCUCP(empty), 0, 0), ZINT_ERROR_INVALID_DATA, "ZBarcode_Encode_and_Buffer_Vector(symbol, empty, 0, 0) != ZINT_ERROR_INVALID_DATA\n"); assert_zero(strcmp(expected[3], symbol->errtxt), - "ZBarcode_Encode_and_Buffer_Vector(symbol, TCU(empty), 0, 0) strcmp(%s, %s) != 0\n", + "ZBarcode_Encode_and_Buffer_Vector(symbol, ZCUCP(empty), 0, 0) strcmp(%s, %s) != 0\n", expected[3], symbol->errtxt); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_Segs_and_Buffer_Vector(symbol, &seg_empty, 1, 0), ZINT_ERROR_INVALID_DATA, @@ -1881,10 +1912,10 @@ static void test_bad_args(const testCtx *const p_ctx) { /* Data/seg too big */ symbol->errtxt[0] = '\0'; - assert_equal(ZBarcode_Encode(symbol, TCU(empty), ZINT_MAX_DATA_LEN + 1), ZINT_ERROR_TOO_LONG, + assert_equal(ZBarcode_Encode(symbol, ZCUCP(empty), ZINT_MAX_DATA_LEN + 1), ZINT_ERROR_TOO_LONG, "ZBarcode_Encode(symbol, empty, ZINT_MAX_DATA_LEN + 1) != ZINT_ERROR_TOO_LONG\n"); assert_zero(strcmp(expected[7], symbol->errtxt), - "ZBarcode_Encode(symbol, TCU(empty), ZINT_MAX_DATA_LEN + 1) strcmp(%s, %s) != 0\n", + "ZBarcode_Encode(symbol, ZCUCP(empty), ZINT_MAX_DATA_LEN + 1) strcmp(%s, %s) != 0\n", expected[7], symbol->errtxt); symbol->errtxt[0] = '\0'; assert_equal(ZBarcode_Encode_Segs(symbol, &seg_too_long, 1), ZINT_ERROR_TOO_LONG, @@ -1913,10 +1944,10 @@ static void test_stacking(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); for (i = 0; i < ARRAY_SIZE(symbol->row_height); i++) { - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", i, data, ret, symbol->errtxt); } - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_equal(ret, ZINT_ERROR_TOO_LONG, "i:%d ZBarcode_Encode ret %d != ZINT_ERROR_TOO_LONG (%s)\n", i, ret, symbol->errtxt); assert_zero(strcmp(symbol->errtxt, expected_error), "i:%d strcmp(%s, %s) != 0\n", @@ -1924,11 +1955,11 @@ static void test_stacking(const testCtx *const p_ctx) { ZBarcode_Clear(symbol); - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "i:%d ZBarcode_Encode(%s) ret %d != 0 (%s)\n", i, data, ret, symbol->errtxt); symbol->output_options |= BARCODE_CONTENT_SEGS; - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_equal(ret, ZINT_ERROR_INVALID_OPTION, "i:%d ZBarcode_Encode ret %d != ZINT_ERROR_INVALID_OPTION (%s)\n", i, ret, symbol->errtxt); assert_zero(strcmp(symbol->errtxt, expected_error_content), "i:%d strcmp(%s, %s) != 0\n", @@ -2254,7 +2285,7 @@ static void test_strip_bom(const testCtx *const p_ctx) { strcpy(buf, data); length = (int) strlen(buf); - zint_test_strip_bom(TU(buf), &length); + zint_test_strip_bom(ZUCP(buf), &length); assert_equal(length, 1, "length %d != 1\n", length); assert_zero(buf[1], "buf[1] %d != 0\n", buf[1]); @@ -2262,7 +2293,7 @@ static void test_strip_bom(const testCtx *const p_ctx) { strcpy(buf, bom_only); length = (int) strlen(buf); - zint_test_strip_bom(TU(buf), &length); + zint_test_strip_bom(ZUCP(buf), &length); assert_equal(length, 3, "BOM only length %d != 3\n", length); ret = strcmp(buf, bom_only); assert_zero(ret, "BOM only strcmp ret %d != 0\n", ret); @@ -2286,7 +2317,7 @@ static void test_zero_outfile(const testCtx *const p_ctx) { assert_nonzero(symbol->outfile[0], "ZBarcode_Create() outfile zero\n"); symbol->outfile[0] = '\0'; - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "ZBarcode_Encode(%s) ret %d != 0 (%s)\n", data, ret, symbol->errtxt); assert_zero(symbol->outfile[0], "ZBarcode_Encode() outfile non-zero\n"); @@ -2327,7 +2358,7 @@ static void test_clear(const testCtx *const p_ctx) { /* Raster */ - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt); assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n"); @@ -2358,7 +2389,7 @@ static void test_clear(const testCtx *const p_ctx) { /* Vector */ - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt); assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n"); @@ -2444,7 +2475,7 @@ static void test_reset(const testCtx *const p_ctx) { /* Raster */ - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt); assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n"); @@ -2501,7 +2532,7 @@ static void test_reset(const testCtx *const p_ctx) { set_symbol_fields(symbol); - ret = ZBarcode_Encode(symbol, TCU(data), 0); + ret = ZBarcode_Encode(symbol, ZCUCP(data), 0); assert_zero(ret, "ZBarcode_Encode() ret %d != 0 (%s)\n", ret, symbol->errtxt); assert_nonzero(symbol->rows, "ZBarcode_Encode() rows 0\n"); @@ -2858,7 +2889,7 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) { length = data[i].length == -1 && data[i].data ? (int) strlen(data[i].data) : data[i].length; - ret_dest = ZBarcode_Dest_Len_ECI(data[i].eci, TCU(data[i].data), length, &dest_length); + ret_dest = ZBarcode_Dest_Len_ECI(data[i].eci, ZCUCP(data[i].data), length, &dest_length); assert_equal(ret_dest, data[i].ret_dest, "i:%d ZBarcode_Dest_Len_ECI(%d, %s) ret_dest %d != %d\n", i, data[i].eci, data[i].data, ret_dest, data[i].ret_dest); @@ -2868,7 +2899,7 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) { i, dest_length, data[i].expected_dest_length); expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; - ret = ZBarcode_UTF8_To_ECI(data[i].eci, TCU(data[i].data), length, dest, &dest_length); + ret = ZBarcode_UTF8_To_ECI(data[i].eci, ZCUCP(data[i].data), length, dest, &dest_length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_UTF8_To_ECI(%d, %s) ret %d != %d\n", i, data[i].eci, data[i].data, ret, data[i].ret); if (ret < ZINT_ERROR) { @@ -2876,7 +2907,7 @@ static void test_utf8_to_eci(const testCtx *const p_ctx) { "i:%d ZBarcode_UTF8_To_ECI dest_length %d != expected_length %d\n", i, dest_length, expected_length); #if 0 - printf("dest_length %d\n", dest_length); z_debug_print_escape(TCU(dest), dest_length, NULL); + printf("dest_length %d\n", dest_length); z_debug_print_escape(ZCUCP(dest), dest_length, NULL); printf("\n"); #endif assert_zero(memcmp(dest, data[i].expected, expected_length), @@ -3046,7 +3077,7 @@ static void test_content_segs(const testCtx *const p_ctx) { expected = data[i].expected[0] ? data[i].expected : data[i].data; expected_length = (int) strlen(expected); - ret = ZBarcode_Encode(symbol, TCU(text), length); + ret = ZBarcode_Encode(symbol, ZCUCP(text), length); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i); diff --git a/backend/tests/test_raster.c b/backend/tests/test_raster.c index a6da2f30..3d373aa1 100644 --- a/backend/tests/test_raster.c +++ b/backend/tests/test_raster.c @@ -2545,9 +2545,9 @@ static void test_height(const testCtx *const p_ctx) { /*110*/ { BARCODE_DBAR_EXP, -1, 33, "[01]12345678901231", "", 0, 33, 1, 134, 268, 66, "", "" }, /*111*/ { BARCODE_DBAR_EXP, COMPLIANT_HEIGHT, 33, "[01]12345678901231", "", ZINT_WARN_NONCOMPLIANT, 33, 1, 134, 268, 66, "Warning 247: Height not compliant with standards (too small)", "" }, /*112*/ { BARCODE_DBAR_EXP, COMPLIANT_HEIGHT, 34, "[01]12345678901231", "", 0, 34, 1, 134, 268, 68, "", "" }, - /*113*/ { BARCODE_TELEPEN, -1, 1, "1234567890", "", 0, 1, 1, 208, 416, 2, "", "" }, - /*114*/ { BARCODE_TELEPEN, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 208, 416, 2, "", "No known min" }, - /*115*/ { BARCODE_TELEPEN, -1, 4, "1234567890", "", 0, 4, 1, 208, 416, 8, "", "" }, + /*113*/ { BARCODE_TELEPEN, -1, 8.9, "1234567890", "", 0, 9, 1, 208, 416, 18, "", "" }, + /*114*/ { BARCODE_TELEPEN, COMPLIANT_HEIGHT, 8.9, "1234567890", "", ZINT_WARN_NONCOMPLIANT, 9, 1, 208, 416, 18, "Warning 247: Height not compliant with standards (too small)", "" }, + /*115*/ { BARCODE_TELEPEN, COMPLIANT_HEIGHT, 9, "1234567890", "", 0, 9, 1, 208, 416, 18, "", "" }, /*116*/ { BARCODE_UPCA, -1, 1, "12345678901", "", 0, 1, 1, 95, 226, 12, "", "" }, /*117*/ { BARCODE_UPCA, -1, 69, "12345678901", "", 0, 69, 1, 95, 226, 148, "", "" }, /*118*/ { BARCODE_UPCA, COMPLIANT_HEIGHT, 69, "12345678901", "", ZINT_WARN_NONCOMPLIANT, 69, 1, 95, 226, 148, "Warning 247: Height not compliant with standards (too small)", "" }, @@ -2764,9 +2764,9 @@ static void test_height(const testCtx *const p_ctx) { /*329*/ { BARCODE_PLESSEY, -1, 1, "1234567890", "", 0, 1, 1, 227, 454, 2, "", "" }, /*330*/ { BARCODE_PLESSEY, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 227, 454, 2, "", "TODO: Find doc" }, /*331*/ { BARCODE_PLESSEY, -1, 4, "1234567890", "", 0, 4, 1, 227, 454, 8, "", "" }, - /*332*/ { BARCODE_TELEPEN_NUM, -1, 1, "1234567890", "", 0, 1, 1, 128, 256, 2, "", "" }, - /*333*/ { BARCODE_TELEPEN_NUM, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 128, 256, 2, "", "No known min" }, - /*334*/ { BARCODE_TELEPEN_NUM, -1, 4, "1234567890", "", 0, 4, 1, 128, 256, 8, "", "" }, + /*332*/ { BARCODE_TELEPEN_NUM, -1, 6.6, "1234567890", "", 0, 6.5, 1, 128, 256, 13, "", "" }, + /*333*/ { BARCODE_TELEPEN_NUM, COMPLIANT_HEIGHT, 6.6, "1234567890", "", ZINT_WARN_NONCOMPLIANT, 6.5, 1, 128, 256, 13, "Warning 247: Height not compliant with standards (too small)", "" }, + /*334*/ { BARCODE_TELEPEN_NUM, COMPLIANT_HEIGHT, 6.7, "1234567890", "", 0, 6.5, 1, 128, 256, 13, "", "" }, /*335*/ { BARCODE_ITF14, -1, 1, "1234567890", "", 0, 1, 1, 135, 330, 22, "", "" }, /*336*/ { BARCODE_ITF14, -1, 5.7, "1234567890", "", 0, 5.5, 1, 135, 330, 31, "", "" }, /*337*/ { BARCODE_ITF14, COMPLIANT_HEIGHT, 5.7, "1234567890", "", ZINT_WARN_NONCOMPLIANT, 5.5, 1, 135, 330, 31, "Warning 247: Height not compliant with standards (too small)", "" }, diff --git a/backend/tests/test_telepen.c b/backend/tests/test_telepen.c index 59684174..9889d860 100644 --- a/backend/tests/test_telepen.c +++ b/backend/tests/test_telepen.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2025 Robin Stuart + Copyright (C) 2020-2026 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -36,6 +36,7 @@ static void test_large(const testCtx *const p_ctx) { struct item { int symbology; + int option_2; const char *pattern; int length; int ret; @@ -45,10 +46,40 @@ static void test_large(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_TELEPEN, "\177", 69, 0, 1, 1152, "" }, - /* 1*/ { BARCODE_TELEPEN, "\177", 70, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 70 too long (maximum 69)" }, - /* 2*/ { BARCODE_TELEPEN_NUM, "1", 136, 0, 1, 1136, "" }, - /* 3*/ { BARCODE_TELEPEN_NUM, "1", 137, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 137 too long (maximum 136)" }, + /* 0*/ { BARCODE_TELEPEN, -1, "\177", 69, 0, 1, 1152, "" }, + /* 1*/ { BARCODE_TELEPEN, -1, "\177", 70, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 70 too long, requires 70 symbol characters (maximum 69)" }, + /* 2*/ { BARCODE_TELEPEN, 1, "\177", 69, 0, 1, 1152, "" }, + /* 3*/ { BARCODE_TELEPEN, 1, "\177", 70, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 70 too long, requires 70 symbol characters (maximum 69)" }, + /* 4*/ { BARCODE_TELEPEN, 1, "\177", 136, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 136 too long, requires 136 symbol characters (maximum 69)" }, + /* 5*/ { BARCODE_TELEPEN, 1, "\177", 137, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 137 too long, requires 137 symbol characters (maximum 69)" }, + /* 6*/ { BARCODE_TELEPEN, 1, "\177", 200, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 200 too long, requires 200 symbol characters (maximum 69)" }, + /* 7*/ { BARCODE_TELEPEN, 1, "\177", 201, ZINT_ERROR_TOO_LONG, -1, -1, "Error 399: Input length 201 too long, requires too many symbol characters (maximum 69)" }, + /* 8*/ { BARCODE_TELEPEN, -1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\020", 69, 0, 1, 1152, "" }, + /* 9*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\020", 69, 0, 1, 1152, "" }, + /* 10*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\0201", 69, 0, 1, 1152, "" }, + /* 11*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\02012", 70, 0, 1, 1152, "" }, + /* 12*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\020123", 71, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 71 too long, requires 70 symbol characters (maximum 69)" }, + /* 13*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\0201234", 72, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 72 too long, requires 70 symbol characters (maximum 69)" }, + /* 14*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\0201234", 71, 0, 1, 1152, "" }, + /* 15*/ { BARCODE_TELEPEN, 1, "\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\177\02012345", 72, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 72 too long, requires 70 symbol characters (maximum 69)" }, + /* 16*/ { BARCODE_TELEPEN, 1, "\177\02012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234", 136, 0, 1, 1152, "" }, + /* 17*/ { BARCODE_TELEPEN, 1, "\177\020123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345", 137, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 137 too long, requires 70 symbol characters (maximum 69)" }, + /* 18*/ { BARCODE_TELEPEN, 1, "\177\177\020123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012", 135, 0, 1, 1152, "" }, + /* 19*/ { BARCODE_TELEPEN, 1, "\177\177\0201234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123", 136, ZINT_ERROR_TOO_LONG, -1, -1, "Error 390: Input length 136 too long, requires 70 symbol characters (maximum 69)" }, + /* 20*/ { BARCODE_TELEPEN_NUM, -1, "1", 138, 0, 1, 1152, "" }, + /* 21*/ { BARCODE_TELEPEN_NUM, -1, "1", 139, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 139 too long, requires 70 symbol characters (maximum 69)" }, + /* 22*/ { BARCODE_TELEPEN_NUM, 1, "1", 138, 0, 1, 1152, "" }, + /* 23*/ { BARCODE_TELEPEN_NUM, 1, "1", 139, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 139 too long, requires 70 symbol characters (maximum 69)" }, + /* 24*/ { BARCODE_TELEPEN_NUM, 1, "1", 200, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 200 too long, requires 100 symbol characters (maximum 69)" }, + /* 25*/ { BARCODE_TELEPEN_NUM, 1, "1", 201, ZINT_ERROR_TOO_LONG, -1, -1, "Error 400: Input length 201 too long, requires too many symbol characters (maximum 69)" }, + /* 26*/ { BARCODE_TELEPEN_NUM, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456\020", 137, 0, 1, 1152, "" }, + /* 27*/ { BARCODE_TELEPEN_NUM, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567\020", 138, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 138 too long, requires 70 symbol characters (maximum 69)" }, + /* 28*/ { BARCODE_TELEPEN_NUM, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234\020\177", 136, 0, 1, 1152, "" }, + /* 29*/ { BARCODE_TELEPEN_NUM, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345\020\177", 137, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 137 too long, requires 70 symbol characters (maximum 69)" }, + /* 30*/ { BARCODE_TELEPEN_NUM, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012\020\177\177", 135, 0, 1, 1152, "" }, + /* 31*/ { BARCODE_TELEPEN_NUM, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123\020\177\177", 136, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 136 too long, requires 70 symbol characters (maximum 69)" }, + /* 32*/ { BARCODE_TELEPEN_NUM, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\020\177\177\177", 134, 0, 1, 1152, "" }, + /* 33*/ { BARCODE_TELEPEN_NUM, -1, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901\020\177\177\177", 135, ZINT_ERROR_TOO_LONG, -1, -1, "Error 392: Input length 135 too long, requires 70 symbol characters (maximum 69)" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -56,6 +87,15 @@ static void test_large(const testCtx *const p_ctx) { char data_buf[256]; + char escaped[8192]; + char escaped2[8192]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + /* Only do zxing-cpp tests 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++) { @@ -66,18 +106,44 @@ 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*/, data[i].option_2, -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(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); + ret = ZBarcode_Encode(symbol, ZCUCP(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(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_zxingcpp && testUtilCanZXingCPP(i, symbol, data_buf, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)),-1, + "i:%d testUtilModulesDump == -1\n", i); + ret = testUtilZXingCPP(i, symbol, data_buf, length, modules_dump, 3 /*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_buf, length, + NULL /*primary*/, ret_buf, &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, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } } ZBarcode_Delete(symbol); @@ -91,6 +157,7 @@ static void test_hrt(const testCtx *const p_ctx) { struct item { int symbology; + int option_2; int output_options; const char *data; int length; @@ -102,30 +169,63 @@ static void test_hrt(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_TELEPEN, -1, "ABC1234.;$", -1, "ABC1234.;$", -1, "", -1 }, - /* 1*/ { BARCODE_TELEPEN, BARCODE_CONTENT_SEGS, "ABC1234.;$", -1, "ABC1234.;$", -1, "ABC1234.;$^", -1 }, - /* 2*/ { BARCODE_TELEPEN, -1, "abc1234.;$", -1, "abc1234.;$", -1, "", -1 }, - /* 3*/ { BARCODE_TELEPEN, BARCODE_CONTENT_SEGS, "abc1234.;$", -1, "abc1234.;$", -1, "abc1234.;$}", -1 }, - /* 4*/ { BARCODE_TELEPEN, -1, "ABC1234\001", -1, "ABC1234 ", -1, "", -1 }, /* Note used to put control chars (apart from NUL) in HRT */ - /* 5*/ { BARCODE_TELEPEN, BARCODE_CONTENT_SEGS, "ABC1234\001", -1, "ABC1234 ", -1, "ABC1234\001k", -1 }, - /* 6*/ { BARCODE_TELEPEN, -1, "ABC\0001234", 8, "ABC 1234", -1, "", -1 }, - /* 7*/ { BARCODE_TELEPEN, BARCODE_CONTENT_SEGS, "ABC\0001234", 8, "ABC 1234", -1, "ABC\0001234l", 9 }, - /* 8*/ { BARCODE_TELEPEN, -1, "ABK0", -1, "ABK0", -1, "", -1 }, - /* 9*/ { BARCODE_TELEPEN, BARCODE_CONTENT_SEGS, "ABK0", -1, "ABK0", -1, "ABK0\000", 5 }, - /* 10*/ { BARCODE_TELEPEN_NUM, -1, "1234", -1, "1234", -1, "", -1 }, - /* 11*/ { BARCODE_TELEPEN_NUM, BARCODE_CONTENT_SEGS, "1234", -1, "1234", -1, "1234\033", -1 }, - /* 12*/ { BARCODE_TELEPEN_NUM, -1, "123X", -1, "123X", -1, "", -1 }, - /* 13*/ { BARCODE_TELEPEN_NUM, BARCODE_CONTENT_SEGS, "123X", -1, "123X", -1, "123XD", -1 }, - /* 14*/ { BARCODE_TELEPEN_NUM, -1, "123x", -1, "123X", -1, "", -1 }, /* Converts to upper */ - /* 15*/ { BARCODE_TELEPEN_NUM, BARCODE_CONTENT_SEGS, "123x", -1, "123X", -1, "123XD", -1 }, - /* 16*/ { BARCODE_TELEPEN_NUM, -1, "12345", -1, "012345", -1, "", -1 }, /* Adds leading zero if odd */ - /* 17*/ { BARCODE_TELEPEN_NUM, BARCODE_CONTENT_SEGS, "12345", -1, "012345", -1, "012345h", -1 }, + /* 0*/ { BARCODE_TELEPEN, -1, -1, "ABC1234.;$", -1, "ABC1234.;$", -1, "", -1 }, + /* 1*/ { BARCODE_TELEPEN, -1, BARCODE_CONTENT_SEGS, "ABC1234.;$", -1, "ABC1234.;$", -1, "ABC1234.;$^", -1 }, + /* 2*/ { BARCODE_TELEPEN, -1, -1, "abc1234.;$", -1, "abc1234.;$", -1, "", -1 }, + /* 3*/ { BARCODE_TELEPEN, -1, BARCODE_CONTENT_SEGS, "abc1234.;$", -1, "abc1234.;$", -1, "abc1234.;$}", -1 }, + /* 4*/ { BARCODE_TELEPEN, -1, -1, "ABC1234\001", -1, "ABC1234 ", -1, "", -1 }, /* Note used to put control chars (apart from NUL) in HRT */ + /* 5*/ { BARCODE_TELEPEN, -1, BARCODE_CONTENT_SEGS, "ABC1234\001", -1, "ABC1234 ", -1, "ABC1234\001k", -1 }, + /* 6*/ { BARCODE_TELEPEN, -1, -1, "ABC\0001234", 8, "ABC 1234", -1, "", -1 }, + /* 7*/ { BARCODE_TELEPEN, -1, BARCODE_CONTENT_SEGS, "ABC\0001234", 8, "ABC 1234", -1, "ABC\0001234l", 9 }, + /* 8*/ { BARCODE_TELEPEN, -1, -1, "ABK0", -1, "ABK0", -1, "", -1 }, + /* 9*/ { BARCODE_TELEPEN, -1, BARCODE_CONTENT_SEGS, "ABK0", -1, "ABK0", -1, "ABK0\000", 5 }, + /* 10*/ { BARCODE_TELEPEN, -1, -1, "ABK0\020", -1, "ABK0 ", -1, "", -1 }, /* Trailing DLE is literal DLE, space in HRT */ + /* 11*/ { BARCODE_TELEPEN, -1, BARCODE_CONTENT_SEGS, "ABK0\020", -1, "ABK0 ", -1, "ABK0\020o", -1 }, + /* 12*/ { BARCODE_TELEPEN, 1, -1, "ABK0\020", -1, "ABK0", -1, "", -1 }, /* Trailing DLE in Full ASCII + Compressed Numeric mode, remove from HRT */ + /* 13*/ { BARCODE_TELEPEN, 1, BARCODE_CONTENT_SEGS, "ABK0\020", -1, "ABK0", -1, "ABK0\020o", -1 }, + /* 14*/ { BARCODE_TELEPEN, 1, -1, "ABC\0201234", -1, "ABC1234", -1, "", -1 }, /* Trailing numeric, no leading zero needed */ + /* 15*/ { BARCODE_TELEPEN, 1, BARCODE_CONTENT_SEGS, "ABC\0201234", -1, "ABC1234", -1, "ABC\0201234C", -1 }, + /* 16*/ { BARCODE_TELEPEN, 1, -1, "ABC\020123", -1, "ABC0123", -1, "", -1 }, /* Trailing numeric, add leading zero */ + /* 17*/ { BARCODE_TELEPEN, 1, BARCODE_CONTENT_SEGS, "ABC\020123", -1, "ABC0123", -1, "ABC\0200123Y", -1 }, + /* 18*/ { BARCODE_TELEPEN, 1, -1, "ABC\020123x", -1, "ABC123X", -1, "", -1 }, /* Converts to upper */ + /* 19*/ { BARCODE_TELEPEN, 1, BARCODE_CONTENT_SEGS, "ABC\020123x", -1, "ABC123X", -1, "ABC\020123Xl", -1 }, + /* 20*/ { BARCODE_TELEPEN_NUM, -1, -1, "1234", -1, "1234", -1, "", -1 }, + /* 21*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "1234", -1, "1234", -1, "1234\033", -1 }, + /* 22*/ { BARCODE_TELEPEN_NUM, -1, -1, "123X", -1, "123X", -1, "", -1 }, + /* 23*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "123X", -1, "123X", -1, "123XD", -1 }, + /* 24*/ { BARCODE_TELEPEN_NUM, -1, -1, "123x", -1, "123X", -1, "", -1 }, /* Converts to upper */ + /* 25*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "123x", -1, "123X", -1, "123XD", -1 }, + /* 26*/ { BARCODE_TELEPEN_NUM, -1, -1, "12345", -1, "012345", -1, "", -1 }, /* Adds leading zero if odd */ + /* 27*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "12345", -1, "012345", -1, "012345h", -1 }, + /* 28*/ { BARCODE_TELEPEN_NUM, -1, -1, "1234\0205", -1, "12345", -1, "", -1 }, /* Trailing ASCII, no leading zero needed */ + /* 29*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "1234\0205", -1, "12345", -1, "1234\0205U", -1 }, + /* 30*/ { BARCODE_TELEPEN_NUM, -1, -1, "123\020AB", -1, "0123AB", -1, "", -1 }, /* Trailing ASCII, add leading zero */ + /* 31*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "123\020AB", -1, "0123AB", -1, "0123\020AB\035", -1 }, + /* 32*/ { BARCODE_TELEPEN_NUM, -1, -1, "123\020", -1, "0123", -1, "", -1 }, /* Trailing DLE, remove from HRT */ + /* 33*/ { BARCODE_TELEPEN_NUM, -1, BARCODE_CONTENT_SEGS, "123\020", -1, "0123", -1, "0123\020!", -1 }, + /* 34*/ { BARCODE_TELEPEN_NUM, 1, -1, "12345", -1, "012345", -1, "", -1 }, + /* 35*/ { BARCODE_TELEPEN_NUM, 1, BARCODE_CONTENT_SEGS, "12345", -1, "012345", -1, "012345h", -1 }, + /* 36*/ { BARCODE_TELEPEN_NUM, 1, -1, "1234\020567", -1, "1234567", -1, "", -1 }, + /* 37*/ { BARCODE_TELEPEN_NUM, 1, BARCODE_CONTENT_SEGS, "1234\020567", -1, "1234567", -1, "1234\020567g", -1 }, + /* 38*/ { BARCODE_TELEPEN_NUM, 1, -1, "12345\020A", -1, "012345A", -1, "", -1 }, + /* 39*/ { BARCODE_TELEPEN_NUM, 1, BARCODE_CONTENT_SEGS, "12345\020A", -1, "012345A", -1, "012345\020A\027", -1 }, + /* 40*/ { BARCODE_TELEPEN_NUM, 1, -1, "123\020", -1, "0123", -1, "", -1 }, + /* 41*/ { BARCODE_TELEPEN_NUM, 1, BARCODE_CONTENT_SEGS, "123\020", -1, "0123", -1, "0123\020!", -1 }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; int expected_length, expected_content_length; + char escaped[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + /* Only do zxing-cpp tests 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++) { @@ -136,32 +236,60 @@ static void test_hrt(const testCtx *const p_ctx) { assert_nonnull(symbol, "Symbol not created\n"); length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, - -1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options, - data[i].data, data[i].length, debug); + -1 /*option_1*/, data[i].option_2, -1 /*option_3*/, data[i].output_options, + data[i].data, data[i].length, debug); expected_length = data[i].expected_length == -1 ? (int) strlen(data[i].expected) : data[i].expected_length; - expected_content_length = data[i].expected_content_length == -1 ? (int) strlen(data[i].expected_content) : data[i].expected_content_length; + expected_content_length = data[i].expected_content_length == -1 + ? (int) strlen(data[i].expected_content) : data[i].expected_content_length; - ret = ZBarcode_Encode(symbol, TCU(data[i].data), length); + ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt); - assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n", - i, symbol->text_length, expected_length); - assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n", - i, symbol->text, data[i].expected, expected_length); + assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d (%s, %s)\n", + i, symbol->text_length, expected_length, + testUtilEscape(ZCCP(symbol->text), symbol->text_length, escaped, sizeof(escaped)), + testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2))); + assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d text memcmp(%s, %s, %d) != 0\n", + i, testUtilEscape(ZCCP(symbol->text), symbol->text_length, escaped, sizeof(escaped)), + testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)), expected_length); if (symbol->output_options & BARCODE_CONTENT_SEGS) { assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i); assert_nonnull(symbol->content_segs[0].source, "i:%d content_segs[0].source NULL\n", i); assert_equal(symbol->content_segs[0].length, expected_content_length, - "i:%d content_segs[0].length %d != expected_content_length %d\n", - i, symbol->content_segs[0].length, expected_content_length); + "i:%d content_segs[0].length %d != expected_content_length %d (%s, %s)\n", + i, symbol->content_segs[0].length, expected_content_length, + testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length, escaped, + sizeof(escaped)), + testUtilEscape(data[i].expected_content, expected_content_length, escaped2, + sizeof(escaped2))); assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected_content, expected_content_length), - "i:%d memcmp(%.*s, %.*s, %d) != 0\n", - i, symbol->content_segs[0].length, symbol->content_segs[0].source, expected_content_length, - data[i].expected_content, expected_content_length); + "i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i, + testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length, escaped, + sizeof(escaped)), + testUtilEscape(data[i].expected_content, expected_content_length, escaped2, + sizeof(escaped2)), expected_content_length); } else { assert_null(symbol->content_segs, "i:%d content_segs not NULL\n", i); } + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + 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, 3 /*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*/, ret_buf, &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, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } + ZBarcode_Delete(symbol); } @@ -173,6 +301,7 @@ static void test_input(const testCtx *const p_ctx) { struct item { int symbology; + int option_2; const char *data; int length; int ret; @@ -182,20 +311,37 @@ static void test_input(const testCtx *const p_ctx) { }; /* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */ static const struct item data[] = { - /* 0*/ { BARCODE_TELEPEN, " !\"#$%&'()*+,-./0123456789:;<", -1, 0, 1, 512, "" }, - /* 1*/ { BARCODE_TELEPEN, "AZaz\176\001", -1, 0, 1, 144, "" }, - /* 2*/ { BARCODE_TELEPEN, "\000\177", 2, 0, 1, 80, "" }, - /* 3*/ { BARCODE_TELEPEN, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 391: Invalid character at position 1 in input, extended ASCII not allowed" }, - /* 4*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128, "" }, - /* 5*/ { BARCODE_TELEPEN_NUM, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 393: Invalid character at position 10 in input (digits and \"X\" only)" }, - /* 6*/ { BARCODE_TELEPEN_NUM, "123456789X", -1, 0, 1, 128, "" }, /* [0-9]X allowed */ - /* 7*/ { BARCODE_TELEPEN_NUM, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 9 of \"X\" in Telepen data" }, /* X[0-9] not allowed */ - /* 8*/ { BARCODE_TELEPEN_NUM, "1X34567X9X", -1, 0, 1, 128, "" }, /* [0-9]X allowed multiple times */ + /* 0*/ { BARCODE_TELEPEN, -1, " !\"#$%&'()*+,-./0123456789:;<", -1, 0, 1, 512, "" }, + /* 1*/ { BARCODE_TELEPEN, -1, "AZaz\176\001", -1, 0, 1, 144, "" }, + /* 2*/ { BARCODE_TELEPEN, -1, "\000\177", 2, 0, 1, 80, "" }, + /* 3*/ { BARCODE_TELEPEN, -1, "é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 391: Invalid character at position 1 in input, extended ASCII not allowed" }, + /* 4*/ { BARCODE_TELEPEN, -1, "\020", -1, 0, 1, 64, "" }, + /* 5*/ { BARCODE_TELEPEN, 1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 397: DLE (ASCII 16) cannot be first character in Full ASCII + Compressed Numeric Mode" }, + /* 6*/ { BARCODE_TELEPEN, -1, "A\020B", -1, 0, 1, 96, "" }, + /* 7*/ { BARCODE_TELEPEN, 1, "A\020B", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 396: Invalid character at position 3 in input (digits and \"X\" only)" }, + /* 8*/ { BARCODE_TELEPEN_NUM, -1, "1234567890", -1, 0, 1, 128, "" }, + /* 9*/ { BARCODE_TELEPEN_NUM, -1, "123456789A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 393: Invalid character at position 10 in input (digits and \"X\" only)" }, + /* 10*/ { BARCODE_TELEPEN_NUM, -1, "123456789X", -1, 0, 1, 128, "" }, /* [0-9]X allowed */ + /* 11*/ { BARCODE_TELEPEN_NUM, -1, "12345678X9", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 394: Invalid odd position 9 of \"X\" in Telepen data" }, /* X[0-9] not allowed */ + /* 12*/ { BARCODE_TELEPEN_NUM, -1, "1X34567X9X", -1, 0, 1, 128, "" }, /* [0-9]X allowed multiple times */ + /* 13*/ { BARCODE_TELEPEN_NUM, -1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 398: DLE (ASCII 16) cannot be first character in Compressed Numeric Mode" }, + /* 14*/ { BARCODE_TELEPEN_NUM, 1, "\020", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 398: DLE (ASCII 16) cannot be first character in Compressed Numeric Mode" }, + /* 15*/ { BARCODE_TELEPEN_NUM, -1, "12\020é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 395: Invalid character at position 4 in input, extended ASCII not allowed" }, + /* 16*/ { BARCODE_TELEPEN_NUM, 1, "12\020é", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 395: Invalid character at position 4 in input, extended ASCII not allowed" }, }; const int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol = NULL; + char escaped[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; + + /* Only do zxing-cpp tests 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++) { @@ -205,16 +351,41 @@ 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, data[i].length, debug); + length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, + -1 /*option_1*/, data[i].option_2, -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); - 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); + ret = ZBarcode_Encode(symbol, ZCUCP(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); 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_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + 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, 3 /*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*/, ret_buf, &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, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); + } } ZBarcode_Delete(symbol); @@ -224,14 +395,15 @@ static void test_input(const testCtx *const p_ctx) { } /* Telepen Barcode Symbology information and History (BSiH) - https://telepen.co.uk/wp-content/uploads/2018/10/Barcode-Symbology-information-and-History.pdf */ -/* E2326U: SB Telepen Barcode Fonts Guide Issue 2 (Apr 2009) - https://telepen.co.uk/wp-content/uploads/2018/09/SB-Telepen-Barcode-Fonts-V2.pdf */ + https://advanova.co.uk/wp-content/uploads/2022/05/Barcode-Symbology-information-and-History.pdf */ +/* E2326U: SB Telepen Fonts Guide. Issue 3 13/5/2022 + https://advanova.co.uk/wp-content/uploads/2022/05/SB-Telepen-Barcode-Fonts-V3.pdf */ static void test_encode(const testCtx *const p_ctx) { int debug = p_ctx->debug; struct item { int symbology; + int option_2; const char *data; int length; int ret; @@ -241,35 +413,48 @@ static void test_encode(const testCtx *const p_ctx) { const char *comment; const char *expected; }; + /* s/\v(\/\*)[ 0-9]*(\*\/)/\=printf("%s%3d%s", submatch(1), (@z+setreg('z',@z+1)), submatch(2))/ | let @z=0: */ static const struct item data[] = { - /* 0*/ { BARCODE_TELEPEN, "1A", -1, 0, 1, 80, "Telepen BSiH Example, same", + /* 0*/ { BARCODE_TELEPEN, -1, "1A", -1, 0, 1, 80, "Telepen BSiH Example, same", "10101010101110001011101000100010101110111011100010100010001110101110001010101010" }, - /* 1*/ { BARCODE_TELEPEN, "ABC", -1, 0, 1, 96, "Telepen E2326U Example, same", + /* 1*/ { BARCODE_TELEPEN, -1, "ABC", -1, 0, 1, 96, "Telepen E2326U Example, same", "101010101011100010111011101110001110001110111000101011101110101011101000101000101110001010101010" }, - /* 2*/ { BARCODE_TELEPEN, "RST", -1, 0, 1, 96, "Verified manually against tec-it", + /* 2*/ { BARCODE_TELEPEN, -1, "RST", -1, 0, 1, 96, "Verified manually against TEC-IT", "101010101011100011100011100010101010111010111000111010111000101010111000111011101110001010101010" }, - /* 3*/ { BARCODE_TELEPEN, "?@", -1, 0, 1, 80, "ASCII count 127, check 0; verified manually against tec-it", + /* 3*/ { BARCODE_TELEPEN, -1, "?@", -1, 0, 1, 80, "ASCII count 127, check 0; verified manually against TEC-IT", "10101010101110001010101010101110111011101110101011101110111011101110001010101010" }, - /* 4*/ { BARCODE_TELEPEN, "\000", 1, 0, 1, 64, "Verified manually against tec-it", + /* 4*/ { BARCODE_TELEPEN, -1, "\000", 1, 0, 1, 64, "Verified manually against TEC-IT", "1010101010111000111011101110111011101110111011101110001010101010" }, - /* 5*/ { BARCODE_TELEPEN_NUM, "1234567890", -1, 0, 1, 128, "Verified manually against tec-it", + /* 5*/ { BARCODE_TELEPEN, 1, "AB\0201234", -1, 0, 1, 128, "", + "10101011101010001011101110111000111000111011100011101110101110101010101110101110101000101010001010101011101110101110101000101010" + }, + /* 6*/ { BARCODE_TELEPEN, 1, "AB\020123", -1, 0, 1, 128, "", + "10101011101010001011101110111000111000111011100011101110101110101110101010111010111000100010001010100010100011101110101000101010" + }, + /* 7*/ { BARCODE_TELEPEN, 1, "AB\020", -1, 0, 1, 96, "", + "101010111010100010111011101110001110001110111000111011101011101010101110001010101110101000101010" + }, + /* 8*/ { BARCODE_TELEPEN, 1, "AB", -1, 0, 1, 80, "", + "10101011101010001011101110111000111000111011100010101000101010001110101000101010" + }, + /* 9*/ { BARCODE_TELEPEN_NUM, -1, "1234567890", -1, 0, 1, 128, "Verified manually against TEC-IT", "10101010101110001010101110101110101000101010001010101110101110001011101010001000101110001010101010101011101010101110001010101010" }, - /* 6*/ { BARCODE_TELEPEN_NUM, "123456789", -1, 0, 1, 128, "Verified manually against tec-it (012345679)", + /* 10*/ { BARCODE_TELEPEN_NUM, -1, "123456789", -1, 0, 1, 128, "Verified manually against TEC-IT (012345679)", "10101010101110001110101010111010111000100010001011101110001110001000101010001010111010100010100010111000101110101110001010101010" }, - /* 7*/ { BARCODE_TELEPEN_NUM, "123X", -1, 0, 1, 80, "Verified manually against tec-it", + /* 11*/ { BARCODE_TELEPEN_NUM, -1, "123X", -1, 0, 1, 80, "Verified manually against TEC-IT", "10101010101110001010101110101110111010111000111011101011101110001110001010101010" }, - /* 8*/ { BARCODE_TELEPEN_NUM, "1X3X", -1, 0, 1, 80, "Verified manually against tec-it", + /* 12*/ { BARCODE_TELEPEN_NUM, -1, "1X3X", -1, 0, 1, 80, "Verified manually against TEC-IT", "10101010101110001110001110001110111010111000111010111010101110001110001010101010" }, - /* 9*/ { BARCODE_TELEPEN_NUM, "3637", -1, 0, 1, 80, "Glyph count 127, check 0; verified manually against tec-it", + /* 13*/ { BARCODE_TELEPEN_NUM, -1, "3637", -1, 0, 1, 80, "Glyph count 127, check 0; verified manually against TEC-IT", "10101010101110001010101010101110111011101110101011101110111011101110001010101010" }, }; @@ -278,10 +463,14 @@ static void test_encode(const testCtx *const p_ctx) { struct zint_symbol *symbol = NULL; char escaped[1024]; - char bwipp_buf[8192]; - char bwipp_msg[1024]; + char escaped2[1024]; + char cmp_buf[8192]; + char cmp_msg[1024]; + char ret_buf[8192]; - int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test 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(); testStartSymbol(p_ctx->func_name, &symbol); @@ -292,14 +481,18 @@ static void test_encode(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*/, data[i].option_2, -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); + ret = ZBarcode_Encode(symbol, ZCUCP(data[i].data), length); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", + i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { - printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\",\n", - i, testUtilBarcodeName(data[i].symbology), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, + printf(" /*%3d*/ { %s, %d, \"%s\", %d, %s, %d, %d, \"%s\",\n", + i, testUtilBarcodeName(data[i].symbology), data[i].option_2, + testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, testUtilErrorName(data[i].ret), symbol->rows, symbol->width, data[i].comment); testUtilModulesPrint(symbol, " ", "\n"); printf(" },\n"); @@ -307,19 +500,41 @@ static void test_encode(const testCtx *const p_ctx) { if (ret < ZINT_ERROR) { int width, row; - assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", i, symbol->rows, data[i].expected_rows, data[i].data); - assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", i, symbol->width, data[i].expected_width, data[i].data); + assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d (%s)\n", + i, symbol->rows, data[i].expected_rows, data[i].data); + assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d (%s)\n", + i, symbol->width, data[i].expected_width, data[i].data); ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row); - assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", i, ret, width, row, data[i].data); + assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n", + i, ret, width, row, data[i].data); - if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) { - ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, bwipp_buf, sizeof(bwipp_buf), NULL); - assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret); + if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) { + ret = testUtilBwipp(i, symbol, -1, data[i].option_2, -1, data[i].data, length, NULL, cmp_buf, + sizeof(cmp_buf), NULL /*p_parsefnc*/); + assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", + i, testUtilBarcodeName(symbol->symbology), ret); - ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected); + ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, data[i].expected); assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n", - i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf, data[i].expected); + i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected); + } + if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) { + int cmp_len, ret_len; + char modules_dump[4096]; + 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, 3 /*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*/, ret_buf, &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, + testUtilEscape(cmp_buf, cmp_len, escaped, sizeof(escaped)), + testUtilEscape(ret_buf, ret_len, escaped2, sizeof(escaped2))); } } } @@ -347,7 +562,7 @@ static void test_fuzz(const testCtx *const p_ctx) { /* 1*/ { BARCODE_TELEPEN, "\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", 70, ZINT_ERROR_TOO_LONG }, /* 2*/ { BARCODE_TELEPEN_NUM, "\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", 70, ZINT_ERROR_INVALID_DATA }, /* 3*/ { BARCODE_TELEPEN_NUM, "0404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404", 136, 0 }, - /* 4*/ { BARCODE_TELEPEN_NUM, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 137, ZINT_ERROR_TOO_LONG }, + /* 4*/ { BARCODE_TELEPEN_NUM, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567", 137, 0 }, /* 5*/ { BARCODE_TELEPEN_NUM, "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000X", 136, 0 }, /* 6*/ { BARCODE_TELEPEN_NUM, "9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", 136, 0 }, /* 7*/ { BARCODE_TELEPEN_NUM, "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", 4, 0 }, /* Length given, strlen > 137, so pseudo not NUL-terminated */ @@ -370,8 +585,9 @@ static void test_fuzz(const testCtx *const p_ctx) { length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length; - 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); + ret = ZBarcode_Encode(symbol, ZCUCP(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); ZBarcode_Delete(symbol); } @@ -379,40 +595,43 @@ static void test_fuzz(const testCtx *const p_ctx) { testFinish(); } -static const char TeleTable[128][16] = { - { "31313131" }, { "1131313111" }, { "33313111" }, { "1111313131" }, - { "3111313111" }, { "11333131" }, { "13133131" }, { "111111313111" }, - { "31333111" }, { "1131113131" }, { "33113131" }, { "1111333111" }, - { "3111113131" }, { "1113133111" }, { "1311133111" }, { "111111113131" }, - { "3131113111" }, { "11313331" }, { "333331" }, { "111131113111" }, - { "31113331" }, { "1133113111" }, { "1313113111" }, { "1111113331" }, - { "31131331" }, { "113111113111" }, { "3311113111" }, { "1111131331" }, - { "311111113111" }, { "1113111331" }, { "1311111331" }, { "11111111113111" }, - { "31313311" }, { "1131311131" }, { "33311131" }, { "1111313311" }, - { "3111311131" }, { "11333311" }, { "13133311" }, { "111111311131" }, - { "31331131" }, { "1131113311" }, { "33113311" }, { "1111331131" }, - { "3111113311" }, { "1113131131" }, { "1311131131" }, { "111111113311" }, - { "3131111131" }, { "1131131311" }, { "33131311" }, { "111131111131" }, - { "3111131311" }, { "1133111131" }, { "1313111131" }, { "111111131311" }, - { "3113111311" }, { "113111111131" }, { "3311111131" }, { "111113111311" }, - { "311111111131" }, { "111311111311" }, { "131111111311" }, { "11111111111131" }, - { "3131311111" }, { "11313133" }, { "333133" }, { "111131311111" }, - { "31113133" }, { "1133311111" }, { "1313311111" }, { "1111113133" }, - { "313333" }, { "113111311111" }, { "3311311111" }, { "11113333" }, - { "311111311111" }, { "11131333" }, { "13111333" }, { "11111111311111" }, - { "31311133" }, { "1131331111" }, { "33331111" }, { "1111311133" }, - { "3111331111" }, { "11331133" }, { "13131133" }, { "111111331111" }, - { "3113131111" }, { "1131111133" }, { "33111133" }, { "111113131111" }, - { "3111111133" }, { "111311131111" }, { "131111131111" }, { "111111111133" }, - { "31311313" }, { "113131111111" }, { "3331111111" }, { "1111311313" }, - { "311131111111" }, { "11331313" }, { "13131313" }, { "11111131111111" }, - { "3133111111" }, { "1131111313" }, { "33111313" }, { "111133111111" }, - { "3111111313" }, { "111313111111" }, { "131113111111" }, { "111111111313" }, - { "313111111111" }, { "1131131113" }, { "33131113" }, { "11113111111111" }, - { "3111131113" }, { "113311111111" }, { "131311111111" }, { "111111131113" }, - { "3113111113" }, { "11311111111111" }, { "331111111111" }, { "111113111113" }, - { "31111111111111" }, { "111311111113" }, { "131111111113" }, - {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}, +/* Copy of "telepen.c" one */ +static const char TeleTable[132][16] = { + { "31313131" }, { "1131313111" }, { "33313111" }, { "1111313131" }, /*00-03*/ + { "3111313111" }, { "11333131" }, { "13133131" }, { "111111313111" }, /*04-07*/ + { "31333111" }, { "1131113131" }, { "33113131" }, { "1111333111" }, /*08-0B*/ + { "3111113131" }, { "1113133111" }, { "1311133111" }, { "111111113131" }, /*0C-0F*/ + { "3131113111" }, { "11313331" }, { "333331" }, { "111131113111" }, /*10-13*/ + { "31113331" }, { "1133113111" }, { "1313113111" }, { "1111113331" }, /*14-17*/ + { "31131331" }, { "113111113111" }, { "3311113111" }, { "1111131331" }, /*18-1B*/ + { "311111113111" }, { "1113111331" }, { "1311111331" }, { "11111111113111" }, /*1C-1F*/ + { "31313311" }, { "1131311131" }, { "33311131" }, { "1111313311" }, /*20-23*/ + { "3111311131" }, { "11333311" }, { "13133311" }, { "111111311131" }, /*24-27*/ + { "31331131" }, { "1131113311" }, { "33113311" }, { "1111331131" }, /*28-2B*/ + { "3111113311" }, { "1113131131" }, { "1311131131" }, { "111111113311" }, /*2C-2F*/ + { "3131111131" }, { "1131131311" }, { "33131311" }, { "111131111131" }, /*30-33*/ + { "3111131311" }, { "1133111131" }, { "1313111131" }, { "111111131311" }, /*34-37*/ + { "3113111311" }, { "113111111131" }, { "3311111131" }, { "111113111311" }, /*38-3B*/ + { "311111111131" }, { "111311111311" }, { "131111111311" }, { "11111111111131" }, /*3C-3F*/ + { "3131311111" }, { "11313133" }, { "333133" }, { "111131311111" }, /*40-43*/ + { "31113133" }, { "1133311111" }, { "1313311111" }, { "1111113133" }, /*44-47*/ + { "313333" }, { "113111311111" }, { "3311311111" }, { "11113333" }, /*48-4B*/ + { "311111311111" }, { "11131333" }, { "13111333" }, { "11111111311111" }, /*4C-4F*/ + { "31311133" }, { "1131331111" }, { "33331111" }, { "1111311133" }, /*50-53*/ + { "3111331111" }, { "11331133" }, { "13131133" }, { "111111331111" }, /*54-57*/ + { "3113131111" }, { "1131111133" }, { "33111133" }, { "111113131111" }, /*58-5B*/ + { "3111111133" }, { "111311131111" }, { "131111131111" }, { "111111111133" /*START*/ }, /*5C-5F*/ + { "31311313" }, { "113131111111" }, { "3331111111" }, { "1111311313" }, /*60-63*/ + { "311131111111" }, { "11331313" }, { "13131313" }, { "11111131111111" }, /*64-67*/ + { "3133111111" }, { "1131111313" }, { "33111313" }, { "111133111111" }, /*68-6B*/ + { "3111111313" }, { "111313111111" }, { "131113111111" }, { "111111111313" }, /*6C-6F*/ + { "313111111111" }, { "1131131113" }, { "33131113" }, { "11113111111111" }, /*70-73*/ + { "3111131113" }, { "113311111111" }, { "131311111111" }, { "111111131113" }, /*74-77*/ + { "3113111113" }, { "11311111111111" }, { "331111111111" /*STOP*/ }, { "111113111113" }, /*78-7B*/ + { "31111111111111" }, { "111311111113" }, { "131111111113" }, /*7C-7E*/ + {'1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}, /*7F*/ + { "111111113113" /*START 2*/ }, { "311311111111" /*STOP 2*/ }, /*80-81*/ + { "111111311113" /*START 3*/ }, { "311113111111" /*STOP 3*/ }, /*82-83*/ }; /* Dummy to generate lengths table */ @@ -424,15 +643,16 @@ static void test_generate_lens(const testCtx *const p_ctx) { return; } - printf("static const char TeleLens[128] = {"); + printf("static const char TeleLens[128] = {\n "); for (i = 0; i < 127; i++) { - if ((i % 16) == 0) { - printf("\n %2d,", (int) strlen(TeleTable[i])); + if (i && (i % 16) == 0) { + printf(" /*%02X-%02X*/\n %2d,", i - 16, i - 1, (int) strlen(TeleTable[i])); } else { printf(" %2d,", (int) strlen(TeleTable[i])); } } - printf(" 16\n};\n"); + printf(" 16 /*70-7F*/\n};\n"); + /* Not bothering with START/STOP 2/3 */ } int main(int argc, char *argv[]) { diff --git a/backend/tests/test_vector.c b/backend/tests/test_vector.c index 254cdcb4..2bd7f8ac 100644 --- a/backend/tests/test_vector.c +++ b/backend/tests/test_vector.c @@ -2545,9 +2545,9 @@ static void test_height(const testCtx *const p_ctx) { /*110*/ { BARCODE_DBAR_EXP, -1, 33, "[01]12345678901231", "", 0, 33, 1, 134, 268, 66, "" }, /*111*/ { BARCODE_DBAR_EXP, COMPLIANT_HEIGHT, 33, "[01]12345678901231", "", ZINT_WARN_NONCOMPLIANT, 33, 1, 134, 268, 66, "" }, /*112*/ { BARCODE_DBAR_EXP, COMPLIANT_HEIGHT, 34, "[01]12345678901231", "", 0, 34, 1, 134, 268, 68, "" }, - /*113*/ { BARCODE_TELEPEN, -1, 1, "1234567890", "", 0, 1, 1, 208, 416, 2, "" }, - /*114*/ { BARCODE_TELEPEN, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 208, 416, 2, "No known min" }, - /*115*/ { BARCODE_TELEPEN, -1, 4, "1234567890", "", 0, 4, 1, 208, 416, 8, "" }, + /*113*/ { BARCODE_TELEPEN, -1, 8.95, "1234567890", "", 0, 8.95, 1, 208, 416, 17.9, "" }, + /*114*/ { BARCODE_TELEPEN, COMPLIANT_HEIGHT, 8.95, "1234567890", "", ZINT_WARN_NONCOMPLIANT, 8.95, 1, 208, 416, 17.9, "" }, + /*115*/ { BARCODE_TELEPEN, COMPLIANT_HEIGHT, 9, "1234567890", "", 0, 9, 1, 208, 416, 18, "" }, /*116*/ { BARCODE_UPCA, -1, 1, "12345678901", "", 0, 1, 1, 95, 226, 12, "" }, /*117*/ { BARCODE_UPCA, -1, 69, "12345678901", "", 0, 69, 1, 95, 226, 148, "" }, /*118*/ { BARCODE_UPCA, COMPLIANT_HEIGHT, 69, "12345678901", "", ZINT_WARN_NONCOMPLIANT, 69, 1, 95, 226, 148, "" }, @@ -2764,9 +2764,9 @@ static void test_height(const testCtx *const p_ctx) { /*329*/ { BARCODE_PLESSEY, -1, 1, "1234567890", "", 0, 1, 1, 227, 454, 2, "" }, /*330*/ { BARCODE_PLESSEY, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 227, 454, 2, "TODO: Find doc" }, /*331*/ { BARCODE_PLESSEY, -1, 4, "1234567890", "", 0, 4, 1, 227, 454, 8, "" }, - /*332*/ { BARCODE_TELEPEN_NUM, -1, 1, "1234567890", "", 0, 1, 1, 128, 256, 2, "" }, - /*333*/ { BARCODE_TELEPEN_NUM, COMPLIANT_HEIGHT, 1, "1234567890", "", 0, 1, 1, 128, 256, 2, "No known min" }, - /*334*/ { BARCODE_TELEPEN_NUM, -1, 4, "1234567890", "", 0, 4, 1, 128, 256, 8, "" }, + /*332*/ { BARCODE_TELEPEN_NUM, -1, 6.65, "1234567890", "", 0, 6.65, 1, 128, 256, 13.3, "" }, + /*333*/ { BARCODE_TELEPEN_NUM, COMPLIANT_HEIGHT, 6.65, "1234567890", "", ZINT_WARN_NONCOMPLIANT, 6.65, 1, 128, 256, 13.3, "" }, + /*334*/ { BARCODE_TELEPEN_NUM, COMPLIANT_HEIGHT, 6.7, "1234567890", "", 0, 6.7, 1, 128, 256, 13.4, "" }, /*335*/ { BARCODE_ITF14, -1, 1, "1234567890", "", 0, 1, 1, 135, 330, 22, "" }, /*336*/ { BARCODE_ITF14, -1, 5.7, "1234567890", "", 0, 5.6999998, 1, 135, 330, 31.4, "" }, /*337*/ { BARCODE_ITF14, COMPLIANT_HEIGHT, 5.7, "1234567890", "", ZINT_WARN_NONCOMPLIANT, 5.6999998, 1, 135, 330, 31.4, "" }, diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index 477343b4..b1360977 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -3985,7 +3985,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym { "DataBar", BARCODE_DBAR_OMN, 29, }, { "DataBarLimited", BARCODE_DBAR_LTD, 30, }, { "DataBarExpanded", BARCODE_DBAR_EXP, 31, }, - { "", BARCODE_TELEPEN, 32, }, + { "TelepenAlpha", BARCODE_TELEPEN, 32, }, { "", -1, 33, }, { "UPC-A", BARCODE_UPCA, 34, }, { "UPC-A", BARCODE_UPCA_CHK, 35, }, @@ -4040,7 +4040,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym { "MicroPDF417", BARCODE_MICROPDF417, 84, }, { "", BARCODE_USPS_IMAIL, 85, }, { "", BARCODE_PLESSEY, 86, }, - { "", BARCODE_TELEPEN_NUM, 87, }, + { "TelepenNumeric", BARCODE_TELEPEN_NUM, 87, }, { "", -1, 88, }, { "ITF", BARCODE_ITF14, 89, }, { "", BARCODE_KIX, 90, }, @@ -4400,6 +4400,8 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in char *pzn = symbology == BARCODE_PZN ? (char *) z_alloca(expected_len + 1 + 1) : NULL; char *dxfe = symbology == BARCODE_DXFILMEDGE ? (char *) z_alloca(expected_len * 2 + 1) : NULL; char azrune[4]; + char *telepen = symbology == BARCODE_TELEPEN || symbology == BARCODE_TELEPEN_NUM + ? (char *) z_alloca(expected_len + 1 + 1 + 1) : NULL; int ret; int ret_memcmp; @@ -4740,6 +4742,54 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in } else if ((symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39 || symbology == BARCODE_LOGMARS) && have_ccheckdigit) { cmp_len--; /* Too tedious to calculate so ignore */ + + } else if (symbology == BARCODE_TELEPEN_NUM) { + const int dle_posn = z_posn(expected, '\x10'); + if (dle_posn != -1) { + if (dle_posn & 1) { + telepen[0] = '0'; + memcpy(telepen + 1, expected, dle_posn); + z_to_upper(ZUCP(telepen + 1), dle_posn); + memcpy(telepen + dle_posn + 1, expected + dle_posn + 1, expected_len - (dle_posn + 1)); + expected = telepen; + } else { + memcpy(telepen, expected, dle_posn); + z_to_upper(ZUCP(telepen), dle_posn); + memcpy(telepen + dle_posn, expected + dle_posn + 1, expected_len - (dle_posn + 1)); + expected = telepen; + expected_len--; + } + } else if (expected_len & 1) { + telepen[0] = '0'; + memcpy(telepen + 1, expected, expected_len); + z_to_upper(ZUCP(telepen + 1), expected_len); + expected = telepen; + expected_len++; + } else { + memcpy(telepen, expected, expected_len); + z_to_upper(ZUCP(telepen), expected_len); + expected = telepen; + } + + } else if (symbology == BARCODE_TELEPEN && symbol->option_2 == 1) { + const int dle_posn = z_posn(expected, '\x10'); + if (dle_posn != -1) { + memcpy(telepen, expected, dle_posn); + if (dle_posn + 1 < expected_len) { + if ((expected_len - (dle_posn + 1)) & 1) { + telepen[dle_posn] = '0'; + memcpy(telepen + dle_posn + 1, expected + dle_posn + 1, expected_len - (dle_posn + 1)); + z_to_upper(ZUCP(telepen + dle_posn + 1), expected_len - (dle_posn + 1)); + } else { + memcpy(telepen + dle_posn, expected + dle_posn + 1, expected_len - (dle_posn + 1)); + z_to_upper(ZUCP(telepen + dle_posn), expected_len - (dle_posn + 1)); + expected_len--; + } + } else { + expected_len--; + } + expected = telepen; + } } if (ret_buf) { diff --git a/backend/tests/tools/run_zxingcpp_tests.sh b/backend/tests/tools/run_zxingcpp_tests.sh index 8b27660d..ed20c171 100755 --- a/backend/tests/tools/run_zxingcpp_tests.sh +++ b/backend/tests/tools/run_zxingcpp_tests.sh @@ -56,5 +56,6 @@ run_zxingcpp_test "test_pdf417" "fuzz" run_zxingcpp_test "test_qr" run_zxingcpp_test "test_rss" "binary_div_modulo_divisor" run_zxingcpp_test "test_rss" "examples" +run_zxingcpp_test "test_telepen" run_zxingcpp_test "test_upcean" "upce_input" run_zxingcpp_test "test_upcean" "encode" diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index a27846df..5361fa2e 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -1531,6 +1531,7 @@ namespace Zint { || m_symbol == BARCODE_QRCODE || m_symbol == BARCODE_HIBC_QR || m_symbol == BARCODE_MICROQR || m_symbol == BARCODE_RMQR || m_symbol == BARCODE_GRIDMATRIX || m_symbol == BARCODE_HANXIN || m_symbol == BARCODE_CHANNEL || m_symbol == BARCODE_CODEONE || m_symbol == BARCODE_CODE93 + || m_symbol == BARCODE_TELEPEN || m_symbol == BARCODE_TELEPEN_NUM || m_symbol == BARCODE_ULTRA || m_symbol == BARCODE_VIN) { arg_int(cmd, "--vers=", option2()); } else if (m_symbol == BARCODE_DAFT && option2() != 250) { diff --git a/backend_qt/tests/test_qzint.cpp b/backend_qt/tests/test_qzint.cpp index 07126466..9a8f5ef2 100644 --- a/backend_qt/tests/test_qzint.cpp +++ b/backend_qt/tests/test_qzint.cpp @@ -1353,6 +1353,22 @@ private slots: << "zint.exe -b 145 --eci=20 -d \"テ\" --rotate=180 --vers=8" << "" << "" << "" << ""; + QTest::newRow("BARCODE_TELEPEN") << false << 0.0f << "" + << BARCODE_TELEPEN << (DATA_MODE | ESCAPE_MODE) // symbology-inputMode + << "ABCDE\\L123" << "" // text-primary + << 0.0f << -1 << 1 << 0 << 1.0f // height-scale + << 0.0f << false << 0.8f << 1.0f // dpmm-textGap + << 5.0f << 0 << 0 << "" // guardDescent-structAppID + << "" << "" << QColor(Qt::black) << QColor(Qt::white) << false // fgStr-cmyk + << 0 << 0 << 0 << 0 << 0 // borderTypeIndex-fontSetting + << true << false << false << false << true << 0 // showText-rotateAngle + << 0 << false << false << false << false // eci-gs1SyntaxEngine + << false << false << false << WARN_DEFAULT << false // readerInit-debug + << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp + << "zint -b 32 --binary --compliantheight -d 'ABCDE\\L123' --esc --vers=1" + << "zint.exe -b 32 --binary --compliantheight -d \"ABCDE\\L123\" --esc --vers=1" + << "" << "" << "" << ""; + QTest::newRow("BARCODE_ULTRA") << false << 0.0f << "" << BARCODE_ULTRA << (GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE) // symbology-inputMode << "(01)1" << "" // text-primary diff --git a/docs/images/telepen.svg b/docs/images/telepen.svg index 2ce4076d..fcf37c3e 100644 --- a/docs/images/telepen.svg +++ b/docs/images/telepen.svg @@ -1,12 +1,12 @@ - + Zint Generated Symbol - - - - Z80 + + + + Z8000 diff --git a/docs/images/telepen_aim.svg b/docs/images/telepen_aim.svg new file mode 100644 index 00000000..665fb9d2 --- /dev/null +++ b/docs/images/telepen_aim.svg @@ -0,0 +1,12 @@ + + + + Zint Generated Symbol + + + + + Z8000 + + + diff --git a/docs/images/telepen_num_asc.svg b/docs/images/telepen_num_asc.svg new file mode 100644 index 00000000..edf7a32e --- /dev/null +++ b/docs/images/telepen_num_asc.svg @@ -0,0 +1,12 @@ + + + + Zint Generated Symbol + + + + + 12AB + + + diff --git a/docs/images/telepen_num_odd.svg b/docs/images/telepen_num_odd.svg new file mode 100644 index 00000000..84c14037 --- /dev/null +++ b/docs/images/telepen_num_odd.svg @@ -0,0 +1,12 @@ + + + + Zint Generated Symbol + + + + + 123 + + + diff --git a/docs/manual.html b/docs/manual.html index bf669079..0c4b23b2 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -334,7 +334,7 @@

Zint Barcode Generator and Zint Barcode Studio User Manual

Version 2.16.0.9

-

April 2026

+

May 2026