CODE128: Add new extra escape \^1 for manual insertion of FNC1s,

ticket #324, props Jim Shank;
  also improve encodation for a few limited cases;
  also some code fiddling
BWIPP: update to latest
raster: check for overflow on `size + size2` in `raster_malloc()`
vector: put `malloc()`s on one line for grep ease
docs: pandoc-3.3, clang-tidy-20
This commit is contained in:
gitlost 2024-09-03 11:55:55 +01:00
parent 7f4ccccb98
commit 10747d6385
19 changed files with 416 additions and 268 deletions

View File

@ -6,6 +6,7 @@ Version 2.13.0.9 (dev) not released yet
- New `memfile` & `memfile_size` fields in `symbol` for use with new output
option `BARCODE_MEMORY_FILE`
- Invalid `input_mode` now returns warning
- New CODE128-only special extra escape `\^1` for manually inserting FNC1s
Changes
-------
@ -21,6 +22,8 @@ Changes
iso4217: new ISO 4217 currency code 924
- AZTEC: workaround MSVC 2022 optimizer bug in `az_populate_map()` loops,
ticket #317, props Andre Maute
- CODE128: Add new extra escape `\^1` for manual insertion of FNC1s, ticket
#324, props Jim Shank
Bugs
----

View File

@ -1,16 +1,16 @@
% README.clang-tidy 2024-03-03
% Current as of latest clang-tidy-19 from Ubuntu 22.04 apt package
% README.clang-tidy 2024-09-03
% Current as of latest clang-tidy-20 from Ubuntu 22.04 apt package
Requires cmake in "build" sub-directory with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON (for "build/compile_commands.json")
and -DCMAKE_BUILD_TYPE=Debug (so `assert()`s defined), and then make (for Qt generated includes).
In project root directory (warning, slow):
clang-tidy-19 backend/*.c frontend/*.c backend_qt/*.cpp frontend_qt/*.cpp -p build/compile_commands.json
clang-tidy-20 backend/*.c frontend/*.c backend_qt/*.cpp frontend_qt/*.cpp -p build/compile_commands.json
For "backend_tcl", which has no "compile_commands.json", specify the tcl include directory, e.g.
clang-tidy-19 backend_tcl/*.c -- -I/usr/include/tcl8.6
clang-tidy-20 backend_tcl/*.c -- -I/usr/include/tcl8.6
Options are in ".clang-tidy" (in the project root directory). The excluded checks are
`clang-analyzer-security.insecureAPI.strcpy` (for `strcpy()`, `strcat()` etc), and
@ -18,5 +18,5 @@ Options are in ".clang-tidy" (in the project root directory). The excluded check
The test suite (cmake given -DZINT_TEST=ON) can also be analysed with an additional check disabled:
clang-tidy-19 backend/tests/*.c frontend/tests/*.c backend_qt/tests/*.cpp \
clang-tidy-20 backend/tests/*.c frontend/tests/*.c backend_qt/tests/*.cpp \
-checks='-clang-analyzer-optin.performance.Padding' -p build/compile_commands.json

View File

@ -76,11 +76,11 @@ INTERNAL_DATA const char C128Table[107][6] = { /* Used by CODABLOCKF and CODE16K
};
/* Determine appropriate mode for a given character */
INTERNAL int c128_parunmodd(const unsigned char llyth) {
INTERNAL int c128_parunmodd(const unsigned char llyth, const int check_fnc1) {
int modd;
if (llyth <= 31) {
modd = C128_SHIFTA;
modd = check_fnc1 && llyth == '\x1D' ? C128_ABORC : C128_SHIFTA;
} else if ((llyth >= 48) && (llyth <= 57)) {
modd = C128_ABORC;
} else if (llyth <= 95) {
@ -244,7 +244,7 @@ INTERNAL void c128_dxsmooth(int list[2][C128_MAX], int *p_indexliste, const char
*/
INTERNAL void c128_set_a(const unsigned char source, int values[], int *bar_chars) {
if (source > 127) {
if (source >= 128) {
if (source < 160) {
values[(*bar_chars)] = (source - 128) + 64;
} else {
@ -290,7 +290,7 @@ INTERNAL void c128_set_c(const unsigned char source_a, const unsigned char sourc
(*bar_chars)++;
}
/* Put set data into set[]. If source given (GS1_MODE) then resolves odd C blocks */
/* Put set data into set[]. If source given (GS1_MODE or manual FNC1s) then resolves odd C blocks */
INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char set[C128_MAX],
const unsigned char *source) {
int read = 0;
@ -303,12 +303,13 @@ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char
}
if (source) {
/* Watch out for odd-length Mode C blocks */
int c_count = 0;
int c_count = 0, have_nonc = 0;
for (i = 0; i < read; i++) {
if (set[i] == 'C') {
if (source[i] == '\x1D') {
if (c_count & 1) {
if ((i - c_count) != 0) {
have_nonc = 1;
if (i > c_count) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
@ -319,8 +320,9 @@ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char
c_count++;
}
} else {
have_nonc = 1;
if (c_count & 1) {
if ((i - c_count) != 0) {
if (i > c_count) {
set[i - c_count] = 'B';
} else {
set[i - 1] = 'B';
@ -330,17 +332,26 @@ INTERNAL void c128_put_in_set(int list[2][C128_MAX], const int indexliste, char
}
}
if (c_count & 1) {
if ((i - c_count) != 0) {
if (i > c_count && have_nonc) {
set[i - c_count] = 'B';
if (c_count < 4) {
/* Rule 1b */
for (j = i - c_count + 1; j < i; j++) {
set[j] = 'B';
}
}
} else {
set[i - 1] = 'B';
}
}
for (i = 1; i < read - 1; i++) {
if ((set[i] == 'C') && ((set[i - 1] == 'B') && (set[i + 1] == 'B'))) {
set[i] = 'B';
if (set[i] == 'C' && set[i - 1] != 'C' && set[i + 1] != 'C') {
set[i] = set[i + 1];
}
}
if (read > 1 && set[read - 1] == 'C' && set[read - 2] != 'C') {
set[read - 1] = set[read - 2];
}
}
}
@ -351,8 +362,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
unsigned char src_buf[C128_MAX + 1];
unsigned char *src = source;
char manual_set[C128_MAX] = {0};
unsigned char fncs[C128_MAX] = {0}; /* Manual FNC1 positions */
int list[2][C128_MAX] = {{0}};
char set[C128_MAX] = {0}, fset[C128_MAX], mode, last_set, current_set = ' ';
int have_fnc1 = 0; /* Whether have at least 1 manual FNC1 */
int glyph_count = 0; /* Codeword estimate times 2 */
char dest[1000];
char *d = dest;
@ -373,16 +386,22 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
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 '\^^' */
&& ((source[i + 2] >= 'A' && source[i + 2] <= 'C') || source[i + 2] == '1'
|| source[i + 2] == '^')) {
if (source[i + 2] == '^') { /* 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 if (source[i + 2] == '1') { /* FNC1 */
i += 2;
fncs[j] = have_fnc1 = 1;
manual_set[j] = manual_ch;
src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */
} else { /* Manual mode A/B/C */
i += 2;
manual_ch = source[i];
}
} else {
manual_set[j] = manual_ch;
@ -456,10 +475,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
indexliste = 0;
indexchaine = 0;
mode = c128_parunmodd(src[indexchaine]);
mode = c128_parunmodd(src[indexchaine], fncs[indexchaine]);
if (mode == C128_ABORC
&& (symbol->symbology == BARCODE_CODE128AB
|| (manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B'))) {
|| manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B')) {
mode = C128_AORB;
}
@ -471,10 +490,10 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
if (indexchaine == length) {
break;
}
mode = c128_parunmodd(src[indexchaine]);
mode = c128_parunmodd(src[indexchaine], fncs[indexchaine]);
if (mode == C128_ABORC
&& (symbol->symbology == BARCODE_CODE128AB
|| (manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B'))) {
|| manual_set[indexchaine] == 'A' || manual_set[indexchaine] == 'B')) {
mode = C128_AORB;
}
if (manual_set[indexchaine] != manual_set[indexchaine - 1]) {
@ -494,6 +513,7 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
}
c128_dxsmooth(list, &indexliste, src == src_buf ? manual_set : NULL);
if (!have_fnc1) {
/* Resolve odd length C128_LATCHC blocks */
if ((list[1][0] == C128_LATCHC) && (list[0][0] & 1)) {
/* Rule 2 */
@ -514,9 +534,11 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
}
}
}
}
/* Put set data into set[]. Giving NULL as source as used to resolve odd C blocks which has been done above */
c128_put_in_set(list, indexliste, set, NULL /*source*/);
/* Put set data into set[]. Give NULL as source if no manual FNC1s as used to resolve odd C blocks
which has been done above */
c128_put_in_set(list, indexliste, set, have_fnc1 ? src : NULL);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Data: %.*s (%d)\n", length, src, length);
@ -547,13 +569,12 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
} else {
if ((fset[i] == 'F') && (fset[i - 1] != 'F')) {
glyph_count += 4;
}
if ((fset[i] != 'F') && (fset[i - 1] == 'F')) {
} else if ((fset[i] != 'F') && (fset[i - 1] == 'F')) {
glyph_count += 4;
}
}
if (set[i] == 'C') {
if (set[i] == 'C' && !fncs[i]) {
glyph_count += 1; /* Half a codeword */
} else {
glyph_count += 2;
@ -622,7 +643,8 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
read = 0;
do {
if ((read != 0) && (set[read] != current_set)) {
if (read != 0) {
if (set[read] != current_set) {
/* Latch different code set */
switch (set[read]) {
case 'A':
@ -640,7 +662,6 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
}
}
if (read != 0) {
if ((fset[read] == 'F') && (f_state == 0)) {
/* Latch beginning of extended mode */
switch (current_set) {
@ -690,19 +711,25 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
values[bar_characters++] = 98;
}
if (!fncs[read]) {
switch (set[read]) { /* Encode data characters */
case 'a':
case 'A': c128_set_a(src[read], values, &bar_characters);
read++;
case 'A':
c128_set_a(src[read++], values, &bar_characters);
break;
case 'b':
case 'B': (void) c128_set_b(src[read], values, &bar_characters);
read++;
case 'B':
(void) c128_set_b(src[read++], values, &bar_characters);
break;
case 'C': c128_set_c(src[read], src[read + 1], values, &bar_characters);
case 'C':
c128_set_c(src[read], src[read + 1], values, &bar_characters);
read += 2;
break;
}
} else {
values[bar_characters++] = 102; /* FNC1 in all modes */
read++;
}
} while (read < length);
@ -744,6 +771,16 @@ INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int len
/* ISO/IEC 15417:2007 leaves dimensions/height as application specification */
/* HRT */
if (have_fnc1) {
/* Remove any manual FNC1 dummies ('\x1D') */
for (i = 0, j = 0; i < length; i++) {
if (!fncs[i]) {
src[j++] = src[i];
}
}
length = j;
}
error_number = hrt_cpy_iso8859_1(symbol, src, length);
return error_number;
@ -788,7 +825,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
indexliste = 0;
indexchaine = 0;
mode = c128_parunmodd(reduced[indexchaine]);
mode = c128_parunmodd(reduced[indexchaine], 1 /*check_fnc1*/);
do {
list[1][indexliste] = mode;
@ -798,10 +835,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
if (indexchaine == reduced_length) {
break;
}
mode = c128_parunmodd(reduced[indexchaine]);
if (reduced[indexchaine] == '\x1D') {
mode = C128_ABORC;
}
mode = c128_parunmodd(reduced[indexchaine], 1 /*check_fnc1*/);
}
indexliste++;
} while (indexchaine < reduced_length);
@ -853,7 +887,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
break;
}
values[bar_characters++] = 102;
values[bar_characters++] = 102; /* FNC1 */
/* Encode the data */
read = 0;
@ -882,13 +916,11 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
switch (set[read]) { /* Encode data characters */
case 'A':
case 'a':
c128_set_a(reduced[read], values, &bar_characters); /* Not reached */
read++;
c128_set_a(reduced[read++], values, &bar_characters); /* Not reached */
break;
case 'B':
case 'b':
(void) c128_set_b(reduced[read], values, &bar_characters);
read++;
(void) c128_set_b(reduced[read++], values, &bar_characters);
break;
case 'C':
c128_set_c(reduced[read], reduced[read + 1], values, &bar_characters);
@ -896,7 +928,7 @@ INTERNAL int gs1_128_cc(struct zint_symbol *symbol, unsigned char source[], int
break;
}
} else {
values[bar_characters++] = 102;
values[bar_characters++] = 102; /* FNC1 in all modes */
read++;
}
} while (read < reduced_length);
@ -1194,8 +1226,7 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
case 21:
case 24:
case 27:
symbol->text[p] = ' ';
p++;
symbol->text[p++] = ' ';
break;
}
}

View File

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -49,7 +49,7 @@ extern "C" {
INTERNAL int code128(struct zint_symbol *symbol, unsigned char source[], int length);
INTERNAL int c128_parunmodd(const unsigned char llyth);
INTERNAL int c128_parunmodd(const unsigned char llyth, const int check_fnc1);
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);

View File

@ -90,7 +90,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
indexliste = 0;
indexchaine = 0;
mode = c128_parunmodd(source[indexchaine]);
mode = c128_parunmodd(source[indexchaine], gs1 /*check_fnc1*/);
do {
list[1][indexliste] = mode;
@ -100,10 +100,7 @@ INTERNAL int code16k(struct zint_symbol *symbol, unsigned char source[], int len
if (indexchaine == length) {
break;
}
mode = c128_parunmodd(source[indexchaine]);
if (gs1 && source[indexchaine] == '\x1D') {
mode = C128_ABORC;
} /* FNC1 */
mode = c128_parunmodd(source[indexchaine], gs1 /*check_fnc1*/);
}
indexliste++;
} while (indexchaine < length);

View File

@ -68,7 +68,7 @@ static void *raster_malloc(size_t size, size_t size2) {
/* Check for large image `malloc`s, which produce very large files most systems can't handle anyway */
/* Also `malloc()` on Linux will (usually) succeed regardless of request, and then get untrappably killed on
access by OOM killer if too much, so this is a crude mitigation */
if (size + size2 > 0x40000000) { /* 1GB */
if (size + size2 < size /*Overflow check*/ || size + size2 > 0x40000000 /*1GB*/) {
return NULL;
}
return malloc(size);
@ -112,7 +112,7 @@ static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf
symbol->alphamap = NULL;
}
symbol->bitmap = (unsigned char *) raster_malloc(bm_bitmap_size, 0);
symbol->bitmap = (unsigned char *) raster_malloc(bm_bitmap_size, 0 /*size2*/);
if (symbol->bitmap == NULL) {
strcpy(symbol->errtxt, "661: Insufficient memory for bitmap buffer");
return ZINT_ERROR_MEMORY;
@ -783,7 +783,7 @@ static int plot_raster_maxicode(struct zint_symbol *symbol, const int rotate_ang
assert(image_width && image_height);
image_size = (size_t) image_width * image_height;
if (!(pixelbuf = (unsigned char *) raster_malloc(image_size, 0 /*size*/))) {
if (!(pixelbuf = (unsigned char *) raster_malloc(image_size, 0 /*size2*/))) {
strcpy(symbol->errtxt, "655: Insufficient memory for pixel buffer");
return ZINT_ERROR_MEMORY;
}

View File

@ -370,6 +370,19 @@ static void test_input(const testCtx *const p_ctx) {
/* 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" },
/* 79*/ { UNICODE_MODE, "A\0121234A12\012", -1, 0, 145, 1, "(13) 103 33 74 99 12 34 101 33 17 18 74 99 106", "StartA A <LF> CodeC 12 34 CodeA A 1 2 <LF>; Okapi c128/improved-lookahead-mode-a.png" },
/* 80*/ { UNICODE_MODE, "21*\015\012M0", -1, 0, 112, 1, "(10) 103 18 17 10 77 74 45 16 9 106", "StartA 2 1 * <CR> <LF> M 0; Okapi c128/improved-lookahead-rule-1c.png" },
/* 81*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^1SN123456789012", -1, 0, 145, 1, "(13) 104 102 51 46 99 12 34 56 78 90 12 65 106", "StartB FNC1 S N CodeC 12 34 56 78 90 12" },
/* 82*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1SN123456789012", -1, 0, 200, 0, "(18) 104 102 51 46 17 18 19 20 21 22 23 24 25 16 17 18 56 106", "StartB FNC1 S N 1 2 3 4 5 6 7 8 9 0 1 2; BWIPP no manual mode" },
/* 83*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "A\\^1BC\\^1DEF\\^1", -1, 0, 134, 1, "(12) 104 33 102 34 35 102 36 37 38 102 9 106", "StartB A FNC1 B C FNC1 D E F FNC1" },
/* 84*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^C12\\^1", -1, 0, 57, 0, "(5) 105 12 102 12 106", "StartC 12 FNC1; BWIPP no manual mode" },
/* 85*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13", -1, 0, 79, 1, "(7) 105 12 102 100 19 79 106", "StartC 12 FNC1 CodeB 3" },
/* 86*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^13\\^1", -1, 0, 90, 1, "(8) 105 12 102 100 19 102 74 106", "StartC 12 FNC1 CodeB 3 FNC1" },
/* 87*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1\\^123", -1, 0, 79, 0, "(7) 104 17 99 102 23 99 106", "StartB 1 CodeC FNC1 23; BWIPP different encodation (same codeword count)" },
/* 88*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134", -1, 0, 68, 1, "(6) 105 12 102 34 11 106", "StartC 12 FNC1 34" },
/* 89*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^134\\^1", -1, 0, 79, 1, "(7) 105 12 102 34 102 7 106", "StartC 12 FNC1 34 FNC1" },
/* 90*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123\\^145\\^1", -1, 0, 112, 0, "(10) 105 12 100 19 99 102 45 102 101 106", "StartC 12 CodeB 3 CodeC FNC1 45 FNC1; BWIPP different encodation (BWIPP 1 shorter)" },
/* 91*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "12\\^1345\\^1", -1, 0, 112, 0, "(10) 105 12 102 100 19 99 45 102 13 106", "StartC 12 FNC1 CodeB 3 CodeC 45 FNC1; BWIPP different encodation (BWIPP 1 shorter)" },
/* 92*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156\\^1", -1, 0, 90, 1, "(8) 105 12 34 102 56 102 92 106", "StartC 12 34 FNC1 56 FNC1" },
/* 93*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "1234\\^156789\\^101\\^11\\^1", -1, 0, 189, 0, "(17) 105 12 34 102 100 21 99 67 89 102 1 102 100 17 102 48 106", "StartC 12 34 FNC1 56 78 CodeB 9 CodeC FNC1 01 FNC1 CodeB 1 FNC1; BWIPP different encodation (BWIPP 1 shorter)" },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;
@ -449,45 +462,51 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
char *data;
int ret;
int expected_width;
int bwipp_cmp;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9" },
/* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9" },
/* 2*/ { GS1_MODE, "[90]1[90]12", 0, 123, "(11) 105 102 90 100 17 99 102 90 12 13 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12" },
/* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23" },
/* 4*/ { GS1_MODE, "[90]12[90]1", 0, 123, "(11) 105 102 90 12 102 100 25 99 1 19 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 5*/ { GS1_MODE, "[90]12[90]12", 0, 101, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" },
/* 6*/ { GS1_MODE, "[90]12[90]123", 0, 134, "(12) 105 102 90 12 102 100 25 99 1 23 20 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" },
/* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01" },
/* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 145, "(13) 105 102 90 12 100 19 99 102 90 12 34 98 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34" },
/* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 178, "(16) 105 102 90 100 17 102 25 99 1 102 100 25 99 1 51 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 178, "(16) 105 102 90 100 17 99 102 90 12 102 100 25 99 1 8 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 189, "(17) 105 102 90 100 17 102 25 99 1 23 102 100 25 99 1 70 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 189, "(17) 105 102 90 12 102 100 25 99 1 23 102 100 25 99 1 33 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, "(15) 105 102 90 12 102 100 25 99 1 23 102 90 12 11 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 90 12" },
/* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 189, "(17) 105 102 90 12 100 19 102 25 99 1 102 100 25 99 1 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 189, "(17) 105 102 90 12 100 19 99 102 90 12 102 100 25 99 1 80 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 16*/ { GS1_MODE, "[90]123[90]123[90]12", 0, 178, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 23 FNC1 90 12" },
/* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 200, "(18) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 26 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 211, "(19) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 23 85 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01 23" },
/* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 211, "(19) 105 102 90 12 34 100 21 99 102 90 12 34 102 100 25 99 1 30 106", "StartC FNC1 90 12 34 CodeB 5 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" },
/* 21*/ { GS1_MODE, "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
/* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" },
/* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, "(16) 105 102 90 12 34 100 21 33 17 99 23 45 100 33 59 106", "StartC FNC1 90 12 34 CodeB 5 A 1 CodeC 23 45 CodeB A [" },
/* 24*/ { GS1_MODE, "[01]12345678901231[90]12345678901234567890123456789", 0, 321, "(29) 105 102 1 12 34 56 78 90 12 31 90 12 34 56 78 90 12 34 56 78 90 12 34 56 78 100 25 59", "Max length" },
/* 25*/ { GS1_MODE, "[01]12345678901231[90]123456789012345678901234567890[91]1", ZINT_WARN_NONCOMPLIANT, 365, "Warning 843: GS1-128 input too long (48 character maximum)", "Over length" },
/* 26*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]1234", ZINT_WARN_HRT_TRUNCATED, 1135, "Warning 844: Human Readable Text truncated", "Max input" },
/* 27*/ { GS1_MODE, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]567890[20]34[20]78", ZINT_WARN_HRT_TRUNCATED, 1135, "Warning 844: Human Readable Text truncated", "HRT truncation warning trumps non-compliant (3100) warning" },
/* 28*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, "Error 344: Input too long (99 symbol character maximum)", "" },
/* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, 1, "(11) 105 102 90 100 17 102 25 16 17 15 106", "StartC FNC1 90 CodeB 1 FNC1 9 0 1" },
/* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, 1, "(11) 105 102 90 100 17 102 25 16 17 15 106", "StartC FNC1 90 CodeB 1 FNC1 9 0 1" },
/* 2*/ { GS1_MODE, "[90]1[90]12", 0, 123, 0, "(11) 105 102 90 100 17 99 102 90 12 13 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12; BWIPP different encodation (same codeword count)" },
/* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, 1, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23" },
/* 4*/ { GS1_MODE, "[90]12[90]1", 0, 112, 1, "(10) 105 102 90 12 102 90 100 17 43 106", "StartC FNC1 90 12 FNC1 90 CodeB 1" },
/* 5*/ { GS1_MODE, "[90]12[90]12", 0, 101, 1, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" },
/* 6*/ { GS1_MODE, "[90]12[90]123", 0, 123, 1, "(11) 105 102 90 12 102 90 12 100 19 42 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" },
/* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, 1, "(12) 105 102 90 12 100 19 102 25 16 17 29 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 0 1" },
/* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 145, 0, "(13) 105 102 90 12 100 19 99 102 90 12 34 98 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34; BWIPP different encodation (same codeword count)" },
/* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 178, 0, "(16) 105 102 90 100 17 102 25 99 1 102 100 25 16 17 87 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 1 shorter)" },
/* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 178, 0, "(16) 105 102 90 100 17 99 102 90 12 102 100 25 16 17 44 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12 FNC1 CodeB 9 0 1; BWIPP different encodation (same codeword count)" },
/* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 189, 0, "(17) 105 102 90 100 17 102 25 99 1 23 102 100 25 16 17 39 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 1 shorter)" },
/* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 189, 0, "(17) 105 102 90 12 102 100 25 99 1 23 102 100 25 16 17 2 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 2 shorter)" },
/* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, 0, "(15) 105 102 90 12 102 100 25 99 1 23 102 90 12 11 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 90 12; BWIPP different encodation (same codeword count)" },
/* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 189, 0, "(17) 105 102 90 12 100 19 102 25 99 1 102 100 25 16 17 16 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 CodeB 9 0 1; BWIPP different encodation (BWIPP 1 shorter)" },
/* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 189, 0, "(17) 105 102 90 12 100 19 99 102 90 12 102 100 25 16 17 49 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01; BWIPP different encodation (same codeword count)" },
/* 16*/ { GS1_MODE, "[90]123[90]123[90]12", 0, 178, 1, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 23 FNC1 90 12" },
/* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 200, 0, "(18) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 16 17 31 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01; BWIPP different encodation (BWIPP 1 longer)" },
/* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 211, 0, "(19) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 23 85 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01 23; BWIPP different encodation (BWIPP 1 longer)" },
/* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 211, 0, "(19) 105 102 90 12 34 100 21 99 102 90 12 34 102 100 25 16 17 71 106", "StartC FNC1 90 12 34 CodeB 5 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01; BWIPP different encodation (BWIPP 1 longer)" },
/* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, 0, "(12) 104 102 25 16 17 33 102 25 16 17 60 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01; BWIPP different encodation (same codeword count)" },
/* 21*/ { GS1_MODE, "[90]12A[90]123", 0, 145, 1, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
/* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 244, 0, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23; BWIPP different encodation (BWIPP 2 shorter)" },
/* 23*/ { GS1_MODE, "[90]12345A12345A", 0, 178, 1, "(16) 105 102 90 12 34 100 21 33 17 99 23 45 100 33 59 106", "StartC FNC1 90 12 34 CodeB 5 A 1 CodeC 23 45 CodeB A" },
/* 24*/ { GS1_MODE, "[01]12345678901231[90]12345678901234567890123456789", 0, 321, 1, "(29) 105 102 1 12 34 56 78 90 12 31 90 12 34 56 78 90 12 34 56 78 90 12 34 56 78 100 25 59", "Max length" },
/* 25*/ { GS1_MODE, "[01]12345678901231[90]123456789012345678901234567890[91]1", ZINT_WARN_NONCOMPLIANT, 354, 1, "Warning 843: GS1-128 input too long (48 character maximum)", "Over length" },
/* 26*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]1234", ZINT_WARN_HRT_TRUNCATED, 1135, 1, "Warning 844: Human Readable Text truncated", "Max input" },
/* 27*/ { GS1_MODE, "[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[00]345678901234567890[3100]567890[20]34[20]78", ZINT_WARN_HRT_TRUNCATED, 1135, 1, "Warning 844: Human Readable Text truncated", "HRT truncation warning trumps non-compliant (3100) warning" },
/* 28*/ { GS1_MODE, "[90]123456789012345678901234567890[91]1234567890123456789012345678901234567890123456789012345678901234567890[92]12345678901234567890123456789012345678901234567890123456789012345678901234567890[93]12345", ZINT_ERROR_TOO_LONG, 0, 1, "Error 344: Input too long (99 symbol character maximum)", "" },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[8192];
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStartSymbol("test_gs1_128_input", &symbol);
@ -505,13 +524,14 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
length = testUtilSetSymbol(symbol, BARCODE_GS1_128, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*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*/ { %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
printf(" /*%3d*/ { %s, \"%s\", %s, %d, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
testUtilErrorName(data[i].ret), symbol->width, data[i].bwipp_cmp, symbol->errtxt, data[i].comment);
} else {
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);
if (ret == ZINT_WARN_HRT_TRUNCATED) {
@ -521,8 +541,33 @@ static void test_gs1_128_input(const testCtx *const p_ctx) {
assert_equal((int) ustrlen(symbol->text), (int) strlen(data[i].data), "i:%d len symbol->text(%s) %d != %d (%s, %s) (%s)\n",
i, symbol->text, (int) ustrlen(symbol->text), (int) strlen(data[i].data), testUtilErrorName(ret), data[i].data, symbol->errtxt);
}
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not BWIPP compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
} else {
char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
}
}
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len;
char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped);
}
}
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
ZBarcode_Delete(symbol);
@ -556,6 +601,11 @@ static void test_hibc_input(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[8192];
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
testStartSymbol("test_hibc_input", &symbol);
@ -578,10 +628,32 @@ static void test_hibc_input(const testCtx *const p_ctx) {
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
} else {
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);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
}
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len;
char modules_dump[4096];
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
assert_zero(ret, "i:%d %s testUtilZXingCPPCmp %d != 0 %s\n actual: %.*s\nexpected: %.*s\n",
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_len, cmp_buf, ret_len, escaped);
}
}
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
}
ZBarcode_Delete(symbol);

View File

@ -2505,8 +2505,17 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch
sprintf(b, "^%03d", val);
b += 4;
} else {
if (d + 1 < de && *(d + 1) >= 'A' && *(d + 1) <= 'C') {
if (d + 1 < de && ((*(d + 1) >= 'A' && *(d + 1) <= 'C') || *(d + 1) == '1')) {
d++;
if (*d == '1') {
if (b + 5 >= be) {
fprintf(stderr, "testUtilBwippEscape: FNC1 bwipp_data buffer full (%d)\n", bwipp_data_size);
return NULL;
}
strcpy(b, "^FNC1");
b += 5;
*parsefnc = 1;
}
} else {
if (b + 8 >= be) {
fprintf(stderr, "testUtilBwippEscape: loop bwipp_data buffer full (%d)\n", bwipp_data_size);
@ -3960,9 +3969,18 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
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] == '^')) {
&& ((escaped[i + 2] >= 'A' && escaped[i + 2] <= 'C') || escaped[i + 2] == '1'
|| escaped[i + 2] == '^')) {
if (escaped[i + 2] != '^') {
i += 2;
if (escaped[i] == '1') {
/* FNC1 in 1st position treated as GS1 and in 2nd position AIM, neither transmitted */
if (j > 2 || (j == 1 && !(z_isupper(escaped[0]) || z_islower(escaped[0])))
/* TODO: following exception only valid if in Code Set C */
|| (j == 2 && !(z_isdigit(escaped[0]) && z_isdigit(escaped[1])))) {
escaped[j++] = 29; /* GS */
}
}
} else {
escaped[j++] = escaped[i++];
escaped[j++] = escaped[i++];

View File

@ -1,5 +1,6 @@
#!/bin/bash
# Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
# Copyright (C) 2021-2024 Robin Stuart <rstuart114@gmail.com>
# SPDX-License-Identifier: BSD-3-Clause
# vim: set ts=4 sw=4 et :
set -e
@ -28,6 +29,8 @@ run_bwipp_test "test_code1" "encode"
run_bwipp_test "test_code1" "encode_segs"
run_bwipp_test "test_code1" "fuzz"
run_bwipp_test "test_code128" "input"
run_bwipp_test "test_code128" "gs1_128_input"
run_bwipp_test "test_code128" "hibc_input"
run_bwipp_test "test_code128" "encode"
run_bwipp_test "test_code16k" "input"
run_bwipp_test "test_code16k" "encode"

View File

@ -1,5 +1,6 @@
#!/bin/bash
# Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
# Copyright (C) 2021-2024 Robin Stuart <rstuart114@gmail.com>
# SPDX-License-Identifier: BSD-3-Clause
# vim: set ts=4 sw=4 et :
set -e
@ -23,6 +24,8 @@ run_zxingcpp_test "test_codablock" "encode"
run_zxingcpp_test "test_codablock" "fuzz"
run_zxingcpp_test "test_code" "encode"
run_zxingcpp_test "test_code128" "input"
run_zxingcpp_test "test_code128" "gs1_128_input"
run_zxingcpp_test "test_code128" "hibc_input"
run_zxingcpp_test "test_code128" "encode"
run_zxingcpp_test "test_code16k" "input"
run_zxingcpp_test "test_code16k" "encode"

View File

@ -1,7 +1,7 @@
/* vector.c - Creates vector image objects */
/*
libzint - the open source barcode library
Copyright (C) 2018-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2018-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -42,8 +42,7 @@ static int vector_add_rect(struct zint_symbol *symbol, const float x, const floa
const float height, struct zint_vector_rect **last_rect) {
struct zint_vector_rect *rect;
rect = (struct zint_vector_rect *) malloc(sizeof(struct zint_vector_rect));
if (!rect) {
if (!(rect = (struct zint_vector_rect *) malloc(sizeof(struct zint_vector_rect)))) {
strcpy(symbol->errtxt, "691: Insufficient memory for vector rectangle");
return 0;
}
@ -69,8 +68,7 @@ static int vector_add_hexagon(struct zint_symbol *symbol, const float x, const f
const float diameter, struct zint_vector_hexagon **last_hexagon) {
struct zint_vector_hexagon *hexagon;
hexagon = (struct zint_vector_hexagon *) malloc(sizeof(struct zint_vector_hexagon));
if (!hexagon) {
if (!(hexagon = (struct zint_vector_hexagon *) malloc(sizeof(struct zint_vector_hexagon)))) {
strcpy(symbol->errtxt, "692: Insufficient memory for vector hexagon");
return 0;
}
@ -94,8 +92,7 @@ static int vector_add_circle(struct zint_symbol *symbol, const float x, const fl
const float width, const int colour, struct zint_vector_circle **last_circle) {
struct zint_vector_circle *circle;
circle = (struct zint_vector_circle *) malloc(sizeof(struct zint_vector_circle));
if (!circle) {
if (!(circle = (struct zint_vector_circle *) malloc(sizeof(struct zint_vector_circle)))) {
strcpy(symbol->errtxt, "693: Insufficient memory for vector circle");
return 0;
}
@ -121,8 +118,7 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te
struct zint_vector_string **last_string) {
struct zint_vector_string *string;
string = (struct zint_vector_string *) malloc(sizeof(struct zint_vector_string));
if (!string) {
if (!(string = (struct zint_vector_string *) malloc(sizeof(struct zint_vector_string)))) {
strcpy(symbol->errtxt, "694: Insufficient memory for vector string");
return 0;
}
@ -134,8 +130,7 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te
string->length = length == -1 ? (int) ustrlen(text) : length;
string->rotation = 0;
string->halign = halign;
string->text = (unsigned char *) malloc(string->length + 1);
if (!string->text) {
if (!(string->text = (unsigned char *) malloc(string->length + 1))) {
free(string);
strcpy(symbol->errtxt, "695: Insufficient memory for vector string text");
return 0;
@ -449,8 +444,7 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
}
/* Allocate memory */
vector = symbol->vector = (struct zint_vector *) malloc(sizeof(struct zint_vector));
if (!vector) {
if (!(vector = symbol->vector = (struct zint_vector *) malloc(sizeof(struct zint_vector)))) {
strcpy(symbol->errtxt, "696: Insufficient memory for vector header");
return ZINT_ERROR_MEMORY;
}

View File

@ -1,11 +1,11 @@
% docs/README 2024-06-27
% docs/README 2024-09-03
For generation of "docs/manual.pdf" and "docs/manual.txt" from "manual.pmd" using a recent version of pandoc
On Ubuntu/Debian (tested on Ubuntu 22.04)
wget https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-1-amd64.deb
sudo dpkg -i pandoc-3.2.1-1-amd64.deb
wget https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-1-amd64.deb
sudo dpkg -i pandoc-3.3-1-amd64.deb
sudo apt install python3-pip
pip install pandoc-tablenos --user
export PATH=~/.local/bin:"$PATH"
@ -20,9 +20,9 @@ On Ubuntu/Debian (tested on Ubuntu 22.04)
On Fedora (tested on Fedora Linux 38 (Workstation Edition))
wget https://github.com/jgm/pandoc/releases/download/3.2.1/pandoc-3.2.1-linux-amd64.tar.gz
tar xf pandoc-3.2.1-linux-amd64.tar.gz
sudo mv -i pandoc-3.2.1/bin/pandoc /usr/local/bin
wget https://github.com/jgm/pandoc/releases/download/3.3/pandoc-3.3-linux-amd64.tar.gz
tar xf pandoc-3.3-linux-amd64.tar.gz
sudo mv -i pandoc-3.3/bin/pandoc /usr/local/bin
sudo dnf install python3-pip
pip install pandoc-tablenos --user
export PATH=~/.local/bin:"$PATH"

View File

@ -332,7 +332,7 @@
<h1 class="title">Zint Barcode Generator and Zint Barcode Studio User
Manual</h1>
<p class="author">Version 2.13.0.9</p>
<p class="date">June 2024</p>
<p class="date">September 2024</p>
</header>
<nav id="TOC" role="doc-toc">
<ul>
@ -1436,8 +1436,9 @@ is hexadecimal (000000-10FFFF)</td>
</table>
</div>
<p>(Special escape sequences are available for Code 128 only to manually
switch Code Sets - see <a href="#standard-code-128-iso-15417">6.1.10.1
Standard Code 128 (ISO 15417)</a> for details.)</p>
switch Code Sets and/or insert special FNC1 characters - see <a
href="#standard-code-128-iso-15417">6.1.10.1 Standard Code 128 (ISO
15417)</a> for details.)</p>
<p>Input data can be read directly from file using the <code>-i</code>
or <code>--input</code> switch as shown below. The input file is assumed
to be UTF-8 formatted unless an alternative mode is selected. This
@ -4831,6 +4832,11 @@ special code sequence, it can be escaped by doubling the caret
<div class="sourceCode" id="cb100"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb100-1"><a href="#cb100-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> CODE128 <span class="at">-d</span> <span class="st">&quot;\^AABC\^^BDEF&quot;</span> <span class="at">--extraesc</span></span></code></pre></div>
<p>will encode the data <code>"ABC\^BDEF"</code> in Code Set A.</p>
<p>There is also the extra escape <code>\^1</code>, which will encode a
special Function Code 1 character (FNC1) anywhere you chose in the data,
for instance</p>
<div class="sourceCode" id="cb101"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb101-1"><a href="#cb101-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> CODE128 <span class="at">-d</span> <span class="st">&quot;A\^1BC\^1DEF&quot;</span> <span class="at">--extraesc</span></span></code></pre></div>
<p>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 symbols. The ISO/IEC 8859-1 character set is shown in Annex <a
@ -4851,8 +4857,8 @@ which compresses numerical data. The <code>BARCODE_CODE128AB</code><a
href="#fn14" class="footnote-ref" id="fnref14"
role="doc-noteref"><sup>14</sup></a> variant (symbology 60) suppresses
Code Set C in favour of Code Sets A and B.</p>
<p>Note that the special escapes to manually switch Code Sets mentioned
above are not available for this variant (nor for any other).</p>
<p>Note that the special extra escapes mentioned above are not available
for this variant (nor for any other).</p>
<h4 id="gs1-128">6.1.10.3 GS1-128</h4>
<figure>
<img src="images/gs1_128.svg" title="fig:" class="lin"
@ -4875,11 +4881,11 @@ correct encoding. GS1-128 does not support extended ASCII (ISO/IEC
8859-1) characters. Check digits for GTIN data AI (01) are not generated
and need to be included in the input data. The following is an example
of a valid GS1-128 input:</p>
<div class="sourceCode" id="cb101"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb101-1"><a href="#cb101-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 16 <span class="at">-d</span> <span class="st">&quot;[01]98898765432106[3202]012345[15]991231&quot;</span></span></code></pre></div>
<p>or using the <code>--gs1parens</code> option:</p>
<div class="sourceCode" id="cb102"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb102-1"><a href="#cb102-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 16 <span class="at">--gs1parens</span> <span class="at">-d</span> <span class="st">&quot;(01)98898765432106(3202)012345(15)991231&quot;</span></span></code></pre></div>
class="sourceCode bash"><code class="sourceCode bash"><span id="cb102-1"><a href="#cb102-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 16 <span class="at">-d</span> <span class="st">&quot;[01]98898765432106[3202]012345[15]991231&quot;</span></span></code></pre></div>
<p>or using the <code>--gs1parens</code> option:</p>
<div class="sourceCode" id="cb103"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb103-1"><a href="#cb103-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 16 <span class="at">--gs1parens</span> <span class="at">-d</span> <span class="st">&quot;(01)98898765432106(3202)012345(15)991231&quot;</span></span></code></pre></div>
<h4 id="ean-14">6.1.10.4 EAN-14</h4>
<figure>
<img src="images/ean14.svg" title="fig:" class="lin"
@ -5050,8 +5056,8 @@ href="#gs1-128">6.1.10.3 GS1-128</a>.</p>
not calculated by Zint when this symbology is encoded. Fixed length data
should be entered at the appropriate length for correct encoding. The
following is an example of a valid GS1 DataBar Expanded input:</p>
<div class="sourceCode" id="cb103"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb103-1"><a href="#cb103-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 31 <span class="at">-d</span> <span class="st">&quot;[01]98898765432106[3202]012345[15]991231&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb104"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb104-1"><a href="#cb104-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 31 <span class="at">-d</span> <span class="st">&quot;[01]98898765432106[3202]012345[15]991231&quot;</span></span></code></pre></div>
<h3 id="korea-post-barcode">6.1.12 Korea Post Barcode</h3>
<figure>
<img src="images/koreapost.svg" title="fig:" class="lin"
@ -5140,20 +5146,20 @@ position. Lowercase input is automatically made uppercase.</p>
primarily in the vehicle industry, is to simply stack one-dimensional
codes on top of each other. This can be achieved at the command prompt
by giving more than one set of input data. For example</p>
<div class="sourceCode" id="cb104"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb104-1"><a href="#cb104-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-d</span> <span class="st">&quot;This&quot;</span> <span class="at">-d</span> <span class="st">&quot;That&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb105"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb105-1"><a href="#cb105-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-d</span> <span class="st">&quot;This&quot;</span> <span class="at">-d</span> <span class="st">&quot;That&quot;</span></span></code></pre></div>
<p>will draw two Code 128 symbols, one on top of the other. The same
result can be achieved using the API by executing the
<code>ZBarcode_Encode()</code> function more than once on a symbol. For
example:</p>
<div class="sourceCode" id="cb105"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb105-1"><a href="#cb105-1" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>symbology <span class="op">=</span> BARCODE_CODE128<span class="op">;</span></span>
<span id="cb105-2"><a href="#cb105-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb105-3"><a href="#cb105-3" aria-hidden="true" tabindex="-1"></a>error <span class="op">=</span> ZBarcode_Encode<span class="op">(</span>my_symbol<span class="op">,</span> <span class="st">&quot;This&quot;</span><span class="op">,</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb105-4"><a href="#cb105-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb105-5"><a href="#cb105-5" aria-hidden="true" tabindex="-1"></a>error <span class="op">=</span> ZBarcode_Encode<span class="op">(</span>my_symbol<span class="op">,</span> <span class="st">&quot;That&quot;</span><span class="op">,</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb105-6"><a href="#cb105-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb105-7"><a href="#cb105-7" aria-hidden="true" tabindex="-1"></a>error <span class="op">=</span> ZBarcode_Print<span class="op">(</span>my_symbol<span class="op">);</span></span></code></pre></div>
<div class="sourceCode" id="cb106"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb106-1"><a href="#cb106-1" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>symbology <span class="op">=</span> BARCODE_CODE128<span class="op">;</span></span>
<span id="cb106-2"><a href="#cb106-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb106-3"><a href="#cb106-3" aria-hidden="true" tabindex="-1"></a>error <span class="op">=</span> ZBarcode_Encode<span class="op">(</span>my_symbol<span class="op">,</span> <span class="st">&quot;This&quot;</span><span class="op">,</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb106-4"><a href="#cb106-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb106-5"><a href="#cb106-5" aria-hidden="true" tabindex="-1"></a>error <span class="op">=</span> ZBarcode_Encode<span class="op">(</span>my_symbol<span class="op">,</span> <span class="st">&quot;That&quot;</span><span class="op">,</span> <span class="dv">0</span><span class="op">);</span></span>
<span id="cb106-6"><a href="#cb106-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb106-7"><a href="#cb106-7" aria-hidden="true" tabindex="-1"></a>error <span class="op">=</span> ZBarcode_Print<span class="op">(</span>my_symbol<span class="op">);</span></span></code></pre></div>
<figure>
<img src="images/code128_stacked.svg" title="fig:" class="lin"
alt="zint -d &quot;This&quot; -d &quot;That&quot;" />
@ -5169,8 +5175,8 @@ specifying <code>--bind</code> (API
separator bars in integral multiples of the X-dimension (minimum and
default 1, maximum 4) can be set by <code>--separator</code> (API
<code>option_3</code>):</p>
<div class="sourceCode" id="cb106"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb106-1"><a href="#cb106-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">--bind</span> <span class="at">--notext</span> <span class="at">--separator</span><span class="op">=</span>2 <span class="at">-d</span> <span class="st">&quot;This&quot;</span> <span class="at">-d</span> <span class="st">&quot;That&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb107"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb107-1"><a href="#cb107-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">--bind</span> <span class="at">--notext</span> <span class="at">--separator</span><span class="op">=</span>2 <span class="at">-d</span> <span class="st">&quot;This&quot;</span> <span class="at">-d</span> <span class="st">&quot;That&quot;</span></span></code></pre></div>
<figure>
<img src="images/code128_stacked_sep2.svg" title="fig:" class="lin"
alt="zint --notext --bind --separator=2 -d &quot;This&quot; -d &quot;That&quot;" />
@ -5445,21 +5451,21 @@ should be entered into a primary string with the data for the 2D
component being entered in the normal way. To do this at the command
prompt use the <code>--primary</code> switch (API <code>primary</code>).
For example:</p>
<div class="sourceCode" id="cb107"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb107-1"><a href="#cb107-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> EANX_CC <span class="at">--mode</span><span class="op">=</span>1 <span class="at">--primary</span><span class="op">=</span>331234567890 <span class="at">-d</span> <span class="st">&quot;[99]1234-abcd&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb108"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb108-1"><a href="#cb108-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> EANX_CC <span class="at">--mode</span><span class="op">=</span>1 <span class="at">--primary</span><span class="op">=</span>331234567890 <span class="at">-d</span> <span class="st">&quot;[99]1234-abcd&quot;</span></span></code></pre></div>
<p>This creates an EAN-13 linear component with the data
<code>"331234567890"</code> and a 2D CC-A (see <a
href="#cc-a">below</a>) component with the data
<code>"(99)1234-abcd"</code>. The same results can be achieved using the
API as shown below:</p>
<div class="sourceCode" id="cb108"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb108-1"><a href="#cb108-1" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>symbology <span class="op">=</span> BARCODE_EANX_CC<span class="op">;</span></span>
<span id="cb108-2"><a href="#cb108-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb108-3"><a href="#cb108-3" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>option_1 <span class="op">=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb108-4"><a href="#cb108-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb108-5"><a href="#cb108-5" aria-hidden="true" tabindex="-1"></a>strcpy<span class="op">(</span>my_symbol<span class="op">-&gt;</span>primary<span class="op">,</span> <span class="st">&quot;331234567890&quot;</span><span class="op">);</span></span>
<span id="cb108-6"><a href="#cb108-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb108-7"><a href="#cb108-7" aria-hidden="true" tabindex="-1"></a>ZBarcode_Encode_and_Print<span class="op">(</span>my_symbol<span class="op">,</span> <span class="st">&quot;[99]1234-abcd&quot;</span><span class="op">,</span> <span class="dv">0</span><span class="op">,</span> <span class="dv">0</span><span class="op">);</span></span></code></pre></div>
<div class="sourceCode" id="cb109"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb109-1"><a href="#cb109-1" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>symbology <span class="op">=</span> BARCODE_EANX_CC<span class="op">;</span></span>
<span id="cb109-2"><a href="#cb109-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb109-3"><a href="#cb109-3" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>option_1 <span class="op">=</span> <span class="dv">1</span><span class="op">;</span></span>
<span id="cb109-4"><a href="#cb109-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb109-5"><a href="#cb109-5" aria-hidden="true" tabindex="-1"></a>strcpy<span class="op">(</span>my_symbol<span class="op">-&gt;</span>primary<span class="op">,</span> <span class="st">&quot;331234567890&quot;</span><span class="op">);</span></span>
<span id="cb109-6"><a href="#cb109-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb109-7"><a href="#cb109-7" aria-hidden="true" tabindex="-1"></a>ZBarcode_Encode_and_Print<span class="op">(</span>my_symbol<span class="op">,</span> <span class="st">&quot;[99]1234-abcd&quot;</span><span class="op">,</span> <span class="dv">0</span><span class="op">,</span> <span class="dv">0</span><span class="op">);</span></span></code></pre></div>
<p>EAN-2 and EAN-5 add-on data can be used with EAN and UPC symbols
using the + symbol as described in sections <a
href="#upc-universal-product-code-iso-15420">6.1.3 UPC (Universal
@ -5819,13 +5825,13 @@ size to full height can be given in thousandths (permille) using the
<code>--vers</code> option (API <code>option_2</code>). The default
value is 250 (25%).</p>
<p>For example the following</p>
<div class="sourceCode" id="cb109"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb109-1"><a href="#cb109-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> DAFT <span class="at">-d</span> AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF <span class="at">--height</span><span class="op">=</span>8.494 <span class="at">--vers</span><span class="op">=</span>256</span></code></pre></div>
<div class="sourceCode" id="cb110"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb110-1"><a href="#cb110-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> DAFT <span class="at">-d</span> AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF <span class="at">--height</span><span class="op">=</span>8.494 <span class="at">--vers</span><span class="op">=</span>256</span></code></pre></div>
<p>produces the same barcode (see <a
href="#royal-mail-4-state-customer-code-rm4scc">6.5.3 Royal Mail 4-State
Customer Code (RM4SCC)</a>) as</p>
<div class="sourceCode" id="cb110"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb110-1"><a href="#cb110-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> RM4SCC <span class="at">--compliantheight</span> <span class="at">-d</span> <span class="st">&quot;W1J0TR01&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb111"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb111-1"><a href="#cb111-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> RM4SCC <span class="at">--compliantheight</span> <span class="at">-d</span> <span class="st">&quot;W1J0TR01&quot;</span></span></code></pre></div>
<h2 id="matrix-symbols">6.6 Matrix Symbols</h2>
<h3 id="data-matrix-iso-16022">6.6.1 Data Matrix (ISO 16022)</h3>
<figure>
@ -6465,8 +6471,8 @@ be manually specified by using the <code>--mask</code> switch with
values 0-7, or in the API by setting
<code>option_3 = (N + 1) &lt;&lt; 8</code> where N is 0-7. To use with
<code>ZINT_FULL_MULTIBYTE</code> set</p>
<div class="sourceCode" id="cb111"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb111-1"><a href="#cb111-1" aria-hidden="true" tabindex="-1"></a>option_3 <span class="op">=</span> ZINT_FULL_MULTIBYTE <span class="op">|</span> <span class="op">(</span>N <span class="op">+</span> <span class="dv">1</span><span class="op">)</span> <span class="op">&lt;&lt;</span> <span class="dv">8</span></span></code></pre></div>
<div class="sourceCode" id="cb112"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb112-1"><a href="#cb112-1" aria-hidden="true" tabindex="-1"></a>option_3 <span class="op">=</span> ZINT_FULL_MULTIBYTE <span class="op">|</span> <span class="op">(</span>N <span class="op">+</span> <span class="dv">1</span><span class="op">)</span> <span class="op">&lt;&lt;</span> <span class="dv">8</span></span></code></pre></div>
<p>The <code>--fast</code> option (API
<code>input_mode |= FAST_MODE</code>) may be used when leaving Zint to
automatically select a mask to reduce the number of masks to try to four
@ -6602,8 +6608,8 @@ be manually specified by using the <code>--mask</code> switch with
values 0-3, or in the API by setting
<code>option_3 = (N + 1) &lt;&lt; 8</code> where N is 0-3. To use with
<code>ZINT_FULL_MULTIBYTE</code> set</p>
<div class="sourceCode" id="cb112"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb112-1"><a href="#cb112-1" aria-hidden="true" tabindex="-1"></a>option_3 <span class="op">=</span> ZINT_FULL_MULTIBYTE <span class="op">|</span> <span class="op">(</span>N <span class="op">+</span> <span class="dv">1</span><span class="op">)</span> <span class="op">&lt;&lt;</span> <span class="dv">8</span></span></code></pre></div>
<div class="sourceCode" id="cb113"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb113-1"><a href="#cb113-1" aria-hidden="true" tabindex="-1"></a>option_3 <span class="op">=</span> ZINT_FULL_MULTIBYTE <span class="op">|</span> <span class="op">(</span>N <span class="op">+</span> <span class="dv">1</span><span class="op">)</span> <span class="op">&lt;&lt;</span> <span class="dv">8</span></span></code></pre></div>
<h3 id="rectangular-micro-qr-code-rmqr-iso-23941">6.6.5 Rectangular
Micro QR Code (rMQR) (ISO 23941)</h3>
<figure>
@ -6870,8 +6876,8 @@ Latin-2 formatted use the <code>--binary</code> switch (API
<code>input_mode = DATA_MODE</code>).</p>
<p>The following example creates a symbol from data saved as a Latin-2
file:</p>
<div class="sourceCode" id="cb113"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb113-1"><a href="#cb113-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-o</span> upnqr.png <span class="at">-b</span> 143 <span class="at">--scale</span><span class="op">=</span>3 <span class="at">--binary</span> <span class="at">-i</span> upn.txt</span></code></pre></div>
<div class="sourceCode" id="cb114"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb114-1"><a href="#cb114-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-o</span> upnqr.png <span class="at">-b</span> 143 <span class="at">--scale</span><span class="op">=</span>3 <span class="at">--binary</span> <span class="at">-i</span> upn.txt</span></code></pre></div>
<p>A mask may be manually specified or the <code>--fast</code> option
used as with QRCODE.</p>
<h3 id="maxicode-iso-16023">6.6.7 MaxiCode (ISO 16023)</h3>
@ -6946,9 +6952,9 @@ your parcel courier.</td>
<p>The primary message can be set at the command prompt using the
<code>--primary</code> switch (API <code>primary</code>). The secondary
message uses the normal data entry method. For example:</p>
<div class="sourceCode" id="cb114"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb114-1"><a href="#cb114-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-o</span> test.eps <span class="at">-b</span> 57 <span class="at">--primary</span><span class="op">=</span><span class="st">&quot;999999999840012&quot;</span> <span class="dt">\</span></span>
<span id="cb114-2"><a href="#cb114-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&quot;Secondary Message Here&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb115"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb115-1"><a href="#cb115-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-o</span> test.eps <span class="at">-b</span> 57 <span class="at">--primary</span><span class="op">=</span><span class="st">&quot;999999999840012&quot;</span> <span class="dt">\</span></span>
<span id="cb115-2"><a href="#cb115-2" aria-hidden="true" tabindex="-1"></a> <span class="at">-d</span> <span class="st">&quot;Secondary Message Here&quot;</span></span></code></pre></div>
<p>When using the API the primary message must be placed in the
<code>primary</code> string. The secondary is entered in the same way as
described in <a href="#encoding-and-saving-to-file">5.2 Encoding and
@ -6961,9 +6967,9 @@ to be prefixed by the ISO/IEC 15434 Format <code>"01"</code>
<code>vv</code> is a 2-digit version, by using the <code>--scmvv</code>
switch (API <code>option_2 = vv + 1</code>). For example to use the
common version <code>"96"</code> (ASC MH10/SC 8):</p>
<div class="sourceCode" id="cb115"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb115-1"><a href="#cb115-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 57 <span class="at">--primary</span><span class="op">=</span><span class="st">&quot;152382802840001&quot;</span> <span class="at">--scmvv</span><span class="op">=</span>96 <span class="at">--esc</span> <span class="at">-d</span> <span class="dt">\</span></span>
<span id="cb115-2"><a href="#cb115-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb116"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb116-1"><a href="#cb116-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> 57 <span class="at">--primary</span><span class="op">=</span><span class="st">&quot;152382802840001&quot;</span> <span class="at">--scmvv</span><span class="op">=</span>96 <span class="at">--esc</span> <span class="at">-d</span> <span class="dt">\</span></span>
<span id="cb116-2"><a href="#cb116-2" aria-hidden="true" tabindex="-1"></a> <span class="st">&quot;1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E&quot;</span></span></code></pre></div>
<p>will prefix <code>"[)&gt;\R01\G96"</code> to the secondary message.
(<code>\R</code>, <code>\G</code> and <code>\E</code> are the escape
sequences for Record Separator, Group Separator and End of Transmission
@ -6972,8 +6978,8 @@ Sequences</a>.)</p>
<p>Modes 4 to 6 can be accessed using the <code>--mode</code> switch
(API <code>option_1</code>). Modes 4 to 6 do not have a primary message.
For example:</p>
<div class="sourceCode" id="cb116"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb116-1"><a href="#cb116-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-o</span> test.eps <span class="at">-b</span> 57 <span class="at">--mode</span><span class="op">=</span>4 <span class="at">-d</span> <span class="st">&quot;A MaxiCode Message in Mode 4&quot;</span></span></code></pre></div>
<div class="sourceCode" id="cb117"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb117-1"><a href="#cb117-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-o</span> test.eps <span class="at">-b</span> 57 <span class="at">--mode</span><span class="op">=</span>4 <span class="at">-d</span> <span class="st">&quot;A MaxiCode Message in Mode 4&quot;</span></span></code></pre></div>
<p>Mode 6 is reserved for the maintenance of scanner hardware and should
not be used to encode user data.</p>
<p>This symbology uses Latin-1 character encoding by default but also
@ -7898,8 +7904,8 @@ be manually specified by using the <code>--mask</code> switch with
values 0-3, or in the API by setting
<code>option_3 = (N + 1) &lt;&lt; 8</code> where N is 0-3. To use with
<code>ZINT_FULL_MULTIBYTE</code> set</p>
<div class="sourceCode" id="cb117"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb117-1"><a href="#cb117-1" aria-hidden="true" tabindex="-1"></a>option_3 <span class="op">=</span> ZINT_FULL_MULTIBYTE <span class="op">|</span> <span class="op">(</span>N <span class="op">+</span> <span class="dv">1</span><span class="op">)</span> <span class="op">&lt;&lt;</span> <span class="dv">8</span></span></code></pre></div>
<div class="sourceCode" id="cb118"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb118-1"><a href="#cb118-1" aria-hidden="true" tabindex="-1"></a>option_3 <span class="op">=</span> ZINT_FULL_MULTIBYTE <span class="op">|</span> <span class="op">(</span>N <span class="op">+</span> <span class="dv">1</span><span class="op">)</span> <span class="op">&lt;&lt;</span> <span class="dv">8</span></span></code></pre></div>
<h3 id="ultracode">6.6.14 Ultracode</h3>
<figure>
<img src="images/ultra.svg" title="fig:" class="ultra"
@ -7959,8 +7965,8 @@ data-tag=": Ultracode Error Correction Values">
</div>
<p>Zint does not currently implement data compression by default, but
this can be initiated through the API by setting</p>
<div class="sourceCode" id="cb118"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb118-1"><a href="#cb118-1" aria-hidden="true" tabindex="-1"></a>symbol<span class="op">-&gt;</span>option_3 <span class="op">=</span> ULTRA_COMPRESSION<span class="op">;</span></span></code></pre></div>
<div class="sourceCode" id="cb119"><pre
class="sourceCode c"><code class="sourceCode c"><span id="cb119-1"><a href="#cb119-1" aria-hidden="true" tabindex="-1"></a>symbol<span class="op">-&gt;</span>option_3 <span class="op">=</span> ULTRA_COMPRESSION<span class="op">;</span></span></code></pre></div>
<p>With compression, up to 504 digits, 375 alphanumerics or 252 bytes
can be encoded.</p>
<p>Revision 2 of Ultracode (2023) may be specified using
@ -8613,28 +8619,28 @@ properties that correspond to the <code>zint_symbol</code> structure
method <code>render()</code> which takes a Qt <code>QPainter</code> to
paint with, and a <code>QRectF</code> rectangular area specifying where
to paint into:</p>
<div class="sourceCode" id="cb119"><pre
class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb119-1"><a href="#cb119-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* Encode and display barcode in `paintRect` using `painter`.</span></span>
<span id="cb119-2"><a href="#cb119-2" aria-hidden="true" tabindex="-1"></a><span class="co"> Note: legacy argument `mode` is not used */</span></span>
<span id="cb119-3"><a href="#cb119-3" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> render<span class="op">(</span><span class="ex">QPainter</span><span class="op">&amp;</span> painter<span class="op">,</span> <span class="at">const</span> <span class="ex">QRectF</span><span class="op">&amp;</span> paintRect<span class="op">,</span></span>
<span id="cb119-4"><a href="#cb119-4" aria-hidden="true" tabindex="-1"></a> AspectRatioMode mode <span class="op">=</span> IgnoreAspectRatio<span class="op">);</span></span></code></pre></div>
<div class="sourceCode" id="cb120"><pre
class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb120-1"><a href="#cb120-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* Encode and display barcode in `paintRect` using `painter`.</span></span>
<span id="cb120-2"><a href="#cb120-2" aria-hidden="true" tabindex="-1"></a><span class="co"> Note: legacy argument `mode` is not used */</span></span>
<span id="cb120-3"><a href="#cb120-3" aria-hidden="true" tabindex="-1"></a><span class="dt">void</span> render<span class="op">(</span><span class="ex">QPainter</span><span class="op">&amp;</span> painter<span class="op">,</span> <span class="at">const</span> <span class="ex">QRectF</span><span class="op">&amp;</span> paintRect<span class="op">,</span></span>
<span id="cb120-4"><a href="#cb120-4" aria-hidden="true" tabindex="-1"></a> AspectRatioMode mode <span class="op">=</span> IgnoreAspectRatio<span class="op">);</span></span></code></pre></div>
<p><code>render()</code> will emit one of two Qt signals -
<code>encoded</code> on successful encoding and drawing, or
<code>errored</code> on failure. The client can connect and act
appropriately, for instance:</p>
<div class="sourceCode" id="cb120"><pre
class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb120-1"><a href="#cb120-1" aria-hidden="true" tabindex="-1"></a><span class="fu">connect</span><span class="op">(</span>qzint<span class="op">,</span> <span class="ex">SIGNAL</span><span class="op">(</span>encoded<span class="op">()),</span> <span class="ex">SLOT</span><span class="op">(</span>on_encoded<span class="op">()));</span></span>
<span id="cb120-2"><a href="#cb120-2" aria-hidden="true" tabindex="-1"></a><span class="fu">connect</span><span class="op">(</span>qzint<span class="op">,</span> <span class="ex">SIGNAL</span><span class="op">(</span>errored<span class="op">()),</span> <span class="ex">SLOT</span><span class="op">(</span>on_errored<span class="op">()));</span></span></code></pre></div>
<div class="sourceCode" id="cb121"><pre
class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb121-1"><a href="#cb121-1" aria-hidden="true" tabindex="-1"></a><span class="fu">connect</span><span class="op">(</span>qzint<span class="op">,</span> <span class="ex">SIGNAL</span><span class="op">(</span>encoded<span class="op">()),</span> <span class="ex">SLOT</span><span class="op">(</span>on_encoded<span class="op">()));</span></span>
<span id="cb121-2"><a href="#cb121-2" aria-hidden="true" tabindex="-1"></a><span class="fu">connect</span><span class="op">(</span>qzint<span class="op">,</span> <span class="ex">SIGNAL</span><span class="op">(</span>errored<span class="op">()),</span> <span class="ex">SLOT</span><span class="op">(</span>on_errored<span class="op">()));</span></span></code></pre></div>
<p>where <code>qzint</code> is an instance of <code>Zint::QZint</code>
and <code>on_encoded()</code> and <code>on_error()</code> are Qt slot
methods provided by the caller. On error, the error value and message
can be retrieved by the methods <code>getError()</code> and
<code>lastError()</code> respectively.</p>
<p>The other main method is <code>save_to_file()</code>:</p>
<div class="sourceCode" id="cb121"><pre
class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb121-1"><a href="#cb121-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* Encode and print barcode to file `filename`.</span></span>
<span id="cb121-2"><a href="#cb121-2" aria-hidden="true" tabindex="-1"></a><span class="co"> Only sets `getError()` on error, not on warning */</span></span>
<span id="cb121-3"><a href="#cb121-3" aria-hidden="true" tabindex="-1"></a><span class="dt">bool</span> save_to_file<span class="op">(</span><span class="at">const</span> <span class="ex">QString</span><span class="op">&amp;</span> filename<span class="op">);</span> <span class="co">// `ZBarcode_Print()`</span></span></code></pre></div>
<div class="sourceCode" id="cb122"><pre
class="sourceCode cpp"><code class="sourceCode cpp"><span id="cb122-1"><a href="#cb122-1" aria-hidden="true" tabindex="-1"></a><span class="co">/* Encode and print barcode to file `filename`.</span></span>
<span id="cb122-2"><a href="#cb122-2" aria-hidden="true" tabindex="-1"></a><span class="co"> Only sets `getError()` on error, not on warning */</span></span>
<span id="cb122-3"><a href="#cb122-3" aria-hidden="true" tabindex="-1"></a><span class="dt">bool</span> save_to_file<span class="op">(</span><span class="at">const</span> <span class="ex">QString</span><span class="op">&amp;</span> filename<span class="op">);</span> <span class="co">// `ZBarcode_Print()`</span></span></code></pre></div>
<p>which takes a <code>filename</code> to output to. It too will emit an
<code>errored</code> signal on failure, returning <code>false</code>
(but nothing on success, which just returns <code>true</code>). Note
@ -8649,33 +8655,33 @@ symbology capabilities, and utility methods such as
<h1 id="annex-c.-tcl-backend-binding">Annex C. Tcl Backend Binding</h1>
<p>A Tcl binding is available in the <code>"backend_tcl</code>
sub-directory. To make on Unix:</p>
<div class="sourceCode" id="cb122"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb122-1"><a href="#cb122-1" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> backend_tcl</span>
<span id="cb122-2"><a href="#cb122-2" aria-hidden="true" tabindex="-1"></a><span class="fu">autoconf</span></span>
<span id="cb122-3"><a href="#cb122-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span></span>
<span id="cb122-4"><a href="#cb122-4" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span>
<span id="cb122-5"><a href="#cb122-5" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> make install</span></code></pre></div>
<div class="sourceCode" id="cb123"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb123-1"><a href="#cb123-1" aria-hidden="true" tabindex="-1"></a><span class="bu">cd</span> backend_tcl</span>
<span id="cb123-2"><a href="#cb123-2" aria-hidden="true" tabindex="-1"></a><span class="fu">autoconf</span></span>
<span id="cb123-3"><a href="#cb123-3" aria-hidden="true" tabindex="-1"></a><span class="ex">./configure</span></span>
<span id="cb123-4"><a href="#cb123-4" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span></span>
<span id="cb123-5"><a href="#cb123-5" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> make install</span></code></pre></div>
<p>For Windows, a Visual Studio 6.0 project file is available at
<code>"backend_tcl\zint_tcl.dsp"</code>. This can also be opened (and
converted) by more modern Visual Studio versions, though some fixing up
of the project configuration will likely be required.</p>
<p>Once built and installed, invoke the Tcl/Tk CLI
<code>"wish"</code>:</p>
<div class="sourceCode" id="cb123"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb123-1"><a href="#cb123-1" aria-hidden="true" tabindex="-1"></a><span class="ex">wish</span></span></code></pre></div>
<div class="sourceCode" id="cb124"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb124-1"><a href="#cb124-1" aria-hidden="true" tabindex="-1"></a><span class="ex">wish</span></span></code></pre></div>
<p>and ignoring the Tk window click back to the command prompt
<code>"%"</code> and type:</p>
<div class="sourceCode" id="cb124"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb124-1"><a href="#cb124-1" aria-hidden="true" tabindex="-1"></a><span class="ex">require</span> package zint</span>
<span id="cb124-2"><a href="#cb124-2" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> help</span></code></pre></div>
<div class="sourceCode" id="cb125"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb125-1"><a href="#cb125-1" aria-hidden="true" tabindex="-1"></a><span class="ex">require</span> package zint</span>
<span id="cb125-2"><a href="#cb125-2" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> help</span></code></pre></div>
<p>which will show the usage message, with options very similiar to the
Zint CLI. (One notable difference is that boolean options such as
<code>-bold</code> take a <code>1</code> or <code>0</code> as an
argument.)</p>
<p>A demonstration Tcl/Tk program which is also useful in itself is
available at <code>"backend_tcl/demo/demo.tcl"</code>. To run type:</p>
<div class="sourceCode" id="cb125"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb125-1"><a href="#cb125-1" aria-hidden="true" tabindex="-1"></a><span class="ex">wish</span> demo/demo.tcl</span></code></pre></div>
<div class="sourceCode" id="cb126"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb126-1"><a href="#cb126-1" aria-hidden="true" tabindex="-1"></a><span class="ex">wish</span> demo/demo.tcl</span></code></pre></div>
<p>which will display the following window.</p>
<figure>
<img src="images/tcl_demo.png" title="fig:" class="pop"
@ -8889,10 +8895,12 @@ are:</p>
</dd>
<dt><code>--extraesc</code></dt>
<dd>
<p>Process the special escape sequences <code>\^A</code>,
<code>\^B</code> and <code>\^C</code> that allow manual switching of
Code Sets (Code 128 only). The sequence <code>\^^</code> can be used to
encode data that contains special escape sequences.</p>
<p>For Code 128 only, process the special escape sequences
<code>\^A</code>, <code>\^B</code> and <code>\^C</code> that allow
manual switching of Code Sets, and the special escape sequence
<code>\^1</code> that inserts an <code>FNC1</code> character. The
sequence <code>\^^</code> can be used to encode data that contains
special escape sequences.</p>
</dd>
<dt><code>--fast</code></dt>
<dd>
@ -9379,17 +9387,17 @@ Error counterpart of warning if <code>--werror</code> given
<h2 id="examples">EXAMPLES</h2>
<p>Create “out.png” (or “out.gif” if zint built without PNG support) in
the current directory, as a Code 128 symbol.</p>
<div class="sourceCode" id="cb134"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb134-1"><a href="#cb134-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-d</span> <span class="st">&#39;This Text&#39;</span></span></code></pre></div>
<p>Create “qr.svg” in the current directory, as a QR Code symbol.</p>
<div class="sourceCode" id="cb135"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb135-1"><a href="#cb135-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> QRCode <span class="at">-d</span> <span class="st">&#39;This Text&#39;</span> <span class="at">-o</span> <span class="st">&#39;qr.svg&#39;</span></span></code></pre></div>
class="sourceCode bash"><code class="sourceCode bash"><span id="cb135-1"><a href="#cb135-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-d</span> <span class="st">&#39;This Text&#39;</span></span></code></pre></div>
<p>Create “qr.svg” in the current directory, as a QR Code symbol.</p>
<div class="sourceCode" id="cb136"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb136-1"><a href="#cb136-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> QRCode <span class="at">-d</span> <span class="st">&#39;This Text&#39;</span> <span class="at">-o</span> <span class="st">&#39;qr.svg&#39;</span></span></code></pre></div>
<p>Use batch mode to read from an input file “ean13nos.txt” containing
13-digit GTINs, to create a series of EAN-13 barcodes, formatting the
output filenames to “ean001.gif”, “ean002.gif” etc. using the special
character “~”.</p>
<div class="sourceCode" id="cb136"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb136-1"><a href="#cb136-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> EANX <span class="at">--batch</span> <span class="at">-i</span> <span class="st">&#39;ean13nos.txt&#39;</span> <span class="at">-o</span> <span class="st">&#39;ean~~~.gif&#39;</span></span></code></pre></div>
<div class="sourceCode" id="cb137"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb137-1"><a href="#cb137-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> EANX <span class="at">--batch</span> <span class="at">-i</span> <span class="st">&#39;ean13nos.txt&#39;</span> <span class="at">-o</span> <span class="st">&#39;ean~~~.gif&#39;</span></span></code></pre></div>
<h2 id="bugs">BUGS</h2>
<p>Please send bug reports to
https://sourceforge.net/p/zint/tickets/.</p>

View File

@ -1,6 +1,6 @@
% Zint Barcode Generator and Zint Barcode Studio User Manual
% Version 2.13.0.9
% June 2024
% September 2024
# 1. Introduction
@ -574,7 +574,8 @@ 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.)
Code Sets and/or insert special FNC1 characters - 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
@ -3131,6 +3132,13 @@ zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc
will encode the data `"ABC\^BDEF"` in Code Set A.
There is also the extra escape `\^1`, which will encode a special Function Code
1 character (FNC1) anywhere you chose in the data, for instance
```bash
zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
```
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
symbols. The ISO/IEC 8859-1 character set is shown in Annex [A.2 Latin Alphabet
@ -3147,8 +3155,8 @@ It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The `BARCODE_CODE128AB`[^14] 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).
Note that the special extra escapes mentioned above are not available for this
variant (nor for any other).
[^14]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
still recognised.

View File

@ -1,6 +1,6 @@
Zint Barcode Generator and Zint Barcode Studio User Manual
Version 2.13.0.9
June 2024
September 2024
*******************************************************************************
* For reference the following is a text-only version of the Zint manual, *
@ -720,7 +720,8 @@ 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.)
Code Sets and/or insert special FNC1 characters - 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
@ -3029,6 +3030,11 @@ sequence, it can be escaped by doubling the caret (^). For instance
will encode the data "ABC\^BDEF" in Code Set A.
There is also the extra escape \^1, which will encode a special Function Code 1
character (FNC1) anywhere you chose in the data, for instance
zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
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
symbols. The ISO/IEC 8859-1 character set is shown in Annex A.2 Latin Alphabet
@ -3045,8 +3051,8 @@ It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The BARCODE_CODE128AB[14] 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).
Note that the special extra escapes mentioned above are not available for this
variant (nor for any other).
6.1.10.3 GS1-128
@ -4817,7 +4823,7 @@ configured barcode is displayed once the "Generate" button is pressed.
Annex D. Man Page ZINT(1)
% ZINT(1) Version 2.13.0.9 % % June 2024
% ZINT(1) Version 2.13.0.9 % % September 2024
NAME
@ -5011,9 +5017,10 @@ OPTIONS
--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.
For Code 128 only, process the special escape sequences \^A, \^B and \^C
that allow manual switching of Code Sets, and the special escape sequence
\^1 that inserts an FNC1 character. The sequence \^^ can be used to encode
data that contains special escape sequences.
--fast

View File

@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.2
.\" Automatically generated by Pandoc 3.3
.\"
.TH "ZINT" "1" "June 2024" "Version 2.13.0.9" ""
.TH "ZINT" "1" "September 2024" "Version 2.13.0.9"
.SH NAME
\f[CR]zint\f[R] \- encode data as a barcode image
.SH SYNOPSIS
@ -195,9 +195,11 @@ The escape sequences are:
.RE
.TP
\f[CR]\-\-extraesc\f[R]
Process the special escape sequences \f[CR]\[rs]\[ha]A\f[R],
\f[CR]\[rs]\[ha]B\f[R] and \f[CR]\[rs]\[ha]C\f[R] that allow manual
switching of Code Sets (Code 128 only).
For Code 128 only, process the special escape sequences
\f[CR]\[rs]\[ha]A\f[R], \f[CR]\[rs]\[ha]B\f[R] and
\f[CR]\[rs]\[ha]C\f[R] that allow manual switching of Code Sets, and the
special escape sequence \f[CR]\[rs]\[ha]1\f[R] that inserts an
\f[CR]FNC1\f[R] character.
The sequence \f[CR]\[rs]\[ha]\[ha]\f[R] can be used to encode data that
contains special escape sequences.
.TP

View File

@ -1,6 +1,6 @@
% ZINT(1) Version 2.13.0.9
%
% June 2024
% September 2024
# NAME
@ -174,8 +174,9 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
`--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.
: For Code 128 only, process the special escape sequences `\^A`, `\^B` and `\^C` that allow manual switching of Code
Sets, and the special escape sequence `\^1` that inserts an `FNC1` character. The sequence `\^^` can be used to
encode data that contains special escape sequences.
`--fast`

View File

@ -48,11 +48,12 @@
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="radC128ExtraEsc">
<property name="text">
<string>&amp;Manual Code Sets (Extra Escape Mode)</string>
<string>&amp;Manual Code Sets and FNC1s (Extra Escape Mode)</string>
</property>
<property name="toolTip">
<string>Process special escape sequences &quot;\^A&quot;, &quot;\^B&quot; and
&quot;\^C&quot; allowing manual Code Set selection</string>
<string>Process special escape sequences &quot;\^A&quot;, &quot;\^B&quot; and &quot;\^C&quot;
allowing manual Code Set selection and special escape
sequence &quot;\^1&quot; allowing manual FNC1s</string>
</property>
</widget>
</item>