diff --git a/ChangeLog b/ChangeLog index 39b15ec6..68c920b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,11 @@ Changes - BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT: check for errors on writing to output file (ticket #275) - manual/man page: document octal escape; Code 128 subset/mode -> Code Set +- Add special symbology-specific escape sequences (Code 128 only) for manual + Code Set switching via `input_mode` flag `EXTRA_ESCAPE_MODE` (CLI --extraesc) + (ticket #204) +- GUI: disable "Reset" colour if default; add "Unset" to Printing Scale dialog + (allows unsetting of X-dim/resolution settings without having to zap) Bugs ---- diff --git a/backend/code128.c b/backend/code128.c index 422a77df..0b27c229 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -1,7 +1,7 @@ /* code128.c - Handles Code 128 and derivatives */ /* libzint - the open source barcode library - Copyright (C) 2008-2022 Robin Stuart + Copyright (C) 2008-2023 Robin Stuart Bugfixes thanks to Christian Sakowski and BogDan Vatra Redistribution and use in source and binary forms, with or without @@ -97,14 +97,14 @@ INTERNAL int c128_parunmodd(const unsigned char llyth) { } /** - * bring together same type blocks + * Bring together same type blocks */ -static void c128_grwp(int list[2][C128_MAX], int *indexliste) { +static void c128_grwp(int list[2][C128_MAX], int *p_indexliste) { /* bring together same type blocks */ - if (*(indexliste) > 1) { + if (*p_indexliste > 1) { int i = 1; - while (i < *(indexliste)) { + while (i < *p_indexliste) { if (list[1][i - 1] == list[1][i]) { int j; /* bring together */ @@ -112,12 +112,12 @@ static void c128_grwp(int list[2][C128_MAX], int *indexliste) { j = i + 1; /* decrease the list */ - while (j < *(indexliste)) { + while (j < *p_indexliste) { list[0][j - 1] = list[0][j]; list[1][j - 1] = list[1][j]; j++; } - *(indexliste) = *(indexliste) - 1; + *p_indexliste = *p_indexliste - 1; i--; } i++; @@ -128,10 +128,11 @@ static void c128_grwp(int list[2][C128_MAX], int *indexliste) { /** * Implements rules from ISO 15417 Annex E */ -INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { +INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *p_indexliste, const char *manual_set) { int i, last, next; + const int indexliste = *p_indexliste; - for (i = 0; i < *(indexliste); i++) { + for (i = 0; i < indexliste; i++) { int current = list[1][i]; /* Either C128_ABORC, C128_AORB, C128_SHIFTA or C128_SHIFTB */ int length = list[0][i]; if (i != 0) { @@ -139,7 +140,7 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { } else { last = 0; } - if (i != *(indexliste) - 1) { + if (i != indexliste - 1) { next = list[1][i + 1]; } else { next = 0; @@ -147,7 +148,10 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { if (i == 0) { /* first block */ if (current == C128_ABORC) { - if ((*(indexliste) == 1) && (length == 2)) { + if (manual_set && manual_set[i]) { + list[1][i] = manual_set[i]; + current = manual_set[i]; + } else if ((indexliste == 1) && (length == 2)) { /* Rule 1a */ list[1][i] = C128_LATCHC; current = C128_LATCHC; @@ -160,7 +164,9 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { } } if (current == C128_AORB) { - if (next == C128_SHIFTA) { + if (manual_set && (manual_set[i] == 'A' || manual_set[i] == 'B')) { + list[1][i] = manual_set[i]; + } else if (next == C128_SHIFTA) { /* Rule 1c */ list[1][i] = C128_LATCHA; } else { @@ -170,14 +176,17 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { } else if (current == C128_SHIFTA) { /* Rule 1c */ list[1][i] = C128_LATCHA; - } else if (current == C128_SHIFTB) { /* Unless C128_LATCHC set above, can only be C128_SHIFTB */ + } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */ /* Rule 1d */ list[1][i] = C128_LATCHB; } } else { if (current == C128_ABORC) { - if (length >= 4) { - /* Rule 3 */ + if (manual_set && manual_set[i]) { + list[1][i] = manual_set[i]; + current = manual_set[i]; + } else if (length >= 4) { + /* Rule 3 - note Rule 3b (odd C blocks) dealt with later */ list[1][i] = C128_LATCHC; current = C128_LATCHC; } else { @@ -185,7 +194,9 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { } } if (current == C128_AORB) { - if (last == C128_LATCHA || last == C128_SHIFTB) { /* Maintain state */ + if (manual_set && (manual_set[i] == 'A' || manual_set[i] == 'B')) { + list[1][i] = manual_set[i]; + } else if (last == C128_LATCHA || last == C128_SHIFTB) { /* Maintain state */ list[1][i] = C128_LATCHA; } else if (last == C128_LATCHB || last == C128_SHIFTA) { /* Maintain state */ list[1][i] = C128_LATCHB; @@ -195,7 +206,9 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { list[1][i] = C128_LATCHB; } } else if (current == C128_SHIFTA) { - if (length > 1) { + if (manual_set && manual_set[i] == 'A') { + list[1][i] = C128_LATCHA; + } else if (length > 1) { /* Rule 4 */ list[1][i] = C128_LATCHA; } else if (last == C128_LATCHA || last == C128_SHIFTB) { /* Maintain state */ @@ -203,8 +216,10 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { } else if (last == C128_LATCHC) { list[1][i] = C128_LATCHA; } - } else if (current == C128_SHIFTB) { /* Unless C128_LATCHC set above, can only be C128_SHIFTB */ - if (length > 1) { + } else if (current == C128_SHIFTB) { /* Unless C128_LATCHX set above, can only be C128_SHIFTB */ + if (manual_set && manual_set[i] == 'B') { + list[1][i] = C128_LATCHB; + } else if (length > 1) { /* Rule 5 */ list[1][i] = C128_LATCHB; } else if (last == C128_LATCHB || last == C128_SHIFTA) { /* Maintain state */ @@ -216,7 +231,7 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste) { } /* Rule 2 is implemented elsewhere, Rule 6 is implied */ } - c128_grwp(list, indexliste); + c128_grwp(list, p_indexliste); } /** @@ -273,25 +288,13 @@ INTERNAL void c128_set_c(const unsigned char source_a, const unsigned char sourc /* Put set data into set[]. If source given (GS1_MODE) then resolves odd C blocks */ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX], - unsigned char *source) { + const unsigned char *source) { int read = 0; int i, j; for (i = 0; i < indexliste; i++) { for (j = 0; j < list[0][i]; j++) { - switch (list[1][i]) { - case C128_SHIFTA: set[read] = 'a'; - break; - case C128_LATCHA: set[read] = 'A'; - break; - case C128_SHIFTB: set[read] = 'b'; - break; - case C128_LATCHB: set[read] = 'B'; - break; - case C128_LATCHC: set[read] = 'C'; - break; - } - read++; + set[read++] = list[1][i]; } } if (source) { @@ -380,6 +383,9 @@ INTERNAL int c128_hrt_cpy_iso8859_1_test(struct zint_symbol *symbol, const unsig INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length) { int i, j, k, values[C128_MAX] = {0}, bar_characters = 0, read, total_sum; int error_number = 0, indexchaine, indexliste, f_state = 0; + unsigned char src_buf[C128_MAX + 1]; + unsigned char *src = source; + char manual_set[C128_MAX] = {0}; int list[2][C128_MAX] = {{0}}; char set[C128_MAX] = {0}, fset[C128_MAX], mode, last_set, current_set = ' '; int glyph_count = 0; /* Codeword estimate times 2 */ @@ -396,9 +402,47 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len return ZINT_ERROR_TOO_LONG; } + /* Detect special Code Set escapes for Code 128 in extra escape mode only */ + if ((symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128) { + char manual_ch = '\0'; + j = 0; + for (i = 0; i < length; i++) { + if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^' + && ((source[i + 2] >= 'A' && source[i + 2] <= 'C') || source[i + 2] == '^')) { + if (source[i + 2] != '^') { + i += 2; + manual_ch = source[i]; + } else { /* Escape sequence '\^^' */ + manual_set[j] = manual_ch; + src_buf[j++] = source[i++]; + manual_set[j] = manual_ch; + src_buf[j++] = source[i++]; + /* Drop second '^' */ + } + } else { + manual_set[j] = manual_ch; + src_buf[j++] = source[i]; + } + } + if (j != length) { + length = j; + if (length == 0) { + strcpy(symbol->errtxt, "842: No input data"); + return ZINT_ERROR_INVALID_DATA; + } + src = src_buf; + src[length] = '\0'; + if (symbol->debug & ZINT_DEBUG_PRINT) { + printf("MSet: "); + for (i = 0; i < length; i++) printf("%c", manual_set[i] ? manual_set[i] : '.'); + printf("\n"); + } + } + } + /* Detect extended ASCII characters */ for (i = 0; i < length; i++) { - fset[i] = source[i] >= 128 ? 'f' : ' '; + fset[i] = src[i] >= 128 ? 'f' : ' '; } /* Decide when to latch to extended mode - Annex E note 3 */ @@ -447,8 +491,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len indexliste = 0; indexchaine = 0; - mode = c128_parunmodd(source[indexchaine]); - if ((symbol->symbology == BARCODE_CODE128AB) && (mode == C128_ABORC)) { + mode = c128_parunmodd(src[indexchaine]); + if (mode == C128_ABORC + && (symbol->symbology == BARCODE_CODE128AB + || (manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B'))) { mode = C128_AORB; } @@ -460,15 +506,28 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len if (indexchaine == length) { break; } - mode = c128_parunmodd(source[indexchaine]); - if ((symbol->symbology == BARCODE_CODE128AB) && (mode == C128_ABORC)) { + mode = c128_parunmodd(src[indexchaine]); + if (mode == C128_ABORC + && (symbol->symbology == BARCODE_CODE128AB + || (manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B'))) { mode = C128_AORB; } + if (manual_set[indexchaine] != manual_set[indexchaine - 1]) { + break; + } } indexliste++; } while (indexchaine < length); - c128_dxsmooth(list, &indexliste); + if (src == src_buf) { + /* Need to re-index `manual_set` to have sames indexes as `list` blocks for `c128_dxsmooth()` */ + j = 0; + for (i = 1; i < indexliste; i++) { + j += list[0][i - 1]; + manual_set[i] = manual_set[j]; + } + } + c128_dxsmooth(list, &indexliste, src == src_buf ? manual_set : NULL); /* Resolve odd length C128_LATCHC blocks */ if ((list[1][0] == C128_LATCHC) && (list[0][0] & 1)) { @@ -495,7 +554,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len c128_put_in_set(list, indexliste, set, NULL /*source*/); if (symbol->debug & ZINT_DEBUG_PRINT) { - printf("Data: %.*s (%d)\n", length, source, length); + printf("Data: %.*s (%d)\n", length, src, length); printf(" Set: %.*s\n", length, set); printf("FSet: %.*s\n", length, fset); } @@ -668,14 +727,14 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len switch (set[read]) { /* Encode data characters */ case 'a': - case 'A': c128_set_a(source[read], values, &bar_characters); + case 'A': c128_set_a(src[read], values, &bar_characters); read++; break; case 'b': - case 'B': (void) c128_set_b(source[read], values, &bar_characters); + case 'B': (void) c128_set_b(src[read], values, &bar_characters); read++; break; - case 'C': c128_set_c(source[read], source[read + 1], values, &bar_characters); + case 'C': c128_set_c(src[read], src[read + 1], values, &bar_characters); read += 2; break; } @@ -720,7 +779,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len /* ISO/IEC 15417:2007 leaves dimensions/height as application specification */ - c128_hrt_cpy_iso8859_1(symbol, source, length); + c128_hrt_cpy_iso8859_1(symbol, src, length); return error_number; } @@ -782,7 +841,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int indexliste++; } while (indexchaine < reduced_length); - c128_dxsmooth(list, &indexliste); + c128_dxsmooth(list, &indexliste, NULL /*manual_set*/); /* Put set data into set[], resolving odd C blocks */ c128_put_in_set(list, indexliste, set, reduced); diff --git a/backend/code128.h b/backend/code128.h index 1d9f1474..aebcfe54 100644 --- a/backend/code128.h +++ b/backend/code128.h @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2022 Robin Stuart + Copyright (C) 2020-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -38,24 +38,23 @@ extern "C" { #define C128_MAX 160 -#define C128_SHIFTA 90 -#define C128_LATCHA 91 -#define C128_SHIFTB 92 -#define C128_LATCHB 93 -#define C128_SHIFTC 94 -#define C128_LATCHC 95 -#define C128_AORB 96 -#define C128_ABORC 97 +#define C128_LATCHA 'A' +#define C128_LATCHB 'B' +#define C128_LATCHC 'C' +#define C128_SHIFTA 'a' +#define C128_SHIFTB 'b' +#define C128_ABORC '9' +#define C128_AORB 'Z' INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length); INTERNAL int c128_parunmodd(const unsigned char llyth); -INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste); +INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *indexliste, const char *manual_set); INTERNAL void c128_set_a(const unsigned char source, int values[], int *bar_chars); INTERNAL int c128_set_b(const unsigned char source, int values[], int *bar_chars); INTERNAL void c128_set_c(const unsigned char source_a, const unsigned char source_b, int values[], int *bar_chars); INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX], - unsigned char *source); + const unsigned char *source); INTERNAL_DATA_EXTERN const char C128Table[107][6]; diff --git a/backend/code16k.c b/backend/code16k.c index 20db5426..97157a69 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -1,7 +1,7 @@ /* code16k.c - Handles Code 16k stacked symbology */ /* libzint - the open source barcode library - Copyright (C) 2008-2022 Robin Stuart + Copyright (C) 2008-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -108,7 +108,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len indexliste++; } while (indexchaine < length); - c128_dxsmooth(list, &indexliste); + c128_dxsmooth(list, &indexliste, NULL /*manual_set*/); /* Put set data into set[], resolving odd C blocks */ c128_put_in_set(list, indexliste, set, source); diff --git a/backend/library.c b/backend/library.c index 30e6cea8..ad7759a8 100644 --- a/backend/library.c +++ b/backend/library.c @@ -1,7 +1,7 @@ /* library.c - external functions of libzint */ /* libzint - the open source barcode library - Copyright (C) 2009-2022 Robin Stuart + Copyright (C) 2009-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -296,7 +296,7 @@ static int dump_plot(struct zint_symbol *symbol) { } if (ferror(f)) { - sprintf(symbol->errtxt, "790: Incomplete write to output (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "795: Incomplete write to output (%d: %.30s)", errno, strerror(errno)); if (!output_to_stdout) { (void) fclose(f); } @@ -305,7 +305,7 @@ static int dump_plot(struct zint_symbol *symbol) { if (output_to_stdout) { if (fflush(f) != 0) { - sprintf(symbol->errtxt, "791: Incomplete flush to output (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "796: Incomplete flush to output (%d: %.30s)", errno, strerror(errno)); return ZINT_ERROR_FILE_WRITE; } } else { @@ -710,6 +710,7 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_ int i; unsigned long unicode; unsigned char *escaped_string = (unsigned char *) z_alloca(length + 1); + const int extra_escape_mode = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128; in_posn = 0; out_posn = 0; @@ -726,6 +727,19 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_ case '0': escaped_string[out_posn] = 0x00; /* Null */ in_posn += 2; break; + case '^': /* CODE128 specific */ + if (!extra_escape_mode) { + strcpy(symbol->errtxt, "798: Escape '\\^' only valid for Code 128 in extra escape mode"); + return ZINT_ERROR_INVALID_DATA; + } + /* Pass thru unaltered */ + escaped_string[out_posn++] = '\\'; + escaped_string[out_posn] = '^'; + in_posn += 2; + if (in_posn < length) { /* Note allowing '\\^' on its own at end */ + escaped_string[++out_posn] = input_string[in_posn++]; + } + break; case 'E': escaped_string[out_posn] = 0x04; /* End of Transmission */ in_posn += 2; break; @@ -1095,6 +1109,9 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[ if (symbol->rows >= 200) { /* Check for stacking too many symbols */ return error_tag(symbol, ZINT_ERROR_TOO_LONG, "770: Too many stacked symbols"); } + if (symbol->rows < 0) { /* Silently defend against out-of-bounds access */ + symbol->rows = 0; + } if ((symbol->input_mode & 0x07) == GS1_MODE && !gs1_compliant(symbol->symbology)) { return error_tag(symbol, ZINT_ERROR_INVALID_OPTION, "220: Selected symbology does not support GS1 mode"); @@ -1441,7 +1458,7 @@ int ZBarcode_Encode_File(struct zint_symbol *symbol, const char *filename) { /* Get file length */ if (fseek(file, 0, SEEK_END) != 0) { - sprintf(symbol->errtxt, "792: Unable to seek input file (%d: %.30s)", errno, strerror(errno)); + sprintf(symbol->errtxt, "797: Unable to seek input file (%d: %.30s)", errno, strerror(errno)); (void) fclose(file); return error_tag(symbol, ZINT_ERROR_INVALID_DATA, NULL); } diff --git a/backend/libzint.rc b/backend/libzint.rc index 08832592..0ff6135d 100644 --- a/backend/libzint.rc +++ b/backend/libzint.rc @@ -30,7 +30,7 @@ BEGIN VALUE "FileDescription", "libzint barcode library\0" VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "zint.dll\0" - VALUE "LegalCopyright", "Copyright 2022 Robin Stuart & BogDan Vatra\0" + VALUE "LegalCopyright", "Copyright 2023 Robin Stuart & BogDan Vatra\0" VALUE "OriginalFilename", "zint.dll\0" VALUE "ProductName", "libzint\0" VALUE "ProductVersion", VER_FILEVERSION_STR diff --git a/backend/tests/test_code128.c b/backend/tests/test_code128.c index e6bc5455..08978e91 100644 --- a/backend/tests/test_code128.c +++ b/backend/tests/test_code128.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2022 Robin Stuart + Copyright (C) 2020-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -356,52 +356,82 @@ static void test_input(const testCtx *const p_ctx) { /* 0*/ { UNICODE_MODE, "\302\200", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 204: Invalid character in input data (ISO/IEC 8859-1 only)", "PAD not in ISO 8859-1" }, /* 1*/ { DATA_MODE, "\200", -1, 0, 57, 1, "(5) 103 101 64 23 106", "PAD ok using binary" }, /* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, 1, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" }, - /* 3*/ { GS1_MODE, "[90]12", -1, ZINT_ERROR_INVALID_OPTION, 0, 1, "Error 220: Selected symbology does not support GS1 mode", "" }, - /* 4*/ { UNICODE_MODE, "1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1" }, - /* 5*/ { UNICODE_MODE, "12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, - /* 6*/ { UNICODE_MODE, "123", -1, 0, 68, 1, "(6) 104 17 18 19 8 106", "StartB 1 2 3" }, - /* 7*/ { UNICODE_MODE, "1234", -1, 0, 57, 1, "(5) 105 12 34 82 106", "StartC 12 34" }, - /* 8*/ { UNICODE_MODE, "12345", -1, 0, 79, 1, "(7) 105 12 34 100 21 54 106", "StartC 12 34 CodeB 5" }, - /* 9*/ { UNICODE_MODE, "\037", -1, 0, 46, 1, "(4) 103 95 95 106", "StartA US" }, - /* 10*/ { UNICODE_MODE, "1\037", -1, 0, 57, 1, "(5) 103 17 95 1 106", "StartA 1 US" }, - /* 11*/ { UNICODE_MODE, "12\037", -1, 0, 68, 1, "(6) 103 17 18 95 29 106", "StartA 1 2 US" }, - /* 12*/ { UNICODE_MODE, "a\037a", -1, 0, 79, 1, "(7) 104 65 98 95 65 86 106", "StartB a Shift US a" }, - /* 13*/ { UNICODE_MODE, "1234\037a", -1, 0, 101, 0, "(9) 105 12 34 101 95 98 65 100 106", "StartC 12 34 CodeA US Shift a; BWIPP different encodation" }, - /* 14*/ { UNICODE_MODE, "\037AAa\037", -1, 0, 101, 1, "(9) 103 95 33 33 98 65 95 2 106", "StartA US A A Shift a US" }, - /* 15*/ { UNICODE_MODE, "\037AAaa\037", -1, 0, 123, 0, "(11) 103 95 33 33 100 65 65 98 95 40 106", "StartA US A A CodeB a a Shift US; BWIPP different encodation" }, - /* 16*/ { UNICODE_MODE, "AAAa12345aAA", -1, 0, 167, 1, "(15) 104 33 33 33 65 17 99 23 45 100 65 33 33 54 106", "StartB A (3) a 1 CodeC 23 45 CodeB a A A" }, - /* 17*/ { UNICODE_MODE, "a\037Aa\037\037a\037aa\037a", -1, 0, 222, 1, "(20) 104 65 98 95 33 65 101 95 95 98 65 95 100 65 65 98 95 65 96 106", "StartB a Shift US A a CodeA US US Shift a US CodeB a a Shift US a" }, - /* 18*/ { UNICODE_MODE, "\000\037ß", 4, 0, 79, 1, "(7) 103 64 95 101 63 88 106", "StartA NUL US FNC4 ß" }, - /* 19*/ { UNICODE_MODE, "\000\037é", 4, 0, 90, 0, "(8) 103 64 95 101 98 73 78 106", "StartA NUL US FNC4 Shift é; BWIPP different encodation" }, - /* 20*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 0, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US LatchB FNC4 é a; BWIPP different encodation" }, - /* 21*/ { UNICODE_MODE, "abß", -1, 0, 79, 1, "(7) 104 65 66 100 63 29 106", "StartB a b FNC4 ß" }, - /* 22*/ { DATA_MODE, "\141\142\237", -1, 0, 90, 0, "(8) 104 65 66 100 98 95 26 106", "StartB a b FNC4 Shift APC; BWIPP different encodation" }, - /* 23*/ { DATA_MODE, "\141\142\237\037", -1, 0, 101, 0, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b LatchA FNC4 APC US; BWIPP different encodation" }, - /* 24*/ { UNICODE_MODE, "ééé", -1, 0, 90, 1, "(8) 104 100 100 73 73 73 44 106", "StartB LatchFNC4 é é é" }, - /* 25*/ { UNICODE_MODE, "aééééb", -1, 0, 145, 1, "(13) 104 65 100 73 100 73 100 73 100 73 66 49 106", "StartB a FNC4 é (4) b" }, - /* 26*/ { UNICODE_MODE, "aéééééb", -1, 0, 145, 1, "(13) 104 65 100 100 73 73 73 73 73 100 66 93 106", "StartB a Latch é (5) Shift b" }, - /* 27*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 1, "(15) 104 65 100 100 73 73 73 73 73 100 66 100 67 40 106", "StartB a Latch é (5) Shift b Shift c" }, - /* 28*/ { UNICODE_MODE, "aééééébcd", -1, 0, 178, 1, "(16) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 66 106", "StartB a Latch é (5) Unlatch b c d" }, - /* 29*/ { UNICODE_MODE, "aééééébcde", -1, 0, 189, 1, "(17) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 2 106", "StartB a Latch é (5) Unlatch b c d e" }, - /* 30*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 0, "(19) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 95 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é; BWIPP different encodation" }, - /* 31*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 0, "(21) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 100 73 19 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é (2); BWIPP different encodation" }, - /* 32*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 1, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3)" }, - /* 33*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, 1, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, - /* 34*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 222, 1, "(20) 103 101 101 64 64 64 64 64 101 101 33 99 0 0 101 33 101 64 73 106", "StartA Latch PAD (4) Unlatch A CodeC 00 00 CodeA A FNC4 PAD" }, - /* 35*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 0, "(19) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 63 106", "Okapi code128/extended-mode-exit-before-code-set-c.png (chose different solution); BWIPP different encodation" }, - /* 36*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 0, "(21) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 100 33 91 106", "Above with trailing non-shifted (as still latched) extended; BWIPP different encodation" }, - /* 37*/ { DATA_MODE | ESCAPE_MODE, "@g(\302\302\302\302\3025555\302\302\302\302\302\302\302\302", -1, 0, 277, 0, "(25) 104 32 71 8 100 100 34 34 34 34 34 99 55 55 100 34 34 34 34 34 34 34 34 25 106", "Okapi code128/extended-mode-with-short-embedded-code-set-c.png (chose different solution); BWIPP different encodation" }, - /* 38*/ { DATA_MODE | ESCAPE_MODE, "@g(\302\302\302\302\302555555\302\302\302\302\302\302\302", -1, 0, 277, 0, "(25) 104 32 71 8 100 100 34 34 34 34 34 99 55 55 55 100 34 34 34 34 34 34 34 76 106", "Above with extra 55 instead of \xC2; BWIPP different encodation" }, - /* 39*/ { UNICODE_MODE, "ÁÁèÁÁFç7Z", -1, 0, 189, 0, "(17) 104 100 100 33 33 72 33 33 100 38 71 100 100 23 58 95 106", "Okapi code128/extended-mode-shift.png; BWIPP different encodation" }, - /* 40*/ { UNICODE_MODE, "m\nm\nm", -1, 0, 112, 1, "(10) 104 77 98 74 77 98 74 77 11 106", "Okapi code128/code-set-b-a-b-a-b.png" }, - /* 41*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" }, - /* 42*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" }, - /* 43*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 61 106", "BWIPP different encodation, ShA instead of CodeA" }, - /* 44*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation, CodeA instead of ShA, shorter" }, - /* 45*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 89 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", "BWIPP different encodation, CodeA instead of ShA, shorter" }, - /* 46*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 89 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", "BWIPP different encodation, CodeA instead of ShA, shorter" }, - /* 47*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 409, 0, "(37) 104 100 95 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33", "BWIPP different encodation, CodeA instead of ShA, shorter" }, - /* 48*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 684, 0, "(62) 104 100 95 99 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74", "BWIPP different encodation, CodeA instead of ShA, shorter" }, + /* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP no manual mode" }, + /* 4*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape ignored; BWIPP no manual mode" }, + /* 5*/ { UNICODE_MODE | ESCAPE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape ignored; BWIPP no manual mode" }, + /* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^C", -1, ZINT_ERROR_INVALID_DATA, 0, 1, "Error 842: No input data", "" }, + /* 7*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^^B\\^C", -1, 0, 68, 0, "(6) 103 60 62 34 80 106", "BWIPP no manual mode" }, + /* 8*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^^C", -1, 0, 68, 1, "(6) 104 60 62 35 84 106", "" }, + /* 9*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, + /* 10*/ { UNICODE_MODE | ESCAPE_MODE | EXTRA_ESCAPE_MODE, "\\^^A\\^B\\^^C", -1, 0, 101, 1, "(9) 104 60 62 33 60 62 35 14 106", "" }, + /* 11*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^^A", -1, 0, 68, 1, "(6) 104 60 62 33 78 106", "" }, + /* 12*/ { GS1_MODE, "[90]12", -1, ZINT_ERROR_INVALID_OPTION, 0, 1, "Error 220: Selected symbology does not support GS1 mode", "" }, + /* 13*/ { UNICODE_MODE, "1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1" }, + /* 14*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1", -1, 0, 46, 0, "(4) 103 17 17 106", "StartA 1; BWIPP no manual mode" }, + /* 15*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (manual C ignored as odd); BWIPP no manual mode" }, + /* 16*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^A", -1, 0, 46, 1, "(4) 104 17 18 106", "StartB 1 (escape at end ignored); BWIPP no manual mode" }, + /* 17*/ { UNICODE_MODE, "12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, + /* 18*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12", -1, 0, 46, 1, "(4) 105 12 14 106", "StartC 12" }, + /* 19*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12", -1, 0, 57, 0, "(5) 104 17 18 54 106", "StartB 1 2; BWIPP no manual mode" }, + /* 20*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A12", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2; BWIPP no manual mode" }, + /* 21*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^B2", -1, 0, 68, 0, "(6) 103 17 100 18 65 106", "StartA 1 CodeB 2; BWIPP no manual mode" }, + /* 22*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^A2", -1, 0, 68, 0, "(6) 104 17 101 18 68 106", "StartB 1 CodeA 2; BWIPP no manual mode" }, + /* 23*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A1\\^C2", -1, 0, 57, 0, "(5) 103 17 18 53 106", "StartA 1 2 (manual C ignored as odd); BWIPP no manual mode" }, + /* 24*/ { UNICODE_MODE, "123", -1, 0, 68, 1, "(6) 104 17 18 19 8 106", "StartB 1 2 3" }, + /* 25*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A123", -1, 0, 68, 0, "(6) 103 17 18 19 7 106", "StartA 1 2 3; BWIPP no manual mode" }, + /* 26*/ { UNICODE_MODE, "1234", -1, 0, 57, 1, "(5) 105 12 34 82 106", "StartC 12 34" }, + /* 27*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1234", -1, 0, 79, 0, "(7) 104 17 18 19 20 88 106", "StartB 1 2 3 4; BWIPP no manual mode" }, + /* 28*/ { UNICODE_MODE, "12345", -1, 0, 79, 1, "(7) 105 12 34 100 21 54 106", "StartC 12 34 CodeB 5" }, + /* 29*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^A5", -1, 0, 79, 0, "(7) 105 12 34 101 21 57 106", "StartC 12 34 CodeA 5; BWIPP no manual mode" }, + /* 30*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B1\\^C2345", -1, 0, 79, 0, "(7) 104 17 99 23 45 53 106", "StartB 1 CodeC 23 45; BWIPP no manual mode" }, + /* 31*/ { UNICODE_MODE, "\037", -1, 0, 46, 1, "(4) 103 95 95 106", "StartA US" }, + /* 32*/ { UNICODE_MODE, "1\037", -1, 0, 57, 1, "(5) 103 17 95 1 106", "StartA 1 US" }, + /* 33*/ { UNICODE_MODE, "12\037", -1, 0, 68, 1, "(6) 103 17 18 95 29 106", "StartA 1 2 US" }, + /* 34*/ { UNICODE_MODE, "a\037a", -1, 0, 79, 1, "(7) 104 65 98 95 65 86 106", "StartB a Shift US a" }, + /* 35*/ { UNICODE_MODE, "1234\037a", -1, 0, 101, 0, "(9) 105 12 34 101 95 98 65 100 106", "StartC 12 34 CodeA US Shift a; BWIPP different encodation" }, + /* 36*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\037\\^Ba", -1, 0, 101, 1, "(9) 105 12 34 101 95 100 65 7 106", "StartC 12 34 CodeA US CodeB a" }, + /* 37*/ { UNICODE_MODE, "\037AAa\037", -1, 0, 101, 1, "(9) 103 95 33 33 98 65 95 2 106", "StartA US A A Shift a US" }, + /* 38*/ { UNICODE_MODE, "\037AAaa\037", -1, 0, 123, 0, "(11) 103 95 33 33 100 65 65 98 95 40 106", "StartA US A A CodeB a a Shift US; BWIPP different encodation" }, + /* 39*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\037AAaa\\^A\037", -1, 0, 123, 1, "(11) 103 95 33 33 100 65 65 101 95 61 106", "StartA US A A CodeB a a CodeA US" }, + /* 40*/ { UNICODE_MODE, "AAAa12345aAA", -1, 0, 167, 1, "(15) 104 33 33 33 65 17 99 23 45 100 65 33 33 54 106", "StartB A (3) a 1 CodeC 23 45 CodeB a A A" }, + /* 41*/ { UNICODE_MODE, "a\037Aa\037\037a\037aa\037a", -1, 0, 222, 1, "(20) 104 65 98 95 33 65 101 95 95 98 65 95 100 65 65 98 95 65 96 106", "StartB a Shift US A a CodeA US US Shift a US CodeB a a Shift US a" }, + /* 42*/ { UNICODE_MODE, "\000\037ß", 4, 0, 79, 1, "(7) 103 64 95 101 63 88 106", "StartA NUL US FNC4 ß" }, + /* 43*/ { UNICODE_MODE, "\000\037é", 4, 0, 90, 0, "(8) 103 64 95 101 98 73 78 106", "StartA NUL US FNC4 Shift é; BWIPP different encodation (CodeB instead of Shift)" }, + /* 44*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\000\037\\^Bé", 7, 0, 90, 0, "(8) 103 64 95 100 100 73 83 106", "StartA NUL US CodeB FNC4 é; BWIPP different encodation (FNC4 before CodeB)" }, + /* 45*/ { UNICODE_MODE, "\000\037éa", 5, 0, 101, 0, "(9) 103 64 95 100 100 73 65 61 106", "StartA NUL US CodeB FNC4 é a; BWIPP different encodation (FNC4 before CodeB)" }, + /* 46*/ { UNICODE_MODE, "abß", -1, 0, 79, 1, "(7) 104 65 66 100 63 29 106", "StartB a b FNC4 ß" }, + /* 47*/ { DATA_MODE, "\141\142\237", -1, 0, 90, 0, "(8) 104 65 66 100 98 95 26 106", "StartB a b FNC4 Shift APC; BWIPP different encodation" }, + /* 48*/ { DATA_MODE, "\141\142\237\037", -1, 0, 101, 0, "(9) 104 65 66 101 101 95 95 96 106", "StartB a b CodeA FNC4 APC US; BWIPP different encodation" }, + /* 49*/ { UNICODE_MODE, "ééé", -1, 0, 90, 1, "(8) 104 100 100 73 73 73 44 106", "StartB LatchFNC4 é é é" }, + /* 50*/ { UNICODE_MODE, "aééééb", -1, 0, 145, 1, "(13) 104 65 100 73 100 73 100 73 100 73 66 49 106", "StartB a FNC4 é (4) b" }, + /* 51*/ { UNICODE_MODE, "aéééééb", -1, 0, 145, 1, "(13) 104 65 100 100 73 73 73 73 73 100 66 93 106", "StartB a Latch é (5) Shift b" }, + /* 52*/ { UNICODE_MODE, "aééééébc", -1, 0, 167, 1, "(15) 104 65 100 100 73 73 73 73 73 100 66 100 67 40 106", "StartB a Latch é (5) Shift b Shift c" }, + /* 53*/ { UNICODE_MODE, "aééééébcd", -1, 0, 178, 1, "(16) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 66 106", "StartB a Latch é (5) Unlatch b c d" }, + /* 54*/ { UNICODE_MODE, "aééééébcde", -1, 0, 189, 1, "(17) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 2 106", "StartB a Latch é (5) Unlatch b c d e" }, + /* 55*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 211, 0, "(19) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 95 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é; BWIPP different encodation" }, + /* 56*/ { UNICODE_MODE, "aééééébcdeéé", -1, 0, 233, 0, "(21) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 100 73 100 73 19 106", "StartB a Latch é (5) Unlatch b c d e FNC4 é (2); BWIPP different encodation" }, + /* 57*/ { UNICODE_MODE, "aééééébcdeééé", -1, 0, 244, 1, "(22) 104 65 100 100 73 73 73 73 73 100 66 100 67 100 68 100 69 73 73 73 83 106", "StartB a Latch é (5) Shift b Shift c Shift d Shift e é (3)" }, + /* 58*/ { UNICODE_MODE, "aééééébcdefééé", -1, 0, 255, 1, "(23) 104 65 100 100 73 73 73 73 73 100 100 66 67 68 69 70 100 100 73 73 73 67 106", "StartB a Latch é (5) Unlatch b c d e f Latch é (3)" }, + /* 59*/ { DATA_MODE, "\200\200\200\200\200\101\060\060\060\060\101\200", -1, 0, 222, 1, "(20) 103 101 101 64 64 64 64 64 101 101 33 99 0 0 101 33 101 64 73 106", "StartA Latch PAD (4) Unlatch A CodeC 00 00 CodeA A FNC4 PAD" }, + /* 60*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999", -1, 0, 211, 0, "(19) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 63 106", "Okapi code128/extended-mode-exit-before-code-set-c.png (chose different solution); BWIPP different encodation" }, + /* 61*/ { UNICODE_MODE, "ÁÁÁÁÁÁ99999999999999Á", -1, 0, 233, 0, "(21) 104 100 100 33 33 33 33 33 33 99 99 99 99 99 99 99 99 100 33 91 106", "Above with trailing non-shifted (as still latched) extended; BWIPP different encodation" }, + /* 62*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "@g(\302\302\302\302\3025555\302\302\302\302\302\302\302\302", -1, 0, 277, 0, "(25) 104 32 71 8 100 100 34 34 34 34 34 99 55 55 100 34 34 34 34 34 34 34 34 25 106", "Okapi code128/extended-mode-with-short-embedded-code-set-c.png (chose different solution); BWIPP different encodation" }, + /* 63*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "@g(\302\302\302\302\302555555\302\302\302\302\302\302\302", -1, 0, 277, 0, "(25) 104 32 71 8 100 100 34 34 34 34 34 99 55 55 55 100 34 34 34 34 34 34 34 76 106", "Above with extra 55 instead of \xC2; BWIPP different encodation" }, + /* 64*/ { UNICODE_MODE, "ÁÁèÁÁFç7Z", -1, 0, 189, 0, "(17) 104 100 100 33 33 72 33 33 100 38 71 100 100 23 58 95 106", "Okapi code128/extended-mode-shift.png; BWIPP different encodation" }, + /* 65*/ { UNICODE_MODE, "m\nm\nm", -1, 0, 112, 1, "(10) 104 77 98 74 77 98 74 77 11 106", "Okapi code128/code-set-b-a-b-a-b.png" }, + /* 66*/ { UNICODE_MODE, "c\naDEF", -1, 0, 112, 1, "(10) 104 67 98 74 65 36 37 38 75 106", "Okapi bug-36-1.png" }, + /* 67*/ { UNICODE_MODE, "\na\nDEF", -1, 0, 112, 1, "(10) 103 74 98 65 74 36 37 38 90 106", "Okapi bug-36-2.png" }, + /* 68*/ { UNICODE_MODE, "ÿ\012àa\0121\012àAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 98 74 17 98 74 100 64 33 100 64 61 106", "BWIPP different encodation, ShA instead of CodeA" }, + /* 69*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ\012àa\\^A\0121\012\\^BàAà", -1, 0, 222, 0, "(20) 104 100 95 98 74 100 64 65 101 74 17 74 100 100 64 33 100 64 30 106", "BWIPP different encodation, FNC4 before CodeB" }, + /* 70*/ { UNICODE_MODE, "ÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 387, 0, "(35) 104 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100 64", "BWIPP different encodation, CodeA instead of ShA, shorter" }, + /* 71*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "ÿ1234\012à\\^Aa\0121\012\\^C7890\\^BàAàDà\012à", -1, 0, 376, 0, "(34) 104 100 95 99 12 34 101 74 101 98 64 98 65 74 17 74 99 78 90 100 100 64 33 100 64 36", "BWIPP different encodation, FNC4 before CodeB, same width" }, + /* 72*/ { UNICODE_MODE, "yÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 89 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", "BWIPP different encodation, CodeA instead of ShA, shorter" }, + /* 73*/ { UNICODE_MODE, "ÿy1234\012àa\0121\0127890àAàDà\012à", -1, 0, 398, 0, "(36) 104 100 95 89 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33 100", "BWIPP different encodation, CodeA instead of ShA, shorter" }, + /* 74*/ { UNICODE_MODE, "ÿÿ1234\012àa\0121\0127890àAàDà\012à", -1, 0, 409, 0, "(37) 104 100 95 100 95 99 12 34 101 74 100 100 64 65 98 74 17 98 74 99 78 90 100 100 64 33", "BWIPP different encodation, CodeA instead of ShA, shorter" }, + /* 75*/ { UNICODE_MODE, "ÿ12345678\012à12345678abcdef\0121\01223456\012\0127890àAàBCDEFà\012\012à", -1, 0, 684, 0, "(62) 104 100 95 99 12 34 56 78 101 74 101 98 64 99 12 34 56 78 100 65 66 67 68 69 70 98 74", "BWIPP different encodation, CodeA instead of ShA, shorter" }, + /* 76*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^A12\\^C34\\^A\\^B5\\^C67\\^A\\^B\\^CA\\^B\\^A", -1, 0, 145, 0, "(13) 103 17 18 99 34 100 21 99 67 100 33 69 106", "BWIPP no manual mode" }, + /* 77*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C1234ABC12\012", -1, 0, 145, 0, "(13) 105 12 34 100 33 34 35 99 12 101 74 36 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF; BWIPP no manual mode" }, + /* 78*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^", -1, 0, 68, 1, "(6) 104 33 60 62 31 106", "StartC 12 34 CodeB A B C CodeC 12 CodeA LF; BWIPP no manual mode" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -428,14 +458,14 @@ static void test_input(const testCtx *const p_ctx) { length = testUtilSetSymbol(symbol, BARCODE_CODE128, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); - assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { printf(" /*%3d*/ { %s, \"%s\", %d, %s, %d, %d, \"%s\", \"%s\" },\n", i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), data[i].length, - testUtilErrorName(data[i].ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); + testUtilErrorName(ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment); } else { - assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); + assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); + assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0 (width %d)\n", i, symbol->errtxt, data[i].expected, symbol->width); if (ret < ZINT_ERROR) { 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); @@ -667,43 +697,46 @@ static void test_dpd_input(const testCtx *const p_ctx) { struct item { int option_2; + int output_options; char *data; int ret; int expected_width; + float expected_height; char *expected; char *comment; }; struct item data[] = { - /* 0*/ { -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, "Error 349: DPD input wrong length (27 or 28 characters required)", "" }, - /* 1*/ { 1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, "Error 830: DPD relabel input wrong length (27 characters required)", "" }, - /* 2*/ { -1, "123456789012345678901234567", 0, 211, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "27 chars ok now, ident tag prefixed" }, - /* 3*/ { -1, "%123456789012345678901234567", 0, 211, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "" }, - /* 4*/ { 1, "123456789012345678901234567", 0, 200, "(18) 105 12 34 56 78 90 12 34 56 78 90 12 34 56 100 23 102 106", "27 chars also ok (and necessary) for relabel" }, - /* 5*/ { -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, "Error 349: DPD input wrong length (27 or 28 characters required)", "" }, - /* 6*/ { 1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, "Error 830: DPD relabel input wrong length (27 characters required)", "" }, - /* 7*/ { -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, "Error 299: Invalid character in data (alphanumerics only after first character)", "Alphanumerics only in body" }, - /* 8*/ { -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, "Error 300: Invalid character in data (alphanumerics only)", "Alphanumerics only in body" }, - /* 9*/ { -1, ",234567890123456789012345678", 0, 211, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" }, - /* 10*/ { -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char as DPD ident tag" }, - /* 11*/ { -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" }, - /* 12*/ { -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 13*/ { -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 14*/ { 1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 15*/ { -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 16*/ { -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 17*/ { 1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, - /* 18*/ { -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 19*/ { -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 20*/ { 1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 21*/ { -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 22*/ { -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 23*/ { 1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, - /* 24*/ { -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 25*/ { -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 26*/ { 1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 27*/ { -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 28*/ { -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, - /* 29*/ { 1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 0*/ { -1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input wrong length (27 or 28 characters required)", "" }, + /* 1*/ { 1, -1, "12345678901234567890123456", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input wrong length (27 characters required)", "" }, + /* 2*/ { -1, -1, "123456789012345678901234567", 0, 211, 50, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "27 chars ok now, ident tag prefixed" }, + /* 3*/ { -1, -1, "%123456789012345678901234567", 0, 211, 50, "(19) 104 5 17 99 23 45 67 89 1 23 45 67 89 1 23 45 67 51 106", "" }, + /* 4*/ { 1, -1, "123456789012345678901234567", 0, 200, 25, "(18) 105 12 34 56 78 90 12 34 56 78 90 12 34 56 100 23 102 106", "27 chars also ok (and necessary) for relabel" }, + /* 5*/ { -1, -1, "12345678901234567890123456789", ZINT_ERROR_TOO_LONG, -1, 0, "Error 349: DPD input wrong length (27 or 28 characters required)", "" }, + /* 6*/ { 1, -1, "1234567890123456789012345678", ZINT_ERROR_TOO_LONG, -1, 0, "Error 830: DPD relabel input wrong length (27 characters required)", "" }, + /* 7*/ { -1, -1, "123456789012345678901234567,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 299: Invalid character in data (alphanumerics only after first character)", "Alphanumerics only in body" }, + /* 8*/ { -1, -1, "12345678901234567890123456,", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 300: Invalid character in data (alphanumerics only)", "Alphanumerics only in body" }, + /* 9*/ { -1, -1, ",234567890123456789012345678", 0, 211, 50, "(19) 104 12 18 99 34 56 78 90 12 34 56 78 90 12 34 56 78 64 106", "Non-alphanumeric DPD ident tag (Barcode ID) allowed" }, + /* 10*/ { -1, -1, "\037234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Control char as DPD ident tag" }, + /* 11*/ { -1, -1, "é234567890123456789012345678", ZINT_ERROR_INVALID_DATA, -1, 0, "Error 343: Invalid DPD identification tag (first character), ASCII values 32 to 127 only", "Extended ASCII as DPD ident tag" }, + /* 12*/ { -1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 13*/ { -1, -1, "%12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 222, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 14*/ { 1, -1, "12345678901234567890123456A", ZINT_WARN_NONCOMPLIANT, 200, 25, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 15*/ { -1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 16*/ { -1, -1, "%123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 17*/ { 1, -1, "123456789012345678901234A67", ZINT_WARN_NONCOMPLIANT, 211, 25, "Warning 831: Destination Country Code (last 3 characters) should be numeric", "" }, + /* 18*/ { -1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 19*/ { -1, -1, "%12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 20*/ { 1, -1, "12345678901234567890123A567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 21*/ { -1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 22*/ { -1, -1, "%123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 23*/ { 1, -1, "123456789012345678901A34567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 832: Service Code (characters 6-4 from end) should be numeric", "" }, + /* 24*/ { -1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 25*/ { -1, -1, "%12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 233, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 26*/ { 1, -1, "12345678901234567890A234567", ZINT_WARN_NONCOMPLIANT, 211, 25, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 27*/ { -1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 28*/ { -1, -1, "%12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 244, 50, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 29*/ { 1, -1, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 25, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, + /* 30*/ { 1, COMPLIANT_HEIGHT, "12345678901A345678901234567", ZINT_WARN_NONCOMPLIANT, 222, 33.333332, "Warning 833: Last 10 characters of Tracking Number (characters 16-7 from end) should be numeric", "" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; @@ -722,18 +755,20 @@ static void test_dpd_input(const testCtx *const p_ctx) { symbol->debug = ZINT_DEBUG_TEST; /* Needed to get codeword dump in errtxt */ - length = testUtilSetSymbol(symbol, BARCODE_DPD, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, -1 /*output_options*/, data[i].data, -1, debug); + length = testUtilSetSymbol(symbol, BARCODE_DPD, UNICODE_MODE, -1 /*eci*/, -1 /*option_1*/, data[i].option_2, -1, data[i].output_options, data[i].data, -1, debug); ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length); assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt); if (p_ctx->generate) { - printf(" /*%3d*/ { %d, \"%s\", %s, %d, \"%s\", \"%s\" },\n", - i, data[i].option_2, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), - testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment); + printf(" /*%3d*/ { %d, %s, \"%s\", %s, %d, %.8g, \"%s\", \"%s\" },\n", + i, data[i].option_2, testUtilOutputOptionsName(data[i].output_options), + testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), + testUtilErrorName(data[i].ret), symbol->width, symbol->height, symbol->errtxt, data[i].comment); } else { if (ret < ZINT_ERROR) { 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->height, data[i].expected_height, "i:%d symbol->height %.8g != %.8g (%s)\n", i, symbol->height, data[i].expected_height, data[i].data); } assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected); } @@ -773,6 +808,8 @@ static void test_upu_s10_input(const testCtx *const p_ctx) { /* 15*/ { "JB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 839: Invalid Service Indicator (first character should not be any of \"JKSTW\")", "" }, /* 16*/ { "FB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 840: Non-standard Service Indicator (first 2 characters)", "" }, /* 17*/ { "AB123456785AB", ZINT_WARN_NONCOMPLIANT, 156, "Warning 841: Country code (last two characters) is not ISO 3166-1", "" }, + /* 18*/ { "AB123100000IE", 0, 156, "", "Check digit 10 -> 0" }, + /* 19*/ { "AB000000005IE", 0, 156, "", "Check digit 11 -> 5" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_common.c b/backend/tests/test_common.c index f7b47277..e5c2e43d 100644 --- a/backend/tests/test_common.c +++ b/backend/tests/test_common.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -381,6 +381,8 @@ static void test_set_height(const testCtx *const p_ctx) { testFinish(); } +INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int *codewords, const int length); + static void test_debug_test_codeword_dump_int(const testCtx *const p_ctx) { int debug = p_ctx->debug; diff --git a/backend/tests/test_gb18030.c b/backend/tests/test_gb18030.c index 8ddb642b..ab96cf93 100644 --- a/backend/tests/test_gb18030.c +++ b/backend/tests/test_gb18030.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -554,7 +554,10 @@ static void test_perf(const testCtx *const p_ctx) { int i, length, ret; struct zint_symbol symbol = {0}; - int ret_length, ret_length2; + int ret_length; +#ifdef TEST_JUST_SAY_GNO + int ret_length2; +#endif unsigned int ddata[8192]; unsigned char dest[8192]; int ret2 = 0; @@ -585,13 +588,14 @@ static void test_perf(const testCtx *const p_ctx) { diff = diff_gno = diff_eci = 0; for (j = 0; j < TEST_PERF_ITERATIONS; j++) { - ret_length = ret_length2 = length; + ret_length = length; start = clock(); ret = gb18030_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, ddata); diff += clock() - start; #ifdef TEST_JUST_SAY_GNO + ret_length2 = length; start = clock(); ret2 = gb18030_utf8_wctomb(&symbol, (unsigned char *) data[i].data, &ret_length2, ddata2); diff_gno += clock() - start; diff --git a/backend/tests/test_gb2312.c b/backend/tests/test_gb2312.c index 6bd41200..e79b1a6a 100644 --- a/backend/tests/test_gb2312.c +++ b/backend/tests/test_gb2312.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -392,7 +392,10 @@ static void test_perf(const testCtx *const p_ctx) { int i, length, ret; struct zint_symbol symbol = {0}; - int ret_length, ret_length2; + int ret_length; +#ifdef TEST_JUST_SAY_GNO + int ret_length2; +#endif unsigned int ddata[8192]; unsigned char dest[8192]; int ret2 = 0; @@ -424,25 +427,27 @@ static void test_perf(const testCtx *const p_ctx) { diff = diff_gno = diff_eci = diff_eci_gno = 0; for (j = 0; j < TEST_PERF_ITERATIONS; j++) { - ret_length = ret_length2 = length; + ret_length = length; start = clock(); ret = gb2312_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, ddata); diff += clock() - start; #ifdef TEST_JUST_SAY_GNO + ret_length2 = length; start = clock(); ret2 = gb2312_utf8_wctomb(&symbol, (unsigned char *) data[i].data, &ret_length2, ddata2); diff_gno += clock() - start; #endif - ret_length = ret_length2 = length; + ret_length = length; start = clock(); (void)utf8_to_eci(29, (unsigned char *) data[i].data, dest, &ret_length); diff_eci += clock() - start; #ifdef TEST_JUST_SAY_GNO + ret_length2 = length; start = clock(); (void)utf8_to_eci_wctomb(29, (unsigned char *) data[i].data, dest2, &ret_length2); diff_eci_gno += clock() - start; diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index 58a4bb71..f99e1edd 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -547,7 +547,11 @@ static void test_escape_char_process(const testCtx *const p_ctx) { /* 73*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 34, "\\U10FFFF", "", 0, 16, "F1 23 01 01 01 01 01 01 EB 80 EB 80 F6 F1 5D 2A D1 0A BF BC B8 22 65 0C", 0, "" }, /* 74*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 35, "\\U10FFFF", "", 0, 16, "F1 24 01 01 01 01 EB 80 EB 80 01 01 7F 58 28 41 7F 63 0E EB A7 D8 D0 1F", 0, "" }, /* 75*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[20]10", "[10]A", 0, 99, "(7) 105 102 20 10 100 59 106", 0, "" }, - /* 76*/ { BARCODE_GS1_128_CC, GS1_MODE | ESCAPE_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" }, + /* 76*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" }, + /* 77*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid for Code 128 in extra escape mode", 0, "" }, + /* 78*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" }, + /* 79*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" }, + /* 80*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", 0, 79, "(7) 104 60 62 36 17 52 106", 0, "Unknown special escapes passed straight thu" }, }; int data_size = ARRAY_SIZE(data); int i, length, ret; diff --git a/backend/tests/test_pdf417.c b/backend/tests/test_pdf417.c index 0996246c..83441c37 100644 --- a/backend/tests/test_pdf417.c +++ b/backend/tests/test_pdf417.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -424,7 +424,7 @@ static void test_input(const testCtx *const p_ctx) { int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol; - int last_fast_num_cwds; + int last_fast_num_cwds = 0; /* Keep clang-tidy happy */ char escaped[1024]; char cmp_buf[32768]; @@ -3925,7 +3925,7 @@ static void test_encode(const testCtx *const p_ctx) { int data_size = ARRAY_SIZE(data); int i, length, ret; struct zint_symbol *symbol; - int last_fast_num_cwds; + int last_fast_num_cwds = 0; /* Keep clang-tidy happy */ char escaped[1024]; char cmp_buf[32768]; @@ -4663,7 +4663,7 @@ static void test_encode_segs(const testCtx *const p_ctx) { int data_size = ARRAY_SIZE(data); int i, j, seg_count, ret; struct zint_symbol *symbol; - int last_fast_num_cwds; + int last_fast_num_cwds = 0; /* Keep clang-tidy happy */ char escaped[1024]; char cmp_buf[32768]; diff --git a/backend/tests/test_sjis.c b/backend/tests/test_sjis.c index 947bbe5b..c94830ad 100644 --- a/backend/tests/test_sjis.c +++ b/backend/tests/test_sjis.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -401,7 +401,10 @@ static void test_perf(const testCtx *const p_ctx) { int i, length, ret; struct zint_symbol symbol = {0}; - int ret_length, ret_length2; + int ret_length; +#ifdef TEST_JUST_SAY_GNO + int ret_length2; +#endif unsigned int ddata[8192]; int ret2 = 0; #ifdef TEST_JUST_SAY_GNO @@ -431,13 +434,14 @@ static void test_perf(const testCtx *const p_ctx) { diff = diff_gno = 0; for (j = 0; j < TEST_PERF_ITERATIONS; j++) { - ret_length = ret_length2 = length; + ret_length = length; start = clock(); ret = sjis_utf8(&symbol, (unsigned char *) data[i].data, &ret_length, ddata); diff += clock() - start; #ifdef TEST_JUST_SAY_GNO + ret_length2 = length; start = clock(); ret2 = sjis_utf8_wctomb(&symbol, (unsigned char *) data[i].data, &ret_length2, ddata2); diff_gno += clock() - start; diff --git a/backend/tests/testcommon.c b/backend/tests/testcommon.c index dc18b9ea..3288841a 100644 --- a/backend/tests/testcommon.c +++ b/backend/tests/testcommon.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2019-2022 Robin Stuart + Copyright (C) 2019-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -453,6 +453,7 @@ const char *testUtilInputModeName(int input_mode) { { "GS1NOCHECK_MODE", GS1NOCHECK_MODE, 0x0020 }, { "HEIGHTPERROW_MODE", HEIGHTPERROW_MODE, 0x0040 }, { "FAST_MODE", FAST_MODE, 0x0080 }, + { "EXTRA_ESCAPE_MODE", EXTRA_ESCAPE_MODE, 0x0100 }, }; static const int data_size = ARRAY_SIZE(data); int set, i; @@ -2308,14 +2309,31 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch /*case 'x': val = 0; TODO: implement break; */ case '\\': val = '\\'; break; /*case 'u': val = 0; TODO: implement break; */ + case '^': val = -1; break; /* Code 128 special escapes */ default: fprintf(stderr, "testUtilBwippEscape: unknown escape %c\n", *d); return NULL; break; } - if (b + 4 >= be) { - fprintf(stderr, "testUtilBwippEscape: loop bwipp_data buffer full (%d)\n", bwipp_data_size); - return NULL; + if (val >= 0) { + if (b + 4 >= be) { + fprintf(stderr, "testUtilBwippEscape: loop bwipp_data buffer full (%d)\n", bwipp_data_size); + return NULL; + } + sprintf(b, "^%03d", val); + b += 4; + } else { + if (d + 1 < de && *(d + 1) >= 'A' && *(d + 1) <= 'C') { + d++; + } else { + if (b + 8 >= be) { + fprintf(stderr, "testUtilBwippEscape: loop bwipp_data buffer full (%d)\n", bwipp_data_size); + return NULL; + } + sprintf(b, "^%03d^%03d", '\\', *d); + b += 8; + if (*d == '^') { + d++; + } + } } - sprintf(b, "^%03d", val); - b += 4; d++; *parse = 1; } else { @@ -2565,8 +2583,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int /* sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%sdontlint", strlen(bwipp_opts_buf) ? " " : ""); */ } } else { - if (testUtilBwippEscape(bwipp_data, bwipp_data_size, data, data_len, symbol->input_mode & ESCAPE_MODE, - eci, &parse, &parsefnc) == NULL) { + if (testUtilBwippEscape(bwipp_data, bwipp_data_size, data, data_len, + symbol->input_mode & (ESCAPE_MODE | EXTRA_ESCAPE_MODE), eci, &parse, &parsefnc) == NULL) { return -1; } if (parse) { @@ -2832,7 +2850,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int strlen(bwipp_opts_buf) ? " " : "", mode); bwipp_opts = bwipp_opts_buf; } - if (primary_len) { + if (primary_len >= 6) { /* Keep gcc happy */ char prefix_buf[30]; int prefix_len; int postcode_len = primary_len - 6; @@ -3669,7 +3687,8 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in const int is_dbar_exp = symbology == BARCODE_DBAR_EXP || symbology == BARCODE_DBAR_EXPSTK; const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE || is_dbar_exp; - const int is_escaped = symbol->input_mode & ESCAPE_MODE; + const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128; + const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped; const int is_hibc = symbology >= BARCODE_HIBC_128 && symbology <= BARCODE_HIBC_AZTEC; const int have_c25checkdigit = symbol->option_2 == 1 || symbol->option_2 == 2; const int have_c25inter = (symbology == BARCODE_C25INTER && ((expected_len & 1) || have_c25checkdigit)) @@ -3677,13 +3696,14 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in || symbology == BARCODE_DPIDENT; const int is_upcean = is_extendable(symbology); const int need_dpd_prefix = (symbology == BARCODE_DPD && expected_len == 27 && symbol->option_2 != 1); + const int is_vin_international = symbology == BARCODE_VIN && (symbol->option_2 & 1); char *reduced = gs1 ? (char *) z_alloca(expected_len + 1) : NULL; char *escaped = is_escaped ? (char *) z_alloca(expected_len + 1) : NULL; char *hibc = is_hibc ? (char *) z_alloca(expected_len + 2 + 1) : NULL; char *maxi = symbology == BARCODE_MAXICODE && primary ? (char *) z_alloca(expected_len + strlen(primary) + 6 + 9 + 1) : NULL; - char *vin = symbology == BARCODE_VIN && (symbol->option_2 & 1) ? (char *) z_alloca(expected_len + 1 + 1) : NULL; + char *vin = is_vin_international ? (char *) z_alloca(expected_len + 1 + 1) : NULL; char *c25inter = have_c25inter ? (char *) z_alloca(expected_len + 13 + 1 + 1) : NULL; char *upcean = is_upcean ? (char *) z_alloca(expected_len + 1 + 1) : NULL; char *ean14_nve18 = symbology == BARCODE_EAN14 || symbology == BARCODE_NVE18 @@ -3704,10 +3724,31 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in if (is_escaped) { memcpy(escaped, expected, expected_len); - ret = escape_char_process_test(symbol, (unsigned char *) escaped, &expected_len); - if (ret != 0) { - sprintf(msg, "escape_char_process %d != 0", ret); - return 3; + if (symbol->input_mode & ESCAPE_MODE) { + ret = escape_char_process_test(symbol, (unsigned char *) escaped, &expected_len); + if (ret != 0) { + sprintf(msg, "escape_char_process %d != 0", ret); + return 3; + } + } + if (is_extra_escaped) { + /* Remove any Code 128 special escapes */ + int j = 0; + for (i = 0; i < expected_len; i++) { + if (escaped[i] == '\\' && i + 2 < expected_len && escaped[i + 1] == '^' + && ((escaped[i + 2] >= 'A' && escaped[i + 2] <= 'C') || escaped[i + 2] == '^')) { + if (escaped[i + 2] != '^') { + i += 2; + } else { + escaped[j++] = escaped[i++]; + escaped[j++] = escaped[i++]; + } + } else { + escaped[j++] = escaped[i]; + } + } + expected_len = j; + escaped[expected_len] = '\0'; } expected = escaped; } @@ -3778,13 +3819,11 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in if (symbol->option_2 == 1 || symbol->option_2 == 2) { cmp_len--; /* Too messy to calc the check digit so ignore */ } - } else if (symbology == BARCODE_VIN) { - if (symbol->option_2 & 1) { - vin[0] = 'I'; - memcpy(vin + 1, expected, expected_len); - vin[++expected_len] = '\0'; - expected = vin; - } + } else if (is_vin_international) { + vin[0] = 'I'; + memcpy(vin + 1, expected, expected_len); + vin[++expected_len] = '\0'; + expected = vin; } else if (have_c25inter) { if (symbology == BARCODE_C25INTER) { if ((expected_len & 1) || have_c25checkdigit) { diff --git a/backend/zint.h b/backend/zint.h index 43b23670..7cf55fbe 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -1,7 +1,7 @@ /* zint.h - definitions for libzint */ /* libzint - the open source barcode library - Copyright (C) 2009-2022 Robin Stuart + Copyright (C) 2009-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -61,7 +61,7 @@ extern "C" { float x, y; /* Top with x relative to halign (i.e. centre, left, right) */ float fsize; /* Font size */ float width; /* Suggested string width, may be 0 if none recommended */ - int length; /* Number of characters */ + int length; /* Number of characters (bytes) */ int rotation; /* 0, 90, 180, 270 degrees */ int halign; /* Horizontal alignment: 0 for centre, 1 for left, 2 for right (end) */ unsigned char *text; /* UTF-8, NUL-terminated */ @@ -303,6 +303,8 @@ extern "C" { #define HEIGHTPERROW_MODE 0x0040 /* Interpret `height` as per-row rather than as overall height */ #define FAST_MODE 0x0080 /* Use faster if less optimal encodation or other shortcuts if available */ /* Note: affects DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only */ +#define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences */ + /* Note: currently Code 128 only */ /* Data Matrix specific options (`symbol->option_3`) */ #define DM_SQUARE 100 /* Only consider square versions on automatic symbol size selection */ diff --git a/backend_qt/qzint.cpp b/backend_qt/qzint.cpp index 382dea3c..86303556 100644 --- a/backend_qt/qzint.cpp +++ b/backend_qt/qzint.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * Copyright (C) 2008 by BogDan Vatra * * bogdan@licentia.eu * - * Copyright (C) 2010-2022 Robin Stuart * + * Copyright (C) 2010-2023 Robin Stuart * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -1163,6 +1163,7 @@ namespace Zint { } arg_bool(cmd, "--esc", inputMode() & ESCAPE_MODE); + arg_bool(cmd, "--extraesc", inputMode() & EXTRA_ESCAPE_MODE); arg_bool(cmd, "--fast", inputMode() & FAST_MODE); if (fgColor() != Qt::black) { diff --git a/backend_qt/tests/test_qzint.cpp b/backend_qt/tests/test_qzint.cpp index ea69837d..a3184c33 100644 --- a/backend_qt/tests/test_qzint.cpp +++ b/backend_qt/tests/test_qzint.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2021-2022 by Robin Stuart * + * Copyright (C) 2021-2023 by Robin Stuart * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -608,6 +608,19 @@ private slots: " --rotate=90 --verbose --vers=7" << "" << "" << "" << ""; + QTest::newRow("BARCODE_CODE128") << false << 0.0f << "" + << BARCODE_CODE128 << (UNICODE_MODE | EXTRA_ESCAPE_MODE) // symbology-inputMode + << "1234\\^A56" << "" // text-primary + << 0.0f << -1 << 0 << 0 << 1.0f << 0.0f << false << 0.8f // height-dotSize + << 5.0f << 0 << 0 << "" << QColor(Qt::black) << QColor(Qt::white) // guardDescent-bgColor + << false << 0 << 0 << 0 << 0 << 0 // cmyk-fontSetting + << false << false << true << false << true << 0 // showText-rotateAngle + << 0 << false << false << false << WARN_DEFAULT << false // eci-debug + << 0.0 << 0 << 0 << 0 << 0 << 0 // xdimdp + << "zint -b 20 -d '1234\\^A56' --extraesc --notext --quietzones" + << "zint.exe -b 20 -d \"1234\\^A56\" --extraesc --notext --quietzones" + << "" << "" << "" << ""; + QTest::newRow("BARCODE_GS1_128_CC") << false << 0.0f << "" << BARCODE_GS1_128_CC << UNICODE_MODE // symbology-inputMode << "[01]12345678901231[15]121212" << "[11]901222[99]ABCDE" // text-primary diff --git a/backend_tcl/zint.c b/backend_tcl/zint.c index 5b52a7ae..494d1fc3 100644 --- a/backend_tcl/zint.c +++ b/backend_tcl/zint.c @@ -1,7 +1,7 @@ /* zint_tcl.c TCL binding for zint */ /* zint - the open source tcl binding to the zint barcode library - Copyright (C) 2014-2022 Harald Oehlmann + Copyright (C) 2014-2023 Harald Oehlmann Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -164,6 +164,8 @@ *** Potential incompatibility *** 2022-12-09 GL - Added UPU_S10 +2023-01-15 GL +- Added -esc and -extraesc options */ #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) @@ -511,7 +513,8 @@ static const char help_message[] = "zint tcl(stub,obj) dll\n" /* cli option --dump not supported */ /* cli option --ecinos not supported */ " -eci choice: ECI to use\n" - /* cli option --esc not supported */ + " -esc bool: Process escape sequences in input data\n" + " -extraesc bool: Process symbology-specific escape sequences (Code 128 only)\n" " -fast bool: use fast encodation (Data Matrix)\n" " -fg color: set foreground color as 6 or 8 hex rrggbbaa\n" /* replaces cli options --binary and --gs1 */ @@ -781,7 +784,7 @@ static int Encode(Tcl_Interp *interp, int objc, static const char *optionList[] = { "-addongap", "-barcode", "-bg", "-bind", "-bindtop", "-bold", "-border", "-box", "-cols", "-compliantheight", "-dmre", "-dotsize", "-dotty", - "-eci", "-fast", "-fg", "-format", "-fullmultibyte", + "-eci", "-esc", "-extraesc", "-fast", "-fg", "-format", "-fullmultibyte", "-gs1nocheck", "-gs1parens", "-gssep", "-guarddescent", "-height", "-heightperrow", "-init", "-mask", "-mode", "-nobackground", "-noquietzones", "-notext", "-primary", "-quietzones", @@ -793,7 +796,7 @@ static int Encode(Tcl_Interp *interp, int objc, enum iOption { iAddonGap, iBarcode, iBG, iBind, iBindTop, iBold, iBorder, iBox, iCols, iCompliantHeight, iDMRE, iDotSize, iDotty, - iECI, iFast, iFG, iFormat, iFullMultiByte, + iECI, iEsc, iExtraEsc, iFast, iFG, iFormat, iFullMultiByte, iGS1NoCheck, iGS1Parens, iGSSep, iGuardDescent, iHeight, iHeightPerRow, iInit, iMask, iMode, iNoBackground, iNoQuietZones, iNoText, iPrimary, iQuietZones, @@ -824,6 +827,8 @@ static int Encode(Tcl_Interp *interp, int objc, case iCompliantHeight: case iDMRE: case iDotty: + case iEsc: + case iExtraEsc: case iFast: case iGS1NoCheck: case iGS1Parens: @@ -997,6 +1002,20 @@ static int Encode(Tcl_Interp *interp, int objc, my_symbol->output_options &= ~BARCODE_DOTTY_MODE; } break; + case iEsc: + if (intValue) { + my_symbol->input_mode |= ESCAPE_MODE; + } else { + my_symbol->input_mode &= ~ESCAPE_MODE; + } + break; + case iExtraEsc: + if (intValue) { + my_symbol->input_mode |= EXTRA_ESCAPE_MODE; + } else { + my_symbol->input_mode &= ~EXTRA_ESCAPE_MODE; + } + break; case iFast: if (intValue) { my_symbol->input_mode |= FAST_MODE; diff --git a/docs/images/gui_set_printing_scale.png b/docs/images/gui_set_printing_scale.png index 6a3bbe19..6bac06a6 100644 Binary files a/docs/images/gui_set_printing_scale.png and b/docs/images/gui_set_printing_scale.png differ diff --git a/docs/manual.pmd b/docs/manual.pmd index 7d87103f..10347360 100644 --- a/docs/manual.pmd +++ b/docs/manual.pmd @@ -1,6 +1,6 @@ % Zint Barcode Generator and Zint Barcode Studio User Manual % Version 2.12.0.9 -% December 2022 +% January 2023 # 1. Introduction @@ -81,6 +81,8 @@ GS1 data 'chunks' of data, each of which starts with an Application Identifier (AI). The AI identifies what type of information is being encoded. +\clearpage + Reader Initialisation (Programming) : Some symbologies allow a special character to be included which can be @@ -516,6 +518,9 @@ Table: {#tbl:escape_sequences tag=": Escape Sequences"} codeset from U+0000 to U+D7FF and U+E000 to U+FFFF (i.e. excluding surrogates). Not to be confused with the Windows Bitmap file format BMP! +(Special escape sequences are available for Code 128 only to manually switch +Code Sets - see [6.1.10.1 Standard Code 128 (ISO 15417)] for details.) + Input data can be read directly from file using the `-i` or `--input` switch as shown below. The input file is assumed to be UTF-8 formatted unless an alternative mode is selected. This command replaces the use of the `-d` switch. @@ -1501,9 +1506,9 @@ you wish. ## 5.1 Creating and Deleting Symbols The symbols manipulated by Zint are held in a `zint_symbol` structure defined in -`"zint.h"`. These symbols are created with the `ZBarcode_Create()` function and -deleted using the `ZBarcode_Delete()` function. For example the following code -creates and then deletes a symbol: +`"zint.h"`. These symbol structures are created with the `ZBarcode_Create()` +function and deleted using the `ZBarcode_Delete()` function. For example the +following code creates and then deletes a symbol: ```c #include @@ -2110,6 +2115,10 @@ Value Effect `FAST_MODE` Use faster if less optimal encodation or other shortcuts if available (affects `DATAMATRIX`, `MICROPDF417`, `PDF417`, `QRCODE` and `UPNQR` only). + +`EXTRA_ESCAPE_MODE` Process special symbology-specific escape sequences + (`CODE128` only). + -------------------------------------------------------------------------------- Table: API `input_mode` Values {#tbl:api_input_mode tag="$ $"} @@ -2118,8 +2127,8 @@ The default mode is `DATA_MODE`. (Note that this differs from the default for the CLI and GUI, which is `UNICODE_MODE`.) `DATA_MODE`, `UNICODE_MODE` and `GS1_MODE` are mutually exclusive, whereas -`ESCAPE_MODE`, `GS1PARENS_MODE`, `GS1NOCHECK_MODE`, `HEIGHTPERROW_MODE` and -`FAST_MODE` are optional. So, for example, you can set +`ESCAPE_MODE`, `GS1PARENS_MODE`, `GS1NOCHECK_MODE`, `HEIGHTPERROW_MODE`, +`FAST_MODE` and `EXTRA_ESCAPE_MODE` are optional. So, for example, you can set ```c my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE; @@ -2139,8 +2148,10 @@ my_symbol->input_mode = DATA_MODE | GS1_MODE; is not valid. -Permissible escape sequences are listed in Table {@tbl:escape_sequences}. An -example of `GS1PARENS_MODE` usage is given in section [6.1.10.3 GS1-128]. +Permissible escape sequences (`ESCAPE_MODE`) are listed in Table +{@tbl:escape_sequences}, and the special Code 128-only `EXTRA_ESCAPE_MODE` +escape sequences are given in [6.1.10.1 Standard Code 128 (ISO 15417)]. +An example of `GS1PARENS_MODE` usage is given in section [6.1.10.3 GS1-128]. `GS1NOCHECK_MODE` is for use with legacy systems that have data that does not conform to the current GS1 standard. Printable ASCII input is still checked for, @@ -2151,6 +2162,10 @@ For `HEIGHTPERROW_MODE`, see `--heightperrow` in section [4.4 Adjusting Height]. The `height` variable should be set to the desired per-row value on input (it will be set to the overall height on output). +`FAST_MODE` causes a less optimal encodation scheme to be used for Data Matrix, +MicroPDF417 and PDF417. For QR Code and UPNQR, it affects Zint's automatic mask +selection - see [6.6.3 QR Code (ISO 18004)] for details. + ## 5.11 Multiple Segments For input data requiring multiple ECIs, the following functions may be used: @@ -2243,7 +2258,7 @@ my_symbol->dpmm = 600.0f / 25.4f; /* 600 dpi */ my_symbol->scale = ZBarcode_Scale_From_XdimDp( my_symbol->symbology, ZBarcode_Default_Xdim(my_symbol->symbology), - my_symbol->dpmm, "PNG"); /* 7.5 */ + my_symbol->dpmm, "PNG"); /* Returns 7.5 */ ``` The third function `ZBarcode_XdimDP_From_Scale()` is the "reverse" of @@ -2488,7 +2503,6 @@ Identcode is based on Interleaved Code 2 of 5 and is used by Deutsche Post for identification purposes. Identcode requires an 11-digit numerical input to which Zint adds a check digit. - \clearpage ### 6.1.3 UPC (Universal Product Code) (ISO 15420) @@ -2784,8 +2798,28 @@ pharmaceuticals. The symbology is able to encode whole numbers between 3 and One of the most ubiquitous one-dimensional barcode symbologies, Code 128 was developed in 1981 by Computer Identics. This symbology supports full ASCII text and uses a three-Code Set system to compress the data into a smaller symbol. -Zint automatically switches between Code Sets A, B and C and adds a modulo-103 -check digit. +Zint automatically switches between Code Sets A, B and C (but see the special +escapes below) and adds a modulo-103 check digit. + +Manual switching of Code Sets is possible using the `--extraesc` option (API +`input_mode |= EXTRA_ESCAPE_MODE`) and the Code 128-specific escapes `\^A`, +`\^B`, `\^C`. For instance the following will force switching to Code Set B for +the data `"5678"` (normally Code Set C would be used throughout): + +```bash +zint -b CODE128 -d "1234\^B5678" --extraesc +``` + +The manually selected Code Set will apply until the next Code Set escape +sequence, with the exception that data that cannot be represented in that Code +Set will be switched as appropriate. If the data contains a special code +sequence, it can be escaped by doubling the caret (`^`). For instance + +```bash +zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc +``` + +will encode the data `"ABC\^BDEF"` in Code Set A. Code 128 is the default barcode symbology used by Zint. In addition Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128 @@ -2800,6 +2834,9 @@ It is sometimes advantageous to stop Code 128 from using Code Set C which compresses numerical data. The `BARCODE_CODE128AB`[^10] variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B. +Note that the special escapes to manually switch Code Sets mentioned above are +not available for this variant (nor for any other). + [^10]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is still recognised. @@ -2895,6 +2932,8 @@ A DPD Code can be marked as a "relabel" by specifying `--vers=1` (API `option_2 = 1`), which omits the identification tag and prints the barcode at half height. In this case, an input of 27 alphanumeric characters is required. +\clearpage + #### 6.1.10.8 UPU S10 ![`zint -b UPU_S10 --compliantheight -d "EE876543216CA"`](images/upu_s10.svg) @@ -3006,7 +3045,6 @@ input must be alphanumeric, excluding the letter `O`, and must be from 7 to 18 characters in length. A single check character is added by Zint, appearing in the 2nd character position. Lowercase input is automatically made uppercase. - \clearpage ## 6.2 Stacked Symbologies @@ -4267,7 +4305,7 @@ maximum of 90 digits and does not include a check digit. ## 7.1 License -Zint, libzint and Zint Barcode Studio are Copyright © 2022 Robin Stuart. All +Zint, libzint and Zint Barcode Studio are Copyright © 2023 Robin Stuart. All historical versions are distributed under the GNU General Public License version 3 or later. Versions 2.5 and later are released under a dual license: the encoding library is released under the BSD (3 clause) license whereas the diff --git a/docs/manual.txt b/docs/manual.txt index c22c74cb..e302b6b4 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -1,6 +1,6 @@ Zint Barcode Generator and Zint Barcode Studio User Manual Version 2.12.0.9 -December 2022 +January 2023 ******************************************************************************* * For reference the following is a text-only version of the Zint manual, * @@ -665,6 +665,9 @@ sequences are shown in the table below. : Table : Escape Sequences: +(Special escape sequences are available for Code 128 only to manually switch +Code Sets - see 6.1.10.1 Standard Code 128 (ISO 15417) for details.) + Input data can be read directly from file using the -i or --input switch as shown below. The input file is assumed to be UTF-8 formatted unless an alternative mode is selected. This command replaces the use of the -d switch. @@ -1559,9 +1562,9 @@ wish. 5.1 Creating and Deleting Symbols The symbols manipulated by Zint are held in a zint_symbol structure defined in -"zint.h". These symbols are created with the ZBarcode_Create() function and -deleted using the ZBarcode_Delete() function. For example the following code -creates and then deletes a symbol: +"zint.h". These symbol structures are created with the ZBarcode_Create() +function and deleted using the ZBarcode_Delete() function. For example the +following code creates and then deletes a symbol: #include #include @@ -2116,6 +2119,9 @@ property. Valid values are shown in the table below. FAST_MODE Use faster if less optimal encodation or other shortcuts if available (affects DATAMATRIX, MICROPDF417, PDF417, QRCODE and UPNQR only). + + EXTRA_ESCAPE_MODE Process special symbology-specific escape sequences + (CODE128 only). ------------------------------------------------------------------------------- : Table  : API input_mode Values @@ -2124,8 +2130,8 @@ The default mode is DATA_MODE. (Note that this differs from the default for the CLI and GUI, which is UNICODE_MODE.) DATA_MODE, UNICODE_MODE and GS1_MODE are mutually exclusive, whereas -ESCAPE_MODE, GS1PARENS_MODE, GS1NOCHECK_MODE, HEIGHTPERROW_MODE and FAST_MODE -are optional. So, for example, you can set +ESCAPE_MODE, GS1PARENS_MODE, GS1NOCHECK_MODE, HEIGHTPERROW_MODE, FAST_MODE and +EXTRA_ESCAPE_MODE are optional. So, for example, you can set my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE; @@ -2139,8 +2145,10 @@ whereas is not valid. -Permissible escape sequences are listed in Table : Escape Sequences. An example -of GS1PARENS_MODE usage is given in section 6.1.10.3 GS1-128. +Permissible escape sequences (ESCAPE_MODE) are listed in Table +: Escape Sequences, and the special Code 128-only EXTRA_ESCAPE_MODE escape +sequences are given in 6.1.10.1 Standard Code 128 (ISO 15417). An example of +GS1PARENS_MODE usage is given in section 6.1.10.3 GS1-128. GS1NOCHECK_MODE is for use with legacy systems that have data that does not conform to the current GS1 standard. Printable ASCII input is still checked for, @@ -2151,6 +2159,10 @@ For HEIGHTPERROW_MODE, see --heightperrow in section 4.4 Adjusting Height. The height variable should be set to the desired per-row value on input (it will be set to the overall height on output). +FAST_MODE causes a less optimal encodation scheme to be used for Data Matrix, +MicroPDF417 and PDF417. For QR Code and UPNQR, it affects Zint’s automatic mask +selection - see 6.6.3 QR Code (ISO 18004) for details. + 5.11 Multiple Segments For input data requiring multiple ECIs, the following functions may be used: @@ -2234,7 +2246,7 @@ For example: my_symbol->scale = ZBarcode_Scale_From_XdimDp( my_symbol->symbology, ZBarcode_Default_Xdim(my_symbol->symbology), - my_symbol->dpmm, "PNG"); /* 7.5 */ + my_symbol->dpmm, "PNG"); /* Returns 7.5 */ The third function ZBarcode_XdimDP_From_Scale() is the “reverse” of ZBarcode_Scale_From_XdimDp(), returning the X-dimension (in mm) or the dot @@ -2736,8 +2748,24 @@ pharmaceuticals. The symbology is able to encode whole numbers between 3 and One of the most ubiquitous one-dimensional barcode symbologies, Code 128 was developed in 1981 by Computer Identics. This symbology supports full ASCII text and uses a three-Code Set system to compress the data into a smaller symbol. -Zint automatically switches between Code Sets A, B and C and adds a modulo-103 -check digit. +Zint automatically switches between Code Sets A, B and C (but see the special +escapes below) and adds a modulo-103 check digit. + +Manual switching of Code Sets is possible using the --extraesc option (API +input_mode |= EXTRA_ESCAPE_MODE) and the Code 128-specific escapes \^A, \^B, +\^C. For instance the following will force switching to Code Set B for the data +"5678" (normally Code Set C would be used throughout): + + zint -b CODE128 -d "1234\^B5678" --extraesc + +The manually selected Code Set will apply until the next Code Set escape +sequence, with the exception that data that cannot be represented in that Code +Set will be switched as appropriate. If the data contains a special code +sequence, it can be escaped by doubling the caret (^). For instance + + zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc + +will encode the data "ABC\^BDEF" in Code Set A. Code 128 is the default barcode symbology used by Zint. In addition Zint supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128 @@ -2752,6 +2780,9 @@ It is sometimes advantageous to stop Code 128 from using Code Set C which compresses numerical data. The BARCODE_CODE128AB[10] variant (symbology 60) suppresses Code Set C in favour of Code Sets A and B. +Note that the special escapes to manually switch Code Sets mentioned above are +not available for this variant (nor for any other). + 6.1.10.3 GS1-128 [zint -b GS1_128 --compliantheight -d "[01]98898765432106[3202]012345[15]991231"] @@ -4138,7 +4169,7 @@ maximum of 90 digits and does not include a check digit. 7.1 License -Zint, libzint and Zint Barcode Studio are Copyright © 2022 Robin Stuart. All +Zint, libzint and Zint Barcode Studio are Copyright © 2023 Robin Stuart. All historical versions are distributed under the GNU General Public License version 3 or later. Versions 2.5 and later are released under a dual license: the encoding library is released under the BSD (3 clause) license whereas the GUI, @@ -4346,7 +4377,7 @@ defined. Annex B. Man Page ZINT(1) -% ZINT(1) Version 2.12.0.9 % % December 2022 +% ZINT(1) Version 2.12.0.9 % % January 2023 NAME @@ -4514,6 +4545,12 @@ OPTIONS \UNNNNNN (U+NNNNNN) Any 21-bit Unicode character where NNNNNN is hexadecimal +--extraesc + + Process the special escape sequences \^A, \^B and \^C that allow manual + switching of Code Sets (Code 128 only). The sequence \^^ can be used to + encode data that contains special escape sequences. + --fast Use faster if less optimal encodation or other shortcuts (affects Data @@ -4892,7 +4929,7 @@ AIM ITS/04-023 (2022) COPYRIGHT -Copyright © 2022 Robin Stuart. Released under GNU GPL 3.0 or later. +Copyright © 2023 Robin Stuart. Released under GNU GPL 3.0 or later. AUTHOR diff --git a/docs/zint.1 b/docs/zint.1 index 21e16ddc..534b4231 100644 --- a/docs/zint.1 +++ b/docs/zint.1 @@ -14,7 +14,7 @@ . ftr VB CB . ftr VBI CBI .\} -.TH "ZINT" "1" "December 2022" "Version 2.12.0.9" "" +.TH "ZINT" "1" "January 2023" "Version 2.12.0.9" "" .hy .SH NAME .PP @@ -199,6 +199,13 @@ The escape sequences are: .fi .RE .TP +\f[V]--extraesc\f[R] +Process the special escape sequences \f[V]\[rs]\[ha]A\f[R], +\f[V]\[rs]\[ha]B\f[R] and \f[V]\[rs]\[ha]C\f[R] that allow manual +switching of Code Sets (Code 128 only). +The sequence \f[V]\[rs]\[ha]\[ha]\f[R] can be used to encode data that +contains special escape sequences. +.TP \f[V]--fast\f[R] Use faster if less optimal encodation or other shortcuts (affects Data Matrix, MicroPDF417, PDF417, QRCODE & UPNQR only). @@ -627,7 +634,7 @@ ISO/IEC 16390:2007, ISO/IEC 16023:2000, ISO/IEC 24728:2006, ISO/IEC (2022) .SH COPYRIGHT .PP -Copyright \[co] 2022 Robin Stuart. +Copyright \[co] 2023 Robin Stuart. Released under GNU GPL 3.0 or later. .SH AUTHOR .PP diff --git a/docs/zint.1.pmd b/docs/zint.1.pmd index 7dca801b..680d44f4 100644 --- a/docs/zint.1.pmd +++ b/docs/zint.1.pmd @@ -1,6 +1,6 @@ % ZINT(1) Version 2.12.0.9 % -% December 2022 +% January 2023 # NAME @@ -148,6 +148,11 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S \UNNNNNN (U+NNNNNN) Any 21-bit Unicode character where NNNNNN is hexadecimal +`--extraesc` + +: Process the special escape sequences `\^A`, `\^B` and `\^C` that allow manual switching of Code Sets (Code 128 + only). The sequence `\^^` can be used to encode data that contains special escape sequences. + `--fast` : Use faster if less optimal encodation or other shortcuts (affects Data Matrix, MicroPDF417, PDF417, QRCODE & UPNQR @@ -506,7 +511,7 @@ ISO/IEC 18004:2015, ISO/IEC 23941:2022, AIM ITS/04-023 (2022) # COPYRIGHT -Copyright © 2022 Robin Stuart. Released under GNU GPL 3.0 or later. +Copyright © 2023 Robin Stuart. Released under GNU GPL 3.0 or later. # AUTHOR diff --git a/frontend/main.c b/frontend/main.c index 95bdf17f..46941b22 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -164,7 +164,8 @@ static void usage(int no_png) { " --dump Dump hexadecimal representation to stdout\n" " -e, --ecinos Display ECI (Extended Channel Interpretation) table\n", stdout); fputs( " --eci=NUMBER Set the ECI code for the data (segment 0)\n" - " --esc Process escape characters in input data\n" + " --esc Process escape sequences in input data\n" + " --extraesc Process symbology-specific escape sequences (Code 128)\n" " --fast Use faster encodation or other shortcuts if available\n" " --fg=COLOUR Specify a foreground colour (in hex RGB/RGBA)\n", stdout); printf(" --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX%s/SVG/TIF/TXT\n", no_png_type); @@ -1184,7 +1185,7 @@ int main(int argc, char **argv) { enum options { OPT_ADDONGAP = 128, OPT_BATCH, OPT_BINARY, OPT_BG, OPT_BIND, OPT_BIND_TOP, OPT_BOLD, OPT_BORDER, OPT_BOX, OPT_CMYK, OPT_COLS, OPT_COMPLIANTHEIGHT, OPT_DIRECT, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP, - OPT_ECI, OPT_ESC, OPT_FAST, OPT_FG, OPT_FILETYPE, OPT_FONTSIZE, OPT_FULLMULTIBYTE, + OPT_ECI, OPT_ESC, OPT_EXTRAESC, OPT_FAST, OPT_FG, OPT_FILETYPE, OPT_FONTSIZE, OPT_FULLMULTIBYTE, OPT_GS1, OPT_GS1NOCHECK, OPT_GS1PARENS, OPT_GSSEP, OPT_GUARDDESCENT, OPT_HEIGHT, OPT_HEIGHTPERROW, OPT_INIT, OPT_MIRROR, OPT_MASK, OPT_MODE, OPT_NOBACKGROUND, OPT_NOQUIETZONES, OPT_NOTEXT, OPT_PRIMARY, OPT_QUIETZONES, @@ -1217,6 +1218,7 @@ int main(int argc, char **argv) { {"eci", 1, NULL, OPT_ECI}, {"ecinos", 0, NULL, 'e'}, {"esc", 0, NULL, OPT_ESC}, + {"extraesc", 0, NULL, OPT_EXTRAESC}, {"fast", 0, NULL, OPT_FAST}, {"fg", 1, 0, OPT_FG}, {"filetype", 1, NULL, OPT_FILETYPE}, @@ -1392,6 +1394,9 @@ int main(int argc, char **argv) { case OPT_ESC: my_symbol->input_mode |= ESCAPE_MODE; break; + case OPT_EXTRAESC: + my_symbol->input_mode |= EXTRA_ESCAPE_MODE; + break; case OPT_FAST: my_symbol->input_mode |= FAST_MODE; break; diff --git a/frontend/tests/test_args.c b/frontend/tests/test_args.c index 5e4f1049..5f4ab1dc 100644 --- a/frontend/tests/test_args.c +++ b/frontend/tests/test_args.c @@ -1,6 +1,6 @@ /* libzint - the open source barcode library - Copyright (C) 2020-2022 Robin Stuart + Copyright (C) 2020-2023 Robin Stuart Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -214,6 +214,9 @@ static void arg_input_mode(char *cmd, int input_mode) { if (input_mode & ESCAPE_MODE) { sprintf(cmd + (int) strlen(cmd), "%s--esc", strlen(cmd) ? " " : ""); } + if (input_mode & EXTRA_ESCAPE_MODE) { + sprintf(cmd + (int) strlen(cmd), "%s--extraesc", strlen(cmd) ? " " : ""); + } if (input_mode & FAST_MODE) { sprintf(cmd + (int) strlen(cmd), "%s--fast", strlen(cmd) ? " " : ""); } @@ -310,40 +313,42 @@ static void test_dump_args(const testCtx *const p_ctx) { /* 5*/ { BARCODE_CODE128, NULL, NULL, "123\n45\n", "7\n",-1, -1, 1, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Warning 144: Processing first input file 'test_dump_args1.txt' only\nD2 13 9B 39 65 C8 C9 8E B\nD3 97 62 3B 63 AC" }, /* 6*/ { BARCODE_CODE128, "\t", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 90 D2 1A 63 AC" }, /* 7*/ { BARCODE_CODE128, "\\t", NULL, NULL, NULL, ESCAPE_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 90 D2 1A 63 AC" }, - /* 8*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_BIND | BARCODE_BOX | BARCODE_BIND_TOP | SMALL_TEXT | BOLD_TEXT | CMYK_COLOUR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" }, - /* 9*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_DOTTY_MODE, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Error 224: Selected symbology cannot be rendered as dots" }, - /* 10*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 46 D8 C7 58\nD0 97 BB 12 46 88 C5 1A 3C 55 CC C7 58" }, - /* 11*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, 10, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 44 68 BC 98 EB\nD0 97 BB 12 46 2B BD 7B A3 47 8A 8D 18 EB" }, - /* 12*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, 3, -1, 0, -1, "D0 97 BA 58 51 88 B1 11 AC 46 36 C7 58\nD0 97 BB 12 46 88 C5 77 AF 74 62 C7 58\nD0 97 BA CE 5D EB DD 1A 3C 56 88 C7 58" }, - /* 13*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" }, - /* 14*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" }, - /* 15*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" }, - /* 16*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2\nB2 A6 D2 D5 64\nB2 AD AD 2D 64" }, - /* 17*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 0, 0, -1, "FF 54 7A BC 3A 9C 1D 5C 0F E8 A4\nFF 54 7E AE 3C 11 5F AB 8F E8 A4\nFF 54 6A F8 29 9F 1D 5F 8F E8 A4\nFF 54 57 9E 37 BA 1A F7 CF E8 A4\nFF 54 75 CC 36 F0 5D 73 0F E8 A4" }, - /* 18*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 4\n8F 0\nB2 C\nA6 0\nBA C\nD6 0\nEB 4\nE2 8\nFF C" }, - /* 19*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\nAC 7\n8A 4\nA0 3\nC2 2\nB5 1\n82 2\nBA 7\n8C C\nA0 5\n86 A\nFF F" }, - /* 20*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, FAST_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nA6 8C\nB2 F0\n98 B4\nB9 A8\nB8 CC\nF0 78\nA0 3C\n99 70\n85 1C\nDA B0\nE5 94\nA7 50\nFF FC" }, - /* 21*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\n80 04\n82 60\nC5 24\n98 A8\nA3 9C\nCB B8\nAF DC\n86 58\nF6 44\nAC 18\n90 54\nCF 30\nFF FC" }, - /* 22*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\n80 09 F9 BD\n82 4A E2 58\nC5 CD C9 A5\nD8 5C A5 FC\nE0 35 88 69\nCC FC B3 E6\nFF FF FF FF" }, - /* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\n80 25\n82 24\nC5 5D\n98 90\nA4 C7\nC8 A6\nB9 E9\n8E 02\nDE 91\nCD 6C\nA0 BB\n85 80\n98 2D\nE4 CA\nFF FF" }, - /* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, - /* 25*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nBA 03 BA 7D E5 31 B0 0D\n8B 6A 93 B6 E0 0A B8 3C\nBF 1D EA A7 EB ED A1 FB\n96 66 86 B6 C9 AE 92 40\nBF 65 E7 95 BC B7 FA E3\nCC 7C 90 CC D1 24 AB 5A\nFF FF FF FF FF FF FF FF" }, - /* 26*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, - /* 27*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nFA 9C\nBC 00\nD7 84\nED E0\nA4 E4\nA7 40\n9D 3C\nBF 50\nFA 24\nB1 68\nE5 04\n92 70\nFF FC" }, - /* 28*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" }, - /* 29*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" }, - /* 30*/ { BARCODE_DATAMATRIX, "(9\\x31)12(92)34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" }, - /* 31*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" }, - /* 32*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" }, - /* 33*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" }, - /* 34*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" }, - /* 35*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" }, - /* 36*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" }, - /* 37*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" }, - /* 38*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" }, - /* 39*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" }, - /* 40*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 80\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\n03 E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" }, - /* 41*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" }, + /* 8*/ { BARCODE_CODE128, "\\^Ab\011", NULL, NULL, NULL, EXTRA_ESCAPE_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 12 1B AF 43 4C A1 8E B" }, + /* 9*/ { BARCODE_CODE128, "\\^Ab\\t", NULL, NULL, NULL, ESCAPE_MODE | EXTRA_ESCAPE_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 12 1B AF 43 4C A1 8E B" }, + /* 10*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_BIND | BARCODE_BOX | BARCODE_BIND_TOP | SMALL_TEXT | BOLD_TEXT | CMYK_COLOUR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D2 13 9B 39 65 C8 C9 8E B" }, + /* 11*/ { BARCODE_CODE128, "123", NULL, NULL, NULL, -1, BARCODE_DOTTY_MODE, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "Error 224: Selected symbology cannot be rendered as dots" }, + /* 12*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 46 D8 C7 58\nD0 97 BB 12 46 88 C5 1A 3C 55 CC C7 58" }, + /* 13*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, 10, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "D0 97 BA 86 51 88 B1 11 AC 44 68 BC 98 EB\nD0 97 BB 12 46 2B BD 7B A3 47 8A 8D 18 EB" }, + /* 14*/ { BARCODE_CODABLOCKF, "ABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, 3, -1, 0, -1, "D0 97 BA 58 51 88 B1 11 AC 46 36 C7 58\nD0 97 BB 12 46 88 C5 77 AF 74 62 C7 58\nD0 97 BA CE 5D EB DD 1A 3C 56 88 C7 58" }, + /* 15*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "B2 D6 96 CA B5 6D 64" }, + /* 16*/ { BARCODE_CODE11, NULL, NULL, "123", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 1, "B2 D6 96 CA B5 64" }, + /* 17*/ { BARCODE_CODE11, "123", NULL, "456", NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2" }, + /* 18*/ { BARCODE_CODE11, "123", "456", "789", "012", -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, 2, "B2 D6 96 CA B2\nB2 B6 DA 9A B2\nB2 A6 D2 D5 64\nB2 AD AD 2D 64" }, + /* 19*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 0, 0, -1, "FF 54 7A BC 3A 9C 1D 5C 0F E8 A4\nFF 54 7E AE 3C 11 5F AB 8F E8 A4\nFF 54 6A F8 29 9F 1D 5F 8F E8 A4\nFF 54 57 9E 37 BA 1A F7 CF E8 A4\nFF 54 75 CC 36 F0 5D 73 0F E8 A4" }, + /* 20*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 4\n8F 0\nB2 C\nA6 0\nBA C\nD6 0\nEB 4\nE2 8\nFF C" }, + /* 21*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\nAC 7\n8A 4\nA0 3\nC2 2\nB5 1\n82 2\nBA 7\n8C C\nA0 5\n86 A\nFF F" }, + /* 22*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, FAST_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nA6 8C\nB2 F0\n98 B4\nB9 A8\nB8 CC\nF0 78\nA0 3C\n99 70\n85 1C\nDA B0\nE5 94\nA7 50\nFF FC" }, + /* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGH", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\n80 04\n82 60\nC5 24\n98 A8\nA3 9C\nCB B8\nAF DC\n86 58\nF6 44\nAC 18\n90 54\nCF 30\nFF FC" }, + /* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\n80 09 F9 BD\n82 4A E2 58\nC5 CD C9 A5\nD8 5C A5 FC\nE0 35 88 69\nCC FC B3 E6\nFF FF FF FF" }, + /* 25*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\n80 25\n82 24\nC5 5D\n98 90\nA4 C7\nC8 A6\nB9 E9\n8E 02\nDE 91\nCD 6C\nA0 BB\n85 80\n98 2D\nE4 CA\nFF FF" }, + /* 26*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, + /* 27*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nBA 03 BA 7D E5 31 B0 0D\n8B 6A 93 B6 E0 0A B8 3C\nBF 1D EA A7 EB ED A1 FB\n96 66 86 B6 C9 AE 92 40\nBF 65 E7 95 BC B7 FA E3\nCC 7C 90 CC D1 24 AB 5A\nFF FF FF FF FF FF FF FF" }, + /* 28*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA A8\nBA 5A 44\n8B 4D 28\nBF 77 64\n97 85 50\nBA D8 AC\nCD ED B8\nD4 B5 2C\nD1 A8 00\n81 FB 2C\nE4 75 78\n96 E8 2C\nF3 75 78\nEE 1D 04\nCA BA 98\nB1 8F B4\nA0 4F 00\nE4 A7 74\nF1 D3 90\nEF E1 BC\n91 10 38\nFF FF FC" }, + /* 29*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nFA 9C\nBC 00\nD7 84\nED E0\nA4 E4\nA7 40\n9D 3C\nBF 50\nFA 24\nB1 68\nE5 04\n92 70\nFF FC" }, + /* 30*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" }, + /* 31*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" }, + /* 32*/ { BARCODE_DATAMATRIX, "(9\\x31)12(92)34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" }, + /* 33*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" }, + /* 34*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" }, + /* 35*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" }, + /* 36*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" }, + /* 37*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" }, + /* 38*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" }, + /* 39*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" }, + /* 40*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "Warning 760: Converted to Shift JIS but no ECI specified\nFE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" }, + /* 41*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" }, + /* 42*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 80\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\n03 E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" }, + /* 43*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" }, }; int data_size = ARRAY_SIZE(data); int i; diff --git a/frontend_qt/extScale.ui b/frontend_qt/extScale.ui index efb1804b..c6dc8bcf 100644 --- a/frontend_qt/extScale.ui +++ b/frontend_qt/extScale.ui @@ -302,6 +302,20 @@ + + + + false + + + &Unset + + + Reset the scale to the original value and +mark the settings as unset + + + diff --git a/frontend_qt/grpC128.ui b/frontend_qt/grpC128.ui index 896d8f4e..f5974ab2 100644 --- a/frontend_qt/grpC128.ui +++ b/frontend_qt/grpC128.ui @@ -37,15 +37,26 @@ - Subset &C Suppression + Code Set &C Suppression - Do not use Subset C mode + Do not use Code Set C (numeric compression) - + + + + &Manual Code Sets (Extra Escape Mode) + + + Process special escape sequences "\^A", "\^B" and +"\^C" allowing manual Code Set selection + + + + GS&1-128 @@ -56,7 +67,7 @@ formatted with Application Identifiers (AIs) - + H&IBC diff --git a/frontend_qt/mainwindow.cpp b/frontend_qt/mainwindow.cpp index 760c8b0c..d65a99c8 100644 --- a/frontend_qt/mainwindow.cpp +++ b/frontend_qt/mainwindow.cpp @@ -1,6 +1,6 @@ /*************************************************************************** * Copyright (C) 2008 by BogDan Vatra * - * Copyright (C) 2009-2022 by Robin Stuart * + * Copyright (C) 2009-2023 by Robin Stuart * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -59,6 +59,9 @@ static const QKeySequence factoryResetSeq(Qt::SHIFT | Qt::CTRL | Qt::Key_R); static const QRegularExpression colorRE(QSL("^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$")); +static const QColor fgcolorDefault(0, 0, 0, 0xff); +static const QColor bgcolorDefault(0xff, 0xff, 0xff, 0xff); + struct bstyle_item { const QString text; int symbology; @@ -561,8 +564,8 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) void MainWindow::reset_colours() { - m_fgcolor.setRgb(0, 0, 0, 0xff); - m_bgcolor.setRgb(0xff, 0xff, 0xff, 0xff); + m_fgcolor = fgcolorDefault; + m_bgcolor = bgcolorDefault; setColorTxtBtn(m_fgcolor, txt_fgcolor, fgcolor); setColorTxtBtn(m_bgcolor, txt_bgcolor, bgcolor); update_preview(); @@ -733,7 +736,7 @@ void MainWindow::about() "

A free barcode generator

" "

Instruction manual is available at the project homepage:
" "http://www.zint.org.uk.

" - "

Copyright © 2006-2022 Robin Stuart and others.
" + "

Copyright © 2006-2023 Robin Stuart and others.
" "Qt backend by BogDan Vatra.
" "Released under GNU GPL 3.0 or later.

" "

Qt version %2

" @@ -972,7 +975,7 @@ void MainWindow::open_scale_dialog() { double originalScale = spnScale->value(); QString originalSizeMsg = lblSizeMsg->text(); - ScaleWindow dlg(&m_bc, &m_xdimdpVars); + ScaleWindow dlg(&m_bc, &m_xdimdpVars, originalScale); m_scaleWindow = &dlg; connect(&dlg, SIGNAL(scaleChanged(double)), this, SLOT(on_scaleChanged(double))); (void) dlg.exec(); @@ -1558,6 +1561,7 @@ void MainWindow::change_options() connect(get_widget(QSL("radC128EAN")), SIGNAL(toggled( bool )), SLOT(composite_ean_check())); connect(get_widget(QSL("radC128EAN")), SIGNAL(toggled( bool )), SLOT(update_preview())); connect(get_widget(QSL("radC128HIBC")), SIGNAL(toggled( bool )), SLOT(update_preview())); + connect(get_widget(QSL("radC128ExtraEsc")), SIGNAL(toggled( bool )), SLOT(update_preview())); } else if (symbology == BARCODE_PDF417) { QFile file(QSL(":/grpPDF417.ui")); @@ -2502,6 +2506,7 @@ void MainWindow::update_preview() m_bc.bc.setText(txtData->text()); } } + btnReset->setEnabled(m_fgcolor != fgcolorDefault || m_bgcolor != bgcolorDefault); m_bc.bc.setOption1(-1); m_bc.bc.setOption2(0); m_bc.bc.setOption3(0); @@ -2524,14 +2529,18 @@ void MainWindow::update_preview() switch (symbology) { case BARCODE_CODE128: - if (get_rad_val(QSL("radC128CSup"))) + if (get_rad_val(QSL("radC128CSup"))) { m_bc.bc.setSymbol(BARCODE_CODE128AB); - else if (get_rad_val(QSL("radC128EAN"))) + } else if (get_rad_val(QSL("radC128EAN"))) { m_bc.bc.setSymbol(chkComposite->isChecked() ? BARCODE_GS1_128_CC : BARCODE_GS1_128); - else if (get_rad_val(QSL("radC128HIBC"))) + } else if (get_rad_val(QSL("radC128HIBC"))) { m_bc.bc.setSymbol(BARCODE_HIBC_128); - else + } else if (get_rad_val(QSL("radC128ExtraEsc"))) { m_bc.bc.setSymbol(BARCODE_CODE128); + m_bc.bc.setInputMode(m_bc.bc.inputMode() | EXTRA_ESCAPE_MODE); + } else { + m_bc.bc.setSymbol(BARCODE_CODE128); + } break; case BARCODE_EANX: @@ -3927,7 +3936,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) case BARCODE_HIBC_128: settings.setValue(QSL("studio/bc/code128/encoding_mode"), get_rad_grp_index( QStringList() << QSL("radC128Stand") << QSL("radC128EAN") << QSL("radC128CSup") - << QSL("radC128HIBC"))); + << QSL("radC128HIBC") << QSL("radC128ExtraEsc"))); break; case BARCODE_PDF417: @@ -4334,7 +4343,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) case BARCODE_HIBC_128: set_rad_from_setting(settings, QSL("studio/bc/code128/encoding_mode"), QStringList() << QSL("radC128Stand") << QSL("radC128EAN") << QSL("radC128CSup") - << QSL("radC128HIBC")); + << QSL("radC128HIBC") << QSL("radC128ExtraEsc")); break; case BARCODE_PDF417: diff --git a/frontend_qt/scalewindow.cpp b/frontend_qt/scalewindow.cpp index 178cd2e2..179e4e59 100644 --- a/frontend_qt/scalewindow.cpp +++ b/frontend_qt/scalewindow.cpp @@ -1,6 +1,6 @@ /* Zint Barcode Generator - the open source barcode generator - Copyright (C) 2022 Robin Stuart + Copyright (C) 2022-2023 Robin Stuart This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,8 +44,8 @@ static int resolution_standard(int inch, int val) return 0; } -ScaleWindow::ScaleWindow(BarcodeItem *bc, Zint::QZintXdimDpVars *vars) - : m_bc(bc), Valid(false), m_vars(*vars) +ScaleWindow::ScaleWindow(BarcodeItem *bc, Zint::QZintXdimDpVars *vars, double originalScale) + : m_bc(bc), Valid(false), m_vars(*vars), m_originalScale(originalScale), m_unset(false) { setupUi(this); @@ -90,11 +90,15 @@ ScaleWindow::ScaleWindow(BarcodeItem *bc, Zint::QZintXdimDpVars *vars) size_msg_ui_set(); QIcon closeIcon(QIcon::fromTheme(QSL("window-close"), QIcon(QSL(":res/x.svg")))); + QIcon unsetIcon(QSL(":res/delete.svg")); QIcon okIcon(QIcon(QSL(":res/check.svg"))); btnCancel->setIcon(closeIcon); + btnScaleUnset->setIcon(unsetIcon); + btnScaleUnset->setEnabled(m_vars.set); btnOK->setIcon(okIcon); connect(btnCancel, SIGNAL(clicked( bool )), SLOT(close())); + connect(btnScaleUnset, SIGNAL( clicked( bool )), SLOT(unset_scale())); connect(btnOK, SIGNAL(clicked( bool )), SLOT(okay())); connect(spnXdim, SIGNAL(valueChanged( double )), SLOT(update_scale())); connect(cmbXdimUnits, SIGNAL(currentIndexChanged( int )), SLOT(x_dim_units_change())); @@ -143,11 +147,25 @@ void ScaleWindow::size_msg_ui_set() } } +void ScaleWindow::unset_scale() +{ + m_vars.x_dim = m_bc->bc.getXdimDpFromScale(m_originalScale, get_dpmm(), getFileType()); + m_vars.set = 0; + + if (cmbXdimUnits->currentIndex() == 1) { // Inches + spnXdim->setValue(m_vars.x_dim / 25.4); + } else { + spnXdim->setValue(m_vars.x_dim); + } + m_unset = true; + btnScaleUnset->setEnabled(false); +} + void ScaleWindow::okay() { if (update_vars()) { Valid = true; - m_vars.set = 1; + m_vars.set = m_unset ? 0 : 1; } close(); } @@ -159,6 +177,8 @@ void ScaleWindow::update_scale() // Need up-to-date `vectorWidth()` and `vectorHeight()` to estimate size including borders, whitespace & text, // so tell main window to encode and it will update UI here via `size_msg_ui_set()` emit scaleChanged(scale); + m_unset = false; + btnScaleUnset->setEnabled(true); } } diff --git a/frontend_qt/scalewindow.h b/frontend_qt/scalewindow.h index 01833288..3453f9ef 100644 --- a/frontend_qt/scalewindow.h +++ b/frontend_qt/scalewindow.h @@ -1,6 +1,6 @@ /* Zint Barcode Generator - the open source barcode generator - Copyright (C) 2022 Robin Stuart + Copyright (C) 2022-2023 Robin Stuart This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ private: BarcodeItem *m_bc; public: - ScaleWindow(BarcodeItem *bc, struct Zint::QZintXdimDpVars *vars); + ScaleWindow(BarcodeItem *bc, struct Zint::QZintXdimDpVars *vars, double originalScale); ~ScaleWindow(); bool Valid; @@ -45,6 +45,7 @@ signals: public slots: void size_msg_ui_set(); private slots: + void unset_scale(); void okay(); void update_scale(); void x_dim_units_change(); @@ -57,6 +58,8 @@ private: float get_dpmm() const; const char *getFileType() const; double update_vars(); + double m_originalScale; + bool m_unset; }; /* vim: set ts=4 sw=4 et : */