- 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)
- library: guard against out-of-bounds rows (negative)
- test suite: fix some clang-tidy warnings; slight coverage
  improvements
This commit is contained in:
gitlost
2023-01-15 00:22:43 +00:00
parent 5669addf01
commit 6f7cdd660c
30 changed files with 649 additions and 285 deletions

View File

@ -1,7 +1,7 @@
/* code128.c - Handles Code 128 and derivatives */
/*
libzint - the open source barcode library
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008-2023 Robin Stuart <rstuart114@gmail.com>
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);

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
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];

View File

@ -1,7 +1,7 @@
/* code16k.c - Handles Code 16k stacked symbology */
/*
libzint - the open source barcode library
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008-2023 Robin Stuart <rstuart114@gmail.com>
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);

View File

@ -1,7 +1,7 @@
/* library.c - external functions of libzint */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
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);
}

View File

@ -30,7 +30,7 @@ BEGIN
VALUE "FileDescription", "libzint barcode library\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "zint.dll\0"
VALUE "LegalCopyright", "Copyright <20> 2022 Robin Stuart & BogDan Vatra\0"
VALUE "LegalCopyright", "Copyright <20> 2023 Robin Stuart & BogDan Vatra\0"
VALUE "OriginalFilename", "zint.dll\0"
VALUE "ProductName", "libzint\0"
VALUE "ProductVersion", VER_FILEVERSION_STR

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
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 <US> 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 <US> 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;

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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;

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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;

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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;

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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;

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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];

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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;

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2019-2023 Robin Stuart <rstuart114@gmail.com>
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) {

View File

@ -1,7 +1,7 @@
/* zint.h - definitions for libzint */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2023 Robin Stuart <rstuart114@gmail.com>
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 */