1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-06-15 10:03:36 +00:00

Integrate GS1 Syntax Engine

This commit is contained in:
gitlost
2025-09-12 04:20:55 +01:00
parent ad95d8f2b0
commit 0650d5798e
32 changed files with 2109 additions and 723 deletions
+2 -1
View File
@@ -23,11 +23,12 @@ option(ZINT_TEST "Set test compile flag" OFF)
option(ZINT_COVERAGE "Set code coverage flags" OFF)
option(ZINT_SHARED "Build shared library" ON)
option(ZINT_STATIC "Build static library" OFF)
option(ZINT_FRONTEND "Build frontend" ON)
option(ZINT_USE_GS1SE "Build with GS1 Syntax Engine" ON)
option(ZINT_USE_PNG "Build with PNG support" ON)
option(ZINT_USE_QT "Build with Qt support" ON)
option(ZINT_QT6 "If ZINT_USE_QT, use Qt6" OFF)
option(ZINT_UNINSTALL "Add uninstall target" ON)
option(ZINT_FRONTEND "Build frontend" ON)
if(NOT ZINT_SHARED AND NOT ZINT_STATIC)
message(SEND_ERROR "Either ZINT_SHARED or ZINT_STATIC or both must be set")
+7 -1
View File
@@ -1,4 +1,4 @@
Version 2.15.0.9 (dev) not released yet (2025-09-07)
Version 2.15.0.9 (dev) not released yet (2025-09-12)
====================================================
**Incompatible changes**
@@ -11,6 +11,8 @@ Version 2.15.0.9 (dev) not released yet (2025-09-07)
after `ZBarcode_Encode()` and variants are called, and there are three new
methods in the Qt Backend to access to them
- New Qt Backend method `isBindable()` for new flag `ZINT_CAP_BINDABLE`
- New Qt Backend methods `gs1SyntaxEngine()`, `setGS1SyntaxEngine()` and
`haveGS1SyntaxEngine()` to access newly added GS1 Syntax Engine support
- GS1 Composites now return warning if CC type upped from requested due to size
of composite data
- EAN-8 with add-on now returns warning that it's non-standard
@@ -50,6 +52,10 @@ Changes
- Prefix all `INTERNAL` funcs/tables with `zint_`, except for those in
"backend/common.h", which are prefixed by `z_` - makes symbol clashes more
unlikely when zint is statically linked (ticket #337, props Ulrich Becker)
- Add support for GS1 Syntax Engine with new `input_mode` flag
`GS1SYNTAXENGINE_MODE` (CLI --gs1strict, GUI "GS1 Strict" checkbox)
- GS1_MODE: allow GS1 Digital Link URIs (no validation unless
`GS1SYNTAXENGINE_MODE` set)
Bugs
----
+17 -6
View File
@@ -1,10 +1,10 @@
% README.bsd 2025-02-02
% Tested on FreeBSD 14.2-RELEASE (with X11 + GNOME installed), OpenBSD 7.6 (with X11) and NetBSD 10.1 (with X11)
% README.bsd 2025-09-12
% Tested on FreeBSD 14.3-RELEASE (with X11 + GNOME installed), OpenBSD 7.7 (with X11) and NetBSD 10.1 (with X11)
1. Prerequisites for building zint
==================================
Prerequisites are git, cmake, make, gcc (or clang) and, for PNG support, libpng, e.g. FreeBSD
Prerequisites are git, cmake, make, gmake, gcc (or clang) and, for PNG support, libpng, e.g. FreeBSD
su
pkg install git cmake gmake gcc graphics/png
@@ -13,16 +13,27 @@ Prerequisites are git, cmake, make, gcc (or clang) and, for PNG support, libpng,
or OpenBSD (make and clang should already be installed):
su
pkg_add git cmake png
pkg_add git cmake gmake png
exit
or NetBSD (make and gcc should already be installed):
su
pkgin install git cmake png
pkgin install git cmake gmake png
exit
Then clone the latest source
To install the gs1encoders library, optional but needed for GS1 Syntax Engine support, clone, gmake and install:
git clone https://github.com/gs1/gs1-syntax-engine
cd gs1-syntax-engine/src/c-lib
gmake CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib
su
gmake install
exit
(on FreeBSD, the ldconfig not found error can be ignored)
Then clone the latest zint source
git clone https://git.code.sf.net/p/zint/code zint
cd zint
+17 -7
View File
@@ -1,6 +1,6 @@
% README.linux 2025-03-28
% README.linux 2025-09-12
% Tested on Ubuntu 20.04.4 LTS, Ubuntu 22.04 LTS, Ubuntu 24.04 LTS and
% Fedora Linux 41 (Workstation Edition)
% Fedora Linux 42 (Workstation Edition)
1. Prerequisites for building zint
==================================
@@ -21,7 +21,16 @@ or Fedora
sudo dnf install libpng-devel
Then either download the source code tarball
gs1encoders is optional but necessary for GS1 Syntax Engine support. To install clone the repo:
git clone https://github.com/gs1/gs1-syntax-engine
and navigate to "src/c-lib" and make with EXCLUDE_SYNTAX_DICTIONARY_LOADER defined:
cd gs1-syntax-engine/src/c-lib
make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && sudo make install
Now either download the zint source code tarball
wget -O zint-2.15.0-src.tar.gz \
https://sourceforge.net/projects/zint/files/zint/2.15.0/zint-2.15.0-src.tar.gz/download
@@ -122,19 +131,20 @@ On Fedora you may have to set LD_LIBRARY_PATH for zint ("libzint.so") and zint-q
A number of options are available:
ZINT_COVERAGE:BOOL=OFF # Set code coverage flags
ZINT_DEBUG:BOOL=OFF # Set debug compile flags
ZINT_FRONTEND:BOOL=ON # Build frontend
ZINT_NOOPT:BOOL=OFF # Set no optimize compile flags
ZINT_SANITIZE:BOOL=OFF # Set sanitize address/undefined
ZINT_SANITIZEM:BOOL=OFF # Set sanitize memory (ignored if ZINT_SANITIZE)
ZINT_TEST:BOOL=OFF # Set test compile flag
ZINT_COVERAGE:BOOL=OFF # Set code coverage flags
ZINT_SHARED:BOOL=ON # Build shared library
ZINT_STATIC:BOOL=OFF # Build static library
ZINT_TEST:BOOL=OFF # Set test compile flag
ZINT_UNINSTALL:BOOL=ON # Add uninstall target
ZINT_FRONTEND:BOOL=ON # Build frontend
ZINT_USE_GS1SE:BOOL=ON # Build with GS1 Syntax Engine
ZINT_USE_PNG:BOOL=ON # Build with PNG support
ZINT_USE_QT:BOOL=ON # Build with Qt support
ZINT_QT6:BOOL=OFF # If ZINT_USE_QT, use Qt6
ZINT_UNINSTALL:BOOL=ON # Add uninstall target
which can be set by doing e.g.
+7 -1
View File
@@ -1,4 +1,4 @@
% README.macos 2024-01-18
% README.macos 2025-09-12
% Tested on macOS 12.7.2 Monterey VirtualBox (thanks to https://github.com/myspaghetti/macos-virtualbox)
1. Prerequisites for building zint and zint-qt
@@ -29,6 +29,12 @@ Install CMake, libpng and Qt5 (git, make, cc & c++ should already be available w
brew install libpng
brew install qt5
Clone and install the gs1encoders library (optional but necessary for GS1 Syntax Engine support):
git clone https://github.com/gs1/gs1-syntax-engine
cd gs1-syntax-engine/src/c-lib
make CFLAGS_G='-DEXCLUDE_SYNTAX_DICTIONARY_LOADER' lib && sudo make install
Add the Qt5 bin directory to the PATH
export PATH='/usr/local/opt/qt@5/bin':"$PATH"
+13 -3
View File
@@ -8,6 +8,9 @@ project(zint)
if(ZINT_USE_PNG)
find_package(PNG)
endif()
if(ZINT_USE_GS1SE)
find_library(GS1SE gs1encoders)
endif()
set(zint_COMMON_SRCS common.c eci.c filemem.c general_field.c gs1.c large.c library.c reedsol.c)
set(zint_ONEDIM_SRCS 2of5.c 2of5inter.c 2of5inter_based.c bc412.c channel.c codabar.c code.c code11.c code128.c
@@ -15,10 +18,9 @@ set(zint_ONEDIM_SRCS 2of5.c 2of5inter.c 2of5inter_based.c bc412.c channel.c coda
set(zint_POSTAL_SRCS auspost.c imail.c mailmark.c postal.c)
set(zint_TWODIM_SRCS aztec.c codablock.c code1.c code16k.c code49.c composite.c dmatrix.c dotcode.c gridmtx.c
hanxin.c maxicode.c pdf417.c qr.c ultra.c)
set(zint_OUTPUT_SRCS bmp.c emf.c gif.c output.c pcx.c ps.c raster.c svg.c tif.c vector.c)
if(ZINT_USE_PNG AND PNG_FOUND)
set(zint_OUTPUT_SRCS bmp.c emf.c gif.c output.c pcx.c png.c ps.c raster.c svg.c tif.c vector.c)
else()
set(zint_OUTPUT_SRCS bmp.c emf.c gif.c output.c pcx.c ps.c raster.c svg.c tif.c vector.c)
set(zint_OUTPUT_SRCS ${zint_OUTPUT_SRCS} png.c)
endif()
set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
@@ -88,6 +90,14 @@ else()
message(STATUS "Not using PNG")
endif()
if(ZINT_USE_GS1SE AND NOT GS1SE-NOTFOUND)
zint_target_link_libraries(${GS1SE})
zint_target_compile_definitions(PRIVATE ZINT_HAVE_GS1SE)
message(STATUS "Using GS1 Syntax Engine")
else()
message(STATUS "Not using GS1 Syntax Engine")
endif()
# Incompatible with ZINT_SANITIZE (and also with ZINT_USE_PNG unless libpng instrumented)
if(NOT ZINT_SANITIZE AND ZINT_SANITIZEM AND CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -O2)
+1 -1
View File
@@ -539,7 +539,7 @@ INTERNAL int zint_gs1_128_cc(struct zint_symbol *symbol, unsigned char source[],
symbol->row_height[separator_row] = 1;
}
error_number = zint_gs1_verify(symbol, source, &length, reduced, &reduced_length);
error_number = zint_gs1_verify(symbol, source, length, reduced, &reduced_length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
+7 -5
View File
@@ -74,6 +74,7 @@ INTERNAL void z_to_upper(unsigned char source[], const int length) {
INTERNAL int z_chr_cnt(const unsigned char source[], const int length, const unsigned char c) {
int count = 0;
int i;
for (i = 0; i < length; i++) {
count += source[i] == c;
}
@@ -240,6 +241,7 @@ INTERNAL void z_expand(struct zint_symbol *symbol, const char data[], const int
/* Helper for `z_errtxt()` & `z_errtxtf()` to set "err_id: " part of error message, returning length */
static int errtxt_id_str(char *errtxt, int num) {
int len = 0;
if (num == -1) {
errtxt[0] = '\0';
return 0;
@@ -258,6 +260,7 @@ static int errtxt_id_str(char *errtxt, int num) {
errtxt[len++] = '0' + num;
errtxt[len++] = ':';
errtxt[len++] = ' ';
return len;
}
@@ -285,6 +288,7 @@ static int errtxtf_dpad(const char *fmt); /* Forward reference */
static int errtxtf_num_arg(const char *fmt, int *p_arg) {
int ret = 0;
int arg = -2;
if (!errtxtf_dpad(fmt) && z_isdigit(fmt[0])) {
arg = fmt[1] == '$' ? fmt[0] - '0' - 1 : -1;
ret = 2;
@@ -299,6 +303,7 @@ static int errtxtf_num_arg(const char *fmt, int *p_arg) {
static int errtxtf_slen(const char *fmt, const int arg, int *p_arg_cnt, int *p_len) {
int ret = 0;
int len = -1;
if (fmt[0] == '.') {
if (z_isdigit(fmt[1]) && fmt[1] != '0') {
len = fmt[1] - '0';
@@ -326,6 +331,7 @@ static int errtxtf_slen(const char *fmt, const int arg, int *p_arg_cnt, int *p_l
if (p_len) {
*p_len = len;
}
return ret;
}
@@ -662,11 +668,7 @@ INTERNAL int z_is_fixed_ratio(const int symbology) {
/* Whether next two characters are digits */
INTERNAL int z_is_twodigits(const unsigned char source[], const int length, const int position) {
if (position + 1 < length && z_isdigit(source[position]) && z_isdigit(source[position + 1])) {
return 1;
}
return 0;
return position + 1 < length && z_isdigit(source[position]) && z_isdigit(source[position + 1]);
}
/* Returns how many consecutive digits lie immediately ahead up to `max`, or all if `max` is -1 */
+25 -24
View File
@@ -1094,16 +1094,17 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
}
/* Calculate the width of the linear part (primary) */
static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source, int *p_length) {
static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source, int length) {
struct zint_symbol dummy = {0};
int error_number;
int linear_width;
dummy.symbology = BARCODE_GS1_128_CC;
dummy.option_1 = -1;
dummy.input_mode = symbol->input_mode;
/* Verified later via `linear` symbol (unless GS1SYNTAXENGINE_MODE, when already verified) */
dummy.input_mode = symbol->input_mode | GS1NOCHECK_MODE;
dummy.debug = symbol->debug;
error_number = zint_gs1_128_cc(&dummy, source, *p_length, 3 /*cc_mode*/, 0 /*cc_rows*/);
error_number = zint_gs1_128_cc(&dummy, source, length, 3 /*cc_mode*/, 0 /*cc_rows*/);
linear_width = dummy.width;
if (error_number >= ZINT_ERROR || (symbol->debug & ZINT_DEBUG_TEST)) {
(void) z_errtxt(0, symbol, -1, dummy.errtxt);
@@ -1112,8 +1113,6 @@ static int cc_linear_dummy_run(struct zint_symbol *symbol, unsigned char *source
if (error_number >= ZINT_ERROR) {
return 0;
}
/* May have changed if ESCAPE_MODE & GS1PARENS_MODE and escaped parentheses */
*p_length = (int) z_ustrlen(source);
return linear_width;
}
@@ -1128,7 +1127,6 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
struct zint_symbol *linear;
int top_shift, bottom_shift;
int linear_width = 0;
unsigned char primary[sizeof(symbol->primary)];
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
@@ -1155,13 +1153,10 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
"Invalid mode (CC-C only valid with GS1-128 linear component)");
}
/* Take copy of primary so passed-in remains unchanged */
memcpy(primary, symbol->primary, primary_len + 1); /* Include terminating NUL */
if (symbol->symbology == BARCODE_GS1_128_CC) {
/* Do a test run of encoding the linear component to establish its width */
linear_width = cc_linear_dummy_run(symbol, primary, &primary_len); /* Length can change */
if (linear_width == 0) {
linear_width = cc_linear_dummy_run(symbol, ZUCP(symbol->primary), primary_len);
if (linear_width == 0) { /* Only catches `GS1NOCHECK_MODE` errors */
return z_errtxt_adj(ZINT_ERROR_INVALID_DATA, symbol, "%1$s%2$s", " (linear component)");
}
if (debug_print) {
@@ -1178,7 +1173,8 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
int padded_primary_len;
int with_addon;
unsigned char padded_primary[21];
if (!zint_ean_leading_zeroes(symbol, primary, primary_len, padded_primary, &with_addon, NULL, NULL)) {
if (!zint_ean_leading_zeroes(symbol, ZCUCP(symbol->primary), primary_len, padded_primary,
&with_addon, NULL, NULL)) {
return z_errtxt_adj(ZINT_ERROR_TOO_LONG, symbol, "%1$s%2$s", " (linear component)");
}
padded_primary_len = (int) z_ustrlen(padded_primary);
@@ -1278,6 +1274,11 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
linear->symbology = symbol->symbology;
linear->input_mode = symbol->input_mode;
#ifdef ZINT_HAVE_GS1SE
if (symbol->input_mode & GS1SYNTAXENGINE_MODE) {
linear->input_mode |= GS1NOCHECK_MODE; /* Already verified in `ZBarcode_Encode_Segs()` */
}
#endif
linear->output_options = symbol->output_options;
linear->show_hrt = symbol->show_hrt;
linear->option_2 = symbol->option_2;
@@ -1295,35 +1296,35 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
case BARCODE_EANX_CC:
case BARCODE_EAN8_CC:
case BARCODE_EAN13_CC:
error_number = zint_eanx_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_eanx_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_GS1_128_CC:
/* GS1-128 needs to know which type of 2D component is used */
error_number = zint_gs1_128_cc(linear, primary, primary_len, cc_mode, symbol->rows);
error_number = zint_gs1_128_cc(linear, ZUCP(symbol->primary), primary_len, cc_mode, symbol->rows);
break;
case BARCODE_DBAR_OMN_CC:
error_number = zint_dbar_omn_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_omn_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_LTD_CC:
error_number = zint_dbar_ltd_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_ltd_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_EXP_CC:
error_number = zint_dbar_exp_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_exp_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_UPCA_CC:
error_number = zint_eanx_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_eanx_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_UPCE_CC:
error_number = zint_eanx_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_eanx_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_STK_CC:
error_number = zint_dbar_omn_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_omn_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_OMNSTK_CC:
error_number = zint_dbar_omn_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_omn_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
case BARCODE_DBAR_EXPSTK_CC:
error_number = zint_dbar_exp_cc(linear, primary, primary_len, symbol->rows);
error_number = zint_dbar_exp_cc(linear, ZUCP(symbol->primary), primary_len, symbol->rows);
break;
}
@@ -1461,7 +1462,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
error_number = zint_dbar_omnstk_set_height(symbol, symbol->rows - linear->rows + 1 /*first_row*/);
} else if (symbol->symbology == BARCODE_DBAR_EXP_CC || symbol->symbology == BARCODE_DBAR_EXPSTK_CC) {
/* If symbol->height given then min row height was returned, else default height */
if (error_number == 0) { /* Avoid overwriting any `gs1_verify()` warning */
if (error_number == 0) { /* Avoid overwriting any `zint_gs1_verify()` warning */
error_number = z_set_height(symbol, symbol->height ? linear->height : 0.0f,
symbol->height ? 0.0f : linear->height, 0.0f, 0 /*no_errtxt*/);
} else {
@@ -1491,7 +1492,7 @@ INTERNAL int zint_composite(struct zint_symbol *symbol, unsigned char source[],
if (raw_text) {
assert(linear->raw_segs && linear->raw_segs[0].source);
/* First linear, then pipe '|' separator (following BWIPP), then composite */
/* First linear, then pipe '|' separator (following BWIPP & GS1 Syntax Engine), then composite */
if (z_rt_cpy_cat(symbol, linear->raw_segs[0].source, linear->raw_segs[0].length, '|', source, length)) {
ZBarcode_Delete(linear);
return ZINT_ERROR_MEMORY; /* `z_rt_cpy_cat()` only fails with OOM */
+251 -63
View File
@@ -33,6 +33,9 @@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#ifdef ZINT_HAVE_GS1SE
#include <gs1encoders.h>
#endif
#include "common.h"
#include "gs1.h"
@@ -1609,33 +1612,192 @@ static int gs1_packagetype(const unsigned char *data, int data_len, int offset,
/* Generated by "php backend/tools/gen_gs1_linter.php > backend/gs1_lint.h" */
#include "gs1_lint.h"
/* Whether starts with Digital Link URI */
static int gs1_is_digital_link(const unsigned char *source, const int length) {
return (length >= 8 && (memcmp(source, "https://", 8) == 0 || memcmp(source, "HTTPS://", 8) == 0))
|| (length >= 7 && (memcmp(source, "http://", 7) == 0 || memcmp(source, "HTTP://", 7) == 0));
}
/* If built with GS1 Syntax Engine library */
#ifdef ZINT_HAVE_GS1SE
/* Use GS1 Syntax Engine to verify */
static int gs1se_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[], int *p_reduced_length) {
int i, j;
const int is_composite = z_is_composite(symbol->symbology);
const int primary_len = is_composite ? (int) strlen(symbol->primary) : 0;
const int gs1parens_mode = symbol->input_mode & GS1PARENS_MODE;
const char obracket = gs1parens_mode ? '(' : '[';
const int parens_cnt = !gs1parens_mode ? z_chr_cnt(source, length, '(') : 0;
int local_length = length;
const unsigned char *local_source = source;
const unsigned char *local_source2 = source;
unsigned char *local_source_buf = (unsigned char *) z_alloca(ARRAY_SIZE(symbol->primary) + length + 1);
unsigned char *local_source2_buf = (unsigned char *) z_alloca(ARRAY_SIZE(symbol->primary) * 2 + length
+ parens_cnt + 1);
int is_digital_link = 0;
gs1_encoder *ctx;
int gs1se_ret;
/* Need "linear|composite" format to check required AIs */
if (is_composite && primary_len) {
if (symbol->symbology == BARCODE_GS1_128_CC || symbol->symbology == BARCODE_DBAR_EXP_CC
|| symbol->symbology == BARCODE_DBAR_EXPSTK_CC) {
memcpy(local_source_buf, symbol->primary, primary_len);
local_source_buf[primary_len] = '|';
memcpy(local_source_buf + 1 + primary_len, source, length + 1); /* Include terminating NUL */
local_length += 1 + primary_len;
} else {
/* Just use dummy "01" linear */
memcpy(local_source_buf, gs1parens_mode ? "(01)12345678901231|" : "[01]12345678901231|", 19);
memcpy(local_source_buf + 19, source, length + 1); /* Include terminating NUL */
local_length += 19;
}
local_source = local_source_buf;
local_source2 = local_source_buf;
}
if (local_source[0] != obracket) {
if (!z_is_fixed_ratio(symbol->symbology)) { /* Only matrix symbols can encode Digital Link URIs */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 264, "Data does not start with an AI");
}
if (!(is_digital_link = gs1_is_digital_link(local_source, local_length))) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 265,
"Data does not start with an AI or a Digital Link URI");
}
}
if (!is_digital_link) {
/* Convert to GS1 Syntax Engine parenthesis mode */
if (!gs1parens_mode) {
/* Replace '[' and ']' with '(' and ')' & escape any data opening parentheses (not closing parentheses) */
int bracket_level = 0; /* Non-compliant closing square brackets may be in text */
for (i = 0, j = 0; i < local_length; i++) {
if (local_source[i] == '[') {
local_source2_buf[j++] = '(';
bracket_level++;
} else if (local_source[i] == ']' && bracket_level) {
local_source2_buf[j++] = ')';
bracket_level--;
} else {
if (local_source[i] == '(') {
local_source2_buf[j++] = '\\';
}
local_source2_buf[j++] = local_source[i];
}
}
local_source2_buf[j] = '\0';
local_source2 = local_source2_buf;
/* Unescape any backslashed closing parentheses */
} else if (strchr(ZCCP(local_source), '\\') != NULL) {
for (i = 0, j = 0; i < local_length; i++) {
if (local_source[i] == '\\' && i + 1 < local_length && local_source[i + 1] == ')') {
i++;
}
local_source2_buf[j++] = local_source[i];
}
local_source2_buf[j] = '\0';
local_source2 = local_source2_buf;
}
}
if (!(ctx = gs1_encoder_init(NULL))) {
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 266, "Insufficient memory for GS1 Syntax Engine");
}
if (is_digital_link) {
gs1se_ret = gs1_encoder_setDataStr(ctx, ZCCP(local_source2));
} else {
gs1se_ret = gs1_encoder_setAIdataStr(ctx, ZCCP(local_source2));
}
if (!gs1se_ret) {
const char *errmsg = gs1_encoder_getErrMsg(ctx);
const int errmsg_len = (int) strlen(errmsg);
const char *errmarkup = gs1_encoder_getErrMarkup(ctx);
int errmarkup_len = (int) strlen(errmarkup);
if (errmarkup_len && errmsg_len + 1 + errmarkup_len < ARRAY_SIZE(symbol->errtxt)) {
char *local_errmarkup = (char *) z_alloca(errmarkup_len * 4 + 1);
z_debug_print_escape(ZCUCP(errmarkup), errmarkup_len, local_errmarkup);
errmarkup_len = (int) strlen(local_errmarkup);
if (errmsg_len + 1 + errmarkup_len < ARRAY_SIZE(symbol->errtxt)) {
ZEXT z_errtxtf(0, symbol, 267, "%1$s %2$s", errmsg, local_errmarkup);
} else {
z_errtxt(0, symbol, 268, errmsg);
}
} else {
z_errtxt(0, symbol, 268, errmsg);
}
gs1_encoder_free(ctx);
return ZINT_ERROR_INVALID_DATA;
}
/* If Digital Link, set `reduced` */
if (is_digital_link) {
const char *scan_data;
gs1_encoder_setSym(ctx, gs1_encoder_sDM); /* Required for `gs1_encoder_getScanData()` */
if (!(scan_data = gs1_encoder_getScanData(ctx))) { /* Shouldn't happen */
const char *errmsg = gs1_encoder_getErrMsg(ctx);
z_errtxt(0, symbol, 269, strlen(errmsg) ? errmsg : "Internal error");
gs1_encoder_free(ctx);
return ZINT_ERROR_ENCODING_PROBLEM;
}
*p_reduced_length = (int) strlen(scan_data);
/* Skip over Symbology Identifier */
if (*p_reduced_length >= 3 && scan_data[0] == ']') {
scan_data += 3;
*p_reduced_length -= 3;
}
memcpy(reduced, scan_data, *p_reduced_length + 1); /* Include terminating NUL */
} else {
*p_reduced_length = 0; /* Not Digital Link & `reduced` not set */
}
gs1_encoder_free(ctx);
return 0;
}
#endif /* ZINT_HAVE_GS1SE */
#define GS1_PARENS_PLACEHOLDER_MASK 0x20 /* Mask `(` or `)` by this if escaped (get BS (\x08) or HT (\x09)) */
/* Verify a GS1 input string */
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[], int *p_length,
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[], int *p_reduced_length) {
int i, j;
int error_value = 0;
int bracket_level = 0, max_bracket_level = 0;
int ai_length, ai_latch;
int max_ai_length = 0, min_ai_length = 5;
int max_ai_pos = 0, min_ai_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positives */
int ai_zero_len_no_data = 0, ai_single_digit = 0, ai_nonnumeric = 0;
int ai_nonnumeric_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positive */
int length = *p_length;
const char obracket = symbol->input_mode & GS1PARENS_MODE ? '(' : '[';
const char cbracket = symbol->input_mode & GS1PARENS_MODE ? ')' : ']';
const int ai_max = z_chr_cnt(source, length, obracket) + 1; /* Plus 1 so non-zero */
int *ai_value = (int *) z_alloca(sizeof(int) * ai_max);
int *ai_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_length = (int *) z_alloca(sizeof(int) * ai_max);
int error_number = 0;
int bracket_level = 0;
int ai_latch;
int local_length = length;
const unsigned char *local_source = source;
unsigned char *local_source_buf = (unsigned char *) z_alloca(length + 1);
const int gs1parens_mode = symbol->input_mode & GS1PARENS_MODE;
const char obracket = gs1parens_mode ? '(' : '[';
const char cbracket = gs1parens_mode ? ')' : ']';
int done_gs1se = 0;
int is_digital_link = 0; /* Is Digital Link? */
assert(p_length != p_reduced_length); /* Make sure we don't overwrite one with the other */
/* Note: Digital Link URIs only validated if have GS1 Syntax Engine and GS1SYNTAXENGINE_MODE set */
#ifdef ZINT_HAVE_GS1SE
if ((symbol->input_mode & GS1SYNTAXENGINE_MODE) && !(symbol->input_mode & GS1NOCHECK_MODE)) {
/* Strict verification */
if ((error_number = gs1se_verify(symbol, source, length, reduced, p_reduced_length))) {
return error_number;
}
done_gs1se = 1;
is_digital_link = *p_reduced_length != 0; /* `p_reduced_length` will be set if Digital Link */
}
#endif
if (!done_gs1se) {
/* Detect control and extended ASCII characters */
for (i = 0; i < length; i++) {
if (source[i] >= 128) {
if (!z_isascii(source[i])) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 250,
"Extended ASCII characters are not supported by GS1");
}
@@ -1651,10 +1813,26 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
}
if (source[0] != obracket) {
if (!z_is_fixed_ratio(symbol->symbology)) { /* Only matrix symbols can encode Digital Link URIs */
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 252, "Data does not start with an AI");
}
if (!(is_digital_link = gs1_is_digital_link(source, length))) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 855,
"Data does not start with an AI or Digital Link URI");
}
}
}
if ((symbol->input_mode & (ESCAPE_MODE | GS1PARENS_MODE)) == (ESCAPE_MODE | GS1PARENS_MODE)) {
if (is_digital_link) {
if (!done_gs1se) {
/* Just copy over Digital Link URI - no verification */
memcpy(reduced, source, length + 1); /* Include terminating NUL */
*p_reduced_length = length;
}
return 0;
}
if (gs1parens_mode) {
/* Check for escaped parentheses */
for (i = 0; i < length; i++) {
if (source[i] == '\\' && i + 1 < length && (source[i + 1] == '(' || source[i + 1] == ')')) {
@@ -1662,30 +1840,44 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
}
}
if (i != length) {
local_source = local_source_buf;
/* Replace with control-char placeholders */
for (i = 0, j = 0; i < length; i++) {
if (source[i] == '\\' && i + 1 < length && (source[i + 1] == '(' || source[i + 1] == ')')) {
source[j++] = source[++i] & ~GS1_PARENS_PLACEHOLDER_MASK; /* BS (\x08) or HT (\x09) */
local_source_buf[j++] = source[++i] & ~GS1_PARENS_PLACEHOLDER_MASK; /* BS (\x08) or HT (\x09) */
} else {
source[j++] = source[i];
local_source_buf[j++] = source[i];
}
}
source[j] = '\0';
length = j;
local_source_buf[j] = '\0';
local_length = j;
}
}
if (!done_gs1se) {
/* Verify AIs */
int max_ai_length = 0, min_ai_length = 5;
int max_bracket_level = 0;
int ai_length = 0;
int max_ai_pos = 0, min_ai_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positives */
int ai_zero_len_no_data = 0, ai_single_digit = 0, ai_nonnumeric = 0;
int ai_nonnumeric_pos = 0; /* Suppress gcc 14 "-Wmaybe-uninitialized" false positive */
const int ai_max = z_chr_cnt(local_source, local_length, obracket) + 1; /* Plus 1 so non-zero */
int *ai_value = (int *) z_alloca(sizeof(int) * ai_max);
int *ai_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_location = (int *) z_alloca(sizeof(int) * ai_max);
int *data_length = (int *) z_alloca(sizeof(int) * ai_max);
/* Check the balance of the brackets & AI lengths */
ai_length = 0;
ai_latch = 0;
for (i = 0; i < length; i++) {
if (source[i] == obracket) {
for (i = 0; i < local_length; i++) {
if (local_source[i] == obracket) {
bracket_level++;
if (bracket_level > max_bracket_level) {
max_bracket_level = bracket_level;
}
ai_latch = 1;
} else if (source[i] == cbracket && bracket_level) {
} else if (local_source[i] == cbracket && bracket_level) {
bracket_level--;
if (ai_length > max_ai_length) {
max_ai_length = ai_length;
@@ -1696,7 +1888,7 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
min_ai_pos = i - ai_length;
}
/* Check zero-length AI has data */
if (ai_length == 0 && (i + 1 == length || source[i + 1] == obracket)) {
if (ai_length == 0 && (i + 1 == local_length || local_source[i + 1] == obracket)) {
ai_zero_len_no_data = 1;
} else if (ai_length == 1) {
ai_single_digit = 1;
@@ -1705,7 +1897,7 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
ai_latch = 0;
} else if (ai_latch) {
ai_length++;
if (!z_isdigit(source[i])) {
if (!z_isdigit(local_source[i])) {
ai_nonnumeric = 1;
ai_nonnumeric_pos = i - ai_length + 1;
}
@@ -1745,14 +1937,14 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
}
if (!(symbol->input_mode & GS1NOCHECK_MODE)) {
unsigned char *local_source = source;
unsigned char *local_source_buf = (unsigned char *) z_alloca(length + 1);
const unsigned char *local_source2 = local_source;
unsigned char *local_source2_buf = (unsigned char *) z_alloca(local_length + 1);
int ai_count = 0;
for (i = 1; i < length; i++) {
if (source[i - 1] == obracket) {
for (i = 1; i < local_length; i++) {
if (local_source[i - 1] == obracket) {
ai_location[ai_count] = i;
for (j = 1; source[i + j] != cbracket; j++);
ai_value[ai_count] = z_to_int(source + i, j);
for (j = 1; local_source[i + j] != cbracket; j++);
ai_value[ai_count] = z_to_int(local_source + i, j);
ai_count++;
i += j;
}
@@ -1767,8 +1959,8 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
data_location[i] = ai_location[i] + 3;
}
data_length[i] = 0;
while (data_location[i] + data_length[i] < length
&& source[data_location[i] + data_length[i]] != obracket) {
while (data_location[i] + data_length[i] < local_length
&& local_source[data_location[i] + data_length[i]] != obracket) {
data_length[i]++;
}
if (data_length[i] == 0) {
@@ -1777,13 +1969,13 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
}
}
if (length != *p_length) {
if (local_length != length) {
/* Temporarily re-instate escaped parentheses before linting */
local_source = local_source_buf;
memcpy(local_source, source, length + 1); /* Include terminating NUL */
for (i = 0; i < length; i++) {
if (local_source[i] < '\x1D') {
local_source[i] |= GS1_PARENS_PLACEHOLDER_MASK;
local_source2 = local_source2_buf;
memcpy(local_source2_buf, local_source, local_length + 1); /* Include terminating NUL */
for (i = 0; i < local_length; i++) {
if (local_source2_buf[i] < '\x1D') {
local_source2_buf[i] |= GS1_PARENS_PLACEHOLDER_MASK;
}
}
}
@@ -1793,20 +1985,22 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
for (i = 0; i < ai_count; i++) {
int err_no, err_posn;
char err_msg[50];
if (!gs1_lint(ai_value[i], local_source + data_location[i], data_length[i], &err_no, &err_posn,
if (!gs1_lint(ai_value[i], local_source2 + data_location[i], data_length[i], &err_no, &err_posn,
err_msg)) {
if (err_no == 1) {
z_errtxtf(0, symbol, 260, "Invalid AI (%02d)", ai_value[i]);
} else if (err_no == 2 || err_no == 4) { /* 4 is backward-incompatible bad length */
z_errtxtf(0, symbol, 259, "Invalid data length for AI (%02d)", ai_value[i]);
} else {
ZEXT z_errtxtf(0, symbol, 261, "AI (%1$02d) position %2$d: %3$s", ai_value[i], err_posn, err_msg);
ZEXT z_errtxtf(0, symbol, 261, "AI (%1$02d) position %2$d: %3$s", ai_value[i], err_posn,
err_msg);
}
/* For backward compatibility only error on unknown AI or bad length */
if (err_no == 1 || err_no == 2) {
return ZINT_ERROR_INVALID_DATA;
}
error_value = ZINT_WARN_NONCOMPLIANT;
error_number = ZINT_WARN_NONCOMPLIANT;
}
}
}
}
@@ -1814,53 +2008,47 @@ INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[],
/* Resolve AI data - put resulting string in 'reduced' */
j = 0;
ai_latch = 1;
for (i = 0; i < length; i++) {
if (source[i] == obracket) {
for (i = 0; i < local_length; i++) {
if (local_source[i] == obracket) {
bracket_level++;
/* Start of an AI string */
if (ai_latch == 0) {
reduced[j++] = '\x1D';
}
if (i + 1 != length) {
int last_ai = z_to_int(source + i + 1, 2);
if (i + 1 != local_length) {
int last_ai = z_to_int(local_source + i + 1, 2);
ai_latch = 0;
/* The following values from GS1 General Specifications Release 25.0
Figure 7.8.5-2 "Element strings with predefined length using GS1 Application Identifiers" */
if ((last_ai >= 0 && last_ai <= 4) || (last_ai >= 11 && last_ai <= 20)
/* NOTE: as noted by Terry Burton the following complies with ISO/IEC 24724:2011 Table D.1,
but clashes with TPX AI [235], introduced May 2019; awaiting feedback from GS1 */
/* NOTE: as noted by Terry Burton the following complies with ISO/IEC 24724:2011 Table
D.1, but clashes with TPX AI [235], introduced May 2019; awaiting feedback from GS1 */
|| last_ai == 23 /* legacy support */ /* TODO: probably remove */
|| (last_ai >= 31 && last_ai <= 36) || last_ai == 41) {
ai_latch = 1;
}
}
} else if (source[i] == cbracket && bracket_level) {
} else if (local_source[i] == cbracket && bracket_level) {
/* The closing bracket is simply dropped from the input */
bracket_level--;
} else {
reduced[j++] = source[i];
reduced[j++] = local_source[i];
}
}
reduced[j] = '\0';
*p_reduced_length = j;
if (length != *p_length) {
if (local_length != length) {
/* Re-instate escaped parentheses */
for (i = 0; i < *p_reduced_length; i++) {
if (reduced[i] < '\x1D') {
reduced[i] |= GS1_PARENS_PLACEHOLDER_MASK;
}
}
for (i = 0; i < length; i++) {
if (source[i] < '\x1D') {
source[i] |= GS1_PARENS_PLACEHOLDER_MASK;
}
}
*p_length = length;
}
/* The character '\x1D' (GS) in the reduced string refers to the FNC1 character */
return error_value;
return error_number;
}
/* Helper to return standard GS1 check digit (GS1 General Specifications 7.9.1) */
+1 -1
View File
@@ -37,7 +37,7 @@
extern "C" {
#endif /* __cplusplus */
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, unsigned char source[], int *p_length,
INTERNAL int zint_gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int length,
unsigned char reduced[], int *p_reduced_length);
INTERNAL char zint_gs1_check_digit(const unsigned char source[], const int length);
INTERNAL int zint_gs1_iso3166_alpha2(const unsigned char *cc);
+20 -6
View File
@@ -1192,7 +1192,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if (gs1_compliant(symbol->symbology)) {
/* Reduce input for composite and non-forced symbologies, others (GS1_128 and DBAR_EXP based) will
handle it themselves */
const int have_composite = z_is_composite(symbol->symbology);
const int is_composite = z_is_composite(symbol->symbology);
/* Deal with any ECI first */
if (symbol->eci) {
@@ -1205,15 +1205,20 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
symbologies, as standards are inconsistent in mentioning it */
}
if (have_composite || !check_force_gs1(symbol->symbology)) {
if (is_composite || !check_force_gs1(symbol->symbology)) {
unsigned char *reduced = (unsigned char *) z_alloca(local_segs[0].length + 1);
int source_len = local_segs[0].length;
error_number = zint_gs1_verify(symbol, local_segs[0].source, &source_len, reduced,
error_number = zint_gs1_verify(symbol, local_segs[0].source, local_segs[0].length, reduced,
&local_segs[0].length);
if (error_number) {
if (have_composite) {
#ifdef ZINT_HAVE_GS1SE
if (is_composite && !(symbol->input_mode & GS1SYNTAXENGINE_MODE)) {
z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)");
}
#else
if (is_composite) {
z_errtxt_adj(0, symbol, "%1$s%2$s", " (2D component)");
}
#endif
error_number = error_tag(error_number, symbol, -1, NULL);
if (error_number >= ZINT_ERROR) {
return error_number;
@@ -1222,7 +1227,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
memcpy(local_segs[0].source, reduced, local_segs[0].length + 1); /* Include terminating NUL */
/* Set raw text for non-composites (composites set their own raw text) */
if (!have_composite && raw_text && z_rt_cpy(symbol, reduced, local_segs[0].length)) {
if (!is_composite && raw_text && z_rt_cpy(symbol, reduced, local_segs[0].length)) {
return error_tag(ZINT_ERROR_MEMORY, symbol, -1, NULL); /* `z_rt_cpy()` only fails with OOM */
}
}
@@ -2218,6 +2223,15 @@ int ZBarcode_NoPng(void) {
#endif
}
/* Whether Zint built with GS1 Syntext Engine support */
int ZBarcode_HaveGS1SyntaxEngine(void) {
#ifdef ZINT_HAVE_GS1SE
return 1;
#else
return 0;
#endif
}
/* Return the version of Zint linked to */
int ZBarcode_Version(void) {
#if ZINT_VERSION_BUILD
+1 -1
View File
@@ -1226,7 +1226,7 @@ INTERNAL int zint_dbar_exp_cc(struct zint_symbol *symbol, unsigned char source[]
const int raw_text = symbol->output_options & BARCODE_RAW_TEXT;
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
error_number = zint_gs1_verify(symbol, source, &length, reduced, &reduced_length);
error_number = zint_gs1_verify(symbol, source, length, reduced, &reduced_length);
if (error_number >= ZINT_ERROR) {
return error_number;
}
+3
View File
@@ -72,6 +72,9 @@ zint_add_test(gb2312 test_gb2312)
zint_add_test(gif test_gif)
zint_add_test(gridmtx test_gridmtx)
zint_add_test(gs1 test_gs1)
if(ZINT_USE_GS1SE AND NOT GS1SE-NOTFOUND)
zint_add_test(gs1se test_gs1se)
endif()
zint_add_test(hanxin test_hanxin)
zint_add_test(imail test_imail)
zint_add_test(iso3166 test_iso3166)
+1 -1
View File
@@ -306,7 +306,7 @@ static void test_options(const testCtx *const p_ctx) {
/* 25*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, { 0, 0, "" }, "[91]A", 0, 15, 15, "", (41 << 8) | 3, 1 },
/* 26*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)A", 0, 15, 15, "", (41 << 8) | 3, 1 },
/* 27*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", -1, 0 },
/* 28*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)\\(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", -1, 0 },
/* 28*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (41 << 8) | 3, 1 }, /* Escaped parens now work without ESCAPE_MODE */
/* 29*/ { BARCODE_AZTEC, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, -1, -1, { 0, 0, "" }, "(91)\\(", 0, 15, 15, "", (41 << 8) | 3, 1 },
/* 30*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, { 0, 0, "" }, "A", 0, 109, 109, "", (99 << 8) | 4, 26 }, /* 22 layers */
/* 31*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 709: Version '27' out of range for Reader Initialisation symbols (maximum 26)", -1, 27 }, /* 23 layers */
+2 -3
View File
@@ -688,7 +688,7 @@ static void test_options(const testCtx *const p_ctx) {
/* 81*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)12", 0, 10, 10, "", 1, 1, "" },
/* 82*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, -1, { 0, 0, "" }, "[90](", 0, 10, 10, "", 1, 1, "" },
/* 83*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", 0, 1, "" },
/* 84*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)\\(", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 253: Malformed AI in input (brackets don't match)", 0, 1, "" },
/* 84*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)\\(", 0, 10, 10, "", 1, 1, "" }, /* Escaped parens now work without ESCAPE_MODE */
/* 85*/ { BARCODE_DATAMATRIX, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, -1, -1, -1, { 0, 0, "" }, "(90)\\(", 0, 10, 10, "", 1, 1, "" },
/* 86*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "", 2, 1, "" },
/* 87*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "", 2, 1, "" },
@@ -1319,8 +1319,7 @@ static void test_input(const testCtx *const p_ctx) {
i, expected_rows_width, prev_expected_rows_width);
if ((data[i].input_mode & 0x07) == GS1_MODE) {
int data_len = length;
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), &data_len, reduced, &length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, reduced, &length);
assert_zero(ret, "i:%d zint_gs1_verify() ret %d != 0 (%s)\n", i, ret, symbol->errtxt);
text = reduced;
} else {
+203 -190
View File
@@ -395,77 +395,88 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 31*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 32*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "" },
/* 33*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF)GH", "", 0, "(91)ABCDEF)GH", "91ABCDEF)GH" },
/* 34*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF)GH", "" },
/* 35*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF)GH", "91ABCDEF)GH" },
/* 36*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 37*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 38*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 39*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 40*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12", "" },
/* 41*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012|2112345" },
/* 42*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12", "" },
/* 43*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 44*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 45*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 46*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012|2112345" },
/* 47*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12", "" },
/* 48*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 49*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231", "" },
/* 50*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234567890123", "", 0, "(01)12345678901231", "0112345678901231" },
/* 51*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348", "" },
/* 52*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(01)00000000012348", "0100000000012348" },
/* 53*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457", "" },
/* 54*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402", "" },
/* 55*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675", "" },
/* 56*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "12345678901234567", "", 0, "(00)123456789012345675", "00123456789012345675" },
/* 57*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348", "" },
/* 58*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(00)000000000000012348", "00000000000000012348" },
/* 59*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457", "" },
/* 60*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402", "" },
/* 61*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 62*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12", "" },
/* 63*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012" },
/* 64*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "" },
/* 65*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "01123456789012312012" },
/* 66*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 67*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 68*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "01123456789012311012\03520AB" },
/* 69*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 70*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012" },
/* 71*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "" },
/* 72*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "011234567890123110AB\035201290ABC(2012" },
/* 73*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "" },
/* 74*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "011234567890123110AB\035201290ABC20)12" },
/* 75*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "" },
/* 76*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "011234567890123110AB\035201290ABC(20)12" },
/* 77*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , ""},
/* 78*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , "011234567890123110AB\035201290ABC(20)12\0359112(" },
/* 79*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "" },
/* 80*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234", "" },
/* 81*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "0112345678901234|2112345" },
/* 82*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231", "" },
/* 83*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "" },
/* 84*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "011234567890123120122112345|2112345" },
/* 85*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "" },
/* 86*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "011234567890123110(|21123()" },
/* 87*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)(", "" },
/* 88*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)(", "011234567890123110(|21123()" },
/* 89*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "" },
/* 90*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "", "" },
/* 91*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012" },
/* 92*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "", "" },
/* 93*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "" },
/* 94*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/* 95*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "" },
/* 96*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/* 97*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" , ""},
/* 98*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "", "" },
/* 99*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012|2112345" },
/*100*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "", "" },
/*101*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "" },
/*102*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/*103*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*104*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/* 34*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "" }, /* Escaped parens now work without ESCAPE_MODE & now kept in HRT */
/* 35*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "" }, /* Escaped parens now kept in HRT */
/* 36*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "91ABCDEF)GH" },
/* 37*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\)GH", "", 0, "(91)ABCDEF\\)GH", "91ABCDEF)GH" },
/* 38*/ { BARCODE_GS1_128, -1, -1, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "" },
/* 39*/ { BARCODE_GS1_128, -1, BARCODE_RAW_TEXT, "[91]ABCDEF(GH", "", 0, "(91)ABCDEF(GH", "91ABCDEF(GH" },
/* 40*/ { BARCODE_GS1_128, GS1PARENS_MODE, -1, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "" },
/* 41*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, -1, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "" },
/* 42*/ { BARCODE_GS1_128, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "91ABCDEF(GH" },
/* 43*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(91)ABCDEF\\(GH", "", 0, "(91)ABCDEF\\(GH", "91ABCDEF(GH" },
/* 44*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "(01)12345678901234(20)12", "" },
/* 45*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012|2112345" },
/* 46*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "(01)12345678901231(20)12", "" },
/* 47*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 48*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "[21]12345", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 49*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 50*/ { BARCODE_GS1_128_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "[21]12345", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012|2112345" },
/* 51*/ { BARCODE_GS1_128_CC, -1, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)AB(20)12", "" },
/* 52*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]AB[20]12", "[30]1234567A", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 53*/ { BARCODE_EAN14, -1, -1, "1234567890123", "", 0, "(01)12345678901231", "" },
/* 54*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234567890123", "", 0, "(01)12345678901231", "0112345678901231" },
/* 55*/ { BARCODE_EAN14, -1, -1, "1234", "", 0, "(01)00000000012348", "" },
/* 56*/ { BARCODE_EAN14, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(01)00000000012348", "0100000000012348" },
/* 57*/ { BARCODE_EAN14, -1, -1, "12345", "", 0, "(01)00000000123457", "" },
/* 58*/ { BARCODE_EAN14, -1, -1, "12340", "", 0, "(01)00000000123402", "" },
/* 59*/ { BARCODE_NVE18, -1, -1, "12345678901234567", "", 0, "(00)123456789012345675", "" },
/* 60*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "12345678901234567", "", 0, "(00)123456789012345675", "00123456789012345675" },
/* 61*/ { BARCODE_NVE18, -1, -1, "1234", "", 0, "(00)000000000000012348", "" },
/* 62*/ { BARCODE_NVE18, -1, BARCODE_RAW_TEXT, "1234", "", 0, "(00)000000000000012348", "00000000000000012348" },
/* 63*/ { BARCODE_NVE18, -1, -1, "12345", "", 0, "(00)000000000000123457", "" },
/* 64*/ { BARCODE_NVE18, -1, -1, "12340", "", 0, "(00)000000000000123402", "" },
/* 65*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "" }, /* Incorrect check digit */
/* 66*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "(01)12345678901234(20)12", "" },
/* 67*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234(20)12", "01123456789012342012" },
/* 68*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "" },
/* 69*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12", "", 0, "(01)12345678901231(20)12", "01123456789012312012" },
/* 70*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "" }, /* AI (20) should be 2 nos. */
/* 71*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, -1, "[01]12345678901231[10]12[20]AB", "", 0, "(01)12345678901231(10)12(20)AB", "" },
/* 72*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]12[20]AB", "", ZINT_WARN_NONCOMPLIANT, "(01)12345678901231(10)12(20)AB", "01123456789012311012\03520AB" },
/* 73*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "" },
/* 74*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12", "", 0, "(01)12345678901231(10)AB(20)12", "011234567890123110AB\0352012" },
/* 75*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "" },
/* 76*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(2012", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(2012", "011234567890123110AB\035201290ABC(2012" },
/* 77*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "" },
/* 78*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC20)12", "011234567890123110AB\035201290ABC20)12" },
/* 79*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "" },
/* 80*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12", "011234567890123110AB\035201290ABC(20)12" },
/* 81*/ { BARCODE_DBAR_EXP, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , ""},
/* 82*/ { BARCODE_DBAR_EXP, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC(20)12[91]12(", "", 0, "(01)12345678901231(10)AB(20)12(90)ABC(20)12(91)12(" , "011234567890123110AB\035201290ABC(20)12\0359112(" },
/* 83*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "" },
/* 84*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234", "[21]12345", 0, "(01)12345678901234", "" },
/* 85*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234", "[21]12345", ZINT_WARN_NONCOMPLIANT, "(01)12345678901234", "0112345678901234|2112345" },
/* 86*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231", "[21]12345", 0, "(01)12345678901231", "" },
/* 87*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "" },
/* 88*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[20]12[21]12345", "[21]12345", 0, "(01)12345678901231(20)12(21)12345", "011234567890123120122112345|2112345" },
/* 89*/ { BARCODE_DBAR_EXP_CC, -1, -1, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "" },
/* 90*/ { BARCODE_DBAR_EXP_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10](", "[21]123()", 0, "(01)12345678901231(10)(", "011234567890123110(|21123()" },
/* 91*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, -1, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "" }, /* Escaped parens now work without ESCAPE_MODE & now kept in HRT */
/* 92*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "" },
/* 93*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "011234567890123110(|21123()" },
/* 94*/ { BARCODE_DBAR_EXP_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)\\(", "(21)123\\(\\)", 0, "(01)12345678901231(10)\\(", "011234567890123110(|21123()" },
/* 95*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "" },
/* 96*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "", 0, "", "" },
/* 97*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012" },
/* 98*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[20]12", "", 0, "", "" },
/* 99*/ { BARCODE_DBAR_EXPSTK, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "" },
/*100*/ { BARCODE_DBAR_EXPSTK, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/*101*/ { BARCODE_DBAR_EXPSTK, GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "" },
/*102*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "" },
/*103*/ { BARCODE_DBAR_EXPSTK, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/*104*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "", 0, "", "011234567890123110AB\035201290ABC20)12" },
/*105*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "" , ""},
/*106*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, -1, "[01]12345678901234[20]12", "[21]12345", 0, "", "" },
/*107*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901234[20]12", "[21]12345", ZINT_WARN_NONCOMPLIANT, "", "01123456789012342012|2112345" },
/*108*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[20]12", "[21]12345", 0, "", "" },
/*109*/ { BARCODE_DBAR_EXPSTK_CC, -1, -1, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "" },
/*110*/ { BARCODE_DBAR_EXPSTK_CC, -1, BARCODE_RAW_TEXT, "[01]12345678901231[10]AB[20]12[90]ABC20)12", "[21]12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/*111*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*112*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*113*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, -1, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "" },
/*114*/ { BARCODE_DBAR_EXPSTK_CC, ESCAPE_MODE | GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
/*115*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, BARCODE_RAW_TEXT, "(01)12345678901231(10)AB(20)12(90)ABC20\\)12", "(21)12345", 0, "", "011234567890123110AB\035201290ABC20)12|2112345" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -497,7 +508,7 @@ static void test_hrt(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, TCU(text), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, data[i].ret, ret, symbol->errtxt);
i, ret, data[i].ret, symbol->errtxt);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
@@ -1584,7 +1595,7 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), &length, ZUCP(reduced), &reduced_length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
if (p_ctx->generate) {
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
@@ -2294,7 +2305,7 @@ static void test_gs1_lint(const testCtx *const p_ctx) {
length = (int) strlen(data[i].data);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), &length, ZUCP(reduced), &reduced_length);
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n",
i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
@@ -2595,122 +2606,124 @@ static void test_gs1nocheck_mode(const testCtx *const p_ctx) {
/* 63*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]123", 0, "" },
/* 64*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]1A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (20) position 2: Non-numeric character 'A' (2D component)" },
/* 65*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[20]1A", 0, "" },
/* 66*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/* 67*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/* 68*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 69*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 70*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/* 71*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/* 72*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/* 73*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/* 74*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/* 75*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]", 0, "" }, /* Zero-length data not checked */
/* 76*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 77*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 78*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 79*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/* 80*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" },
/* 81*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 82*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 83*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 84*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 85*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 86*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/* 87*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 88*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/* 89*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite data */
/* 90*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" },
/* 91*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/* 92*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 93*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/* 94*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 95*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/* 96*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/* 97*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/* 98*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/* 99*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*100*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*101*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*102*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*103*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*104*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*105*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[10]", "", 0, "" }, /* Zero-length data not checked */
/*106*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*107*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI still checked */
/*108*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*109*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]1", "", 0, "" }, /* Length 0 AI with data not checked */
/*110*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*111*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*112*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" },
/*113*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*114*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*115*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXP */
/*116*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*117*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*118*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*119*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*120*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*121*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*122*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*123*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*124*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*125*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*126*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*127*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*128*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*129*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*130*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*131*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*132*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*133*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[10]", 0, "" }, /* Zero-length data not checked */
/*134*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*135*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/*136*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*137*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/*138*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*139*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*140*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/*141*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*142*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*143*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
/*144*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" },
/*145*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/*146*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*147*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/*148*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*149*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/*150*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/*151*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/*152*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/*153*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*154*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*155*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*156*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*157*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*158*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*159*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]", "", 0, "" }, /* Zero-length data not checked */
/*160*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*161*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXPSTK */
/*162*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*163*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*164*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*165*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*166*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*167*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*168*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*169*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*170*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*171*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*172*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*173*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*174*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*175*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*176*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*177*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*178*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*179*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[235]", 0, "" }, /* Zero-length data not checked */
/*180*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*181*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
/* 66*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" },
/* 67*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (linear component)" }, /* Nonprintable ASCII still checked */
/* 68*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/* 69*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/* 70*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 71*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121\200", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (linear component)" },
/* 72*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/* 73*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/* 74*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/* 75*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/* 76*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/* 77*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]", 0, "" }, /* Zero-length data not checked */
/* 78*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 79*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 80*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 81*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/* 82*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" },
/* 83*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[1]2[]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 5 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/* 84*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 85*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 86*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/* 87*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[][20]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 88*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/* 89*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/* 90*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/* 91*/ { BARCODE_GS1_128_CC, GS1NOCHECK_MODE, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite data */
/* 92*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" },
/* 93*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/* 94*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 95*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/* 96*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/* 97*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/* 98*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/* 99*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/*100*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/*101*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*102*/ { BARCODE_DBAR_EXP, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*103*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*104*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*105*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*106*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*107*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[10]", "", 0, "" }, /* Zero-length data not checked */
/*108*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*109*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 1 AI still checked */
/*110*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*111*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]1", "", 0, "" }, /* Length 0 AI with data not checked */
/*112*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" },
/*113*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*114*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" },
/*115*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short)" }, /* Length 0 AI with no data still checked */
/*116*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*117*/ { BARCODE_DBAR_EXP, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXP */
/*118*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*119*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*120*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*121*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*122*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*123*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*124*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*125*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*126*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*127*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*128*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*129*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*130*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*131*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*132*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*133*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*134*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*135*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[10]", 0, "" }, /* Zero-length data not checked */
/*136*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*137*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 1 AI still checked */
/*138*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]12", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*139*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]12", 0, "" }, /* Length 0 AI with data not checked */
/*140*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" },
/*141*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[]", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 1 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*142*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" },
/*143*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]12[][10]123", ZINT_ERROR_INVALID_DATA, "Error 256: Invalid AI at position 7 in input (AI too short) (2D component)" }, /* Length 0 AI with no data still checked */
/*144*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*145*/ { BARCODE_DBAR_EXP_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
/*146*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" },
/*147*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231", "", 0, "" },
/*148*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*149*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "", 0, "" },
/*150*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234A", "", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11)" },
/*151*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234A", "", 0, "" },
/*152*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 6: Non-numeric character 'A'" },
/*153*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]12345A", "", 0, "" },
/*154*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" },
/*155*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1" }, /* Nonprintable ASCII still checked */
/*156*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" },
/*157*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1" }, /* Extended ASCII still checked */
/*158*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" },
/*159*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI" }, /* Format still checked */
/*160*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input" },
/*161*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[01]", "", 0, "" }, /* Zero-length data not checked */
/*162*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" },
/*163*/ { BARCODE_DBAR_EXPSTK, GS1NOCHECK_MODE, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 386: Invalid character in General Field data" }, /* Non-CSET 82 always checked for DBAR_EXPSTK */
/*164*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*165*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/*166*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (11) (linear component)" },
/*167*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", 0, "" },
/*168*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (11) position 3: Invalid month '34' (linear component)" },
/*169*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", 0, "" },
/*170*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 259: Invalid data length for AI (30) (2D component)" },
/*171*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", 0, "" },
/*172*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (30) position 8: Non-numeric character 'A' (2D component)" },
/*173*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]123456789012[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", 0, "" },
/*174*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" },
/*175*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 263: DEL characters are not supported by GS1 (2D component)" }, /* Nonprintable ASCII still checked */
/*176*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" },
/*177*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 250: Extended ASCII characters are not supported by GS1 (2D component)" }, /* Extended ASCII still checked */
/*178*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" },
/*179*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 252: Data does not start with an AI (2D component)" }, /* Format still checked */
/*180*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 258: Empty data field in input (2D component)" },
/*181*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[235]", 0, "" }, /* Zero-length data not checked */
/*182*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" },
/*183*/ { BARCODE_DBAR_EXPSTK_CC, GS1NOCHECK_MODE, "[01]1234567890121", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 441: Invalid character in input (2D component)" }, /* Non-CSET 82 always checked for composite */
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
+971
View File
@@ -0,0 +1,971 @@
/*
libzint - the open source barcode library
Copyright (C) 2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include "testcommon.h"
#include "../gs1.h"
/*
* Check that GS1_128-based and DBAR_EXP-based symbologies reduce GS1 data
*/
static void test_gs1_reduce(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
const char *data;
const char *composite;
int ret;
const char *comment;
const char *expected;
};
static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128, -1, "12345678901234", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "", 0, "Input mode ignored; verified manually against TEC-IT",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 2*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(01)12345678901231", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 3*/ { BARCODE_GS1_128, GS1_MODE, "[01]12345678901231[21]()", "", 0, "Parentheses in AI data",
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011011100100101111011101000110010011001001000110111000101100011101011"
},
/* 4*/ { BARCODE_GS1_128, ESCAPE_MODE | GS1PARENS_MODE, "(01)12345678901231(21)\\(\\)", "", 0, "Parentheses in AI data",
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011011100100101111011101000110010011001001000110111000101100011101011"
},
/* 5*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 6*/ { BARCODE_GS1_128_CC, GS1PARENS_MODE, "(01)12345678901231", "(21)1234", 0, "Input mode ignored (parentheses instead of square brackets)",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 7*/ { BARCODE_GS1_128_CC, GS1_MODE, "[01]12345678901231[10])", "[21](", 0, "Parentheses in AI data",
"0000000000000000000000000000000000000000000110110111010100001000001000110000110001010001001110100111010100011100001110001100101100011011000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110110011100000101110110110000010011100101001100100100011110010111101101011100010000011001000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110100010001000100011110111100101111001001001100110111111010011010001111100100011101011101000101000000000000000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100110111011010000100010011011011101000100001011101000010011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011001000100101111011101100100100010111011110100010111101100011101011"
},
/* 8*/ { BARCODE_GS1_128_CC, ESCAPE_MODE | GS1PARENS_MODE, "(01)12345678901231(10)\\)", "(21)\\(", 0, "Parentheses in AI data",
"0000000000000000000000000000000000000000000110110111010100001000001000110000110001010001001110100111010100011100001110001100101100011011000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110110011100000101110110110000010011100101001100100100011110010111101101011100010000011001000101000000000000000000000000000000000000"
"0000000000000000000000000000000000000000000110110100010001000100011110111100101111001001001100110111111010011010001111100100011101011101000101000000000000000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100110111011010000100010011011011101000100001011101000010011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011001000100101111011101100100100010111011110100010111101100011101011"
},
/* 9*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against TEC-IT",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/*10*/ { BARCODE_EAN14, GS1PARENS_MODE, "1234567890123", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/*11*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "Input mode ignored; verified manually against TEC-IT",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*12*/ { BARCODE_NVE18, GS1PARENS_MODE, "12345678901234567", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*13*/ { BARCODE_DBAR_EXP, -1, "2012", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*14*/ { BARCODE_DBAR_EXP, -1, "[20]12[01]12345678901231", "", 0, "Input mode ignored",
"01001100000110011010111111110000101000001000011001010111110010001110101111110000111010001001111101110111111001110010100011111100001011110011101000010110111000011010001011111111001110000110111101011101"
},
/*15*/ { BARCODE_DBAR_EXP, GS1PARENS_MODE, "(20)12(01)12345678901231", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"01001100000110011010111111110000101000001000011001010111110010001110101111110000111010001001111101110111111001110010100011111100001011110011101000010110111000011010001011111111001110000110111101011101"
},
/*16*/ { BARCODE_DBAR_EXP, UNICODE_MODE, "[20]12[01]12345678901231", "", 0, "Input mode ignored",
"01001100000110011010111111110000101000001000011001010111110010001110101111110000111010001001111101110111111001110010100011111100001011110011101000010110111000011010001011111111001110000110111101011101"
},
/*17*/ { BARCODE_DBAR_EXP, -1, "[21])[8006]123456789012310102", "", 0, "Parentheses in AI data",
"01011100110010001110111111110000101010100000001100010011011111101110101111100000011011011001110000010101100000010000100011111100001010001011100000110100011001011110001011111111001110000100101110000100001110001001101000110000000010100000001100101001110101111011000010111111111001101"
},
/*18*/ { BARCODE_DBAR_EXP, ESCAPE_MODE | GS1PARENS_MODE, "(21)\\)(8006)123456789012310102", "", 0, "Parentheses in AI data",
"01011100110010001110111111110000101010100000001100010011011111101110101111100000011011011001110000010101100000010000100011111100001010001011100000110100011001011110001011111111001110000100101110000100001110001001101000110000000010100000001100101001110101111011000010111111111001101"
},
/*19*/ { BARCODE_DBAR_EXP_CC, -1, "[20]12", "[21]1234[8006]123456789012310102", 0, "",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*20*/ { BARCODE_DBAR_EXP_CC, UNICODE_MODE, "[20]12", "[21]1234[8006]123456789012310102", 0, "Input mode ignored",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*21*/ { BARCODE_DBAR_EXP_CC, -1, "[10]()[8006]123456789012310202", "[21]()", 0, "Parentheses in AI data",
"00110110111010100001000001000110000110001010001001110100111010111001111101100111011001000011011000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110110010001000111110110111101100001101001001100100111110111101110101111101000110111011001000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110100010111110110100000100001111011011001001100110100111001100111001000001001001111011101000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000110111001100001000000001010010101110011000001101100100000010001010000010101000100011011110001101110101110111000010100000010100101111101110010111000100010111101110100000000100001100000110011010010001100011000100111001111111101010001101110011110001111011100100101000000000110000"
"01011001000110011110111111110000101010001100111110010011011111101110101111100000011011100100001110010001010001000111100011111100001010000010001101000111011101000010001011111111001110011111001100101101110011100111011000110000000010101110010001100001110000100011011010111111111001101"
},
/*22*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, "(10)\\(\\)(8006)123456789012310202", "(21)\\(\\)", 0, "Parentheses in AI data",
"00110110111010100001000001000110000110001010001001110100111010111001111101100111011001000011011000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110110010001000111110110111101100001101001001100100111110111101110101111101000110111011001000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00110110100010111110110100000100001111011011001001100110100111001100111001000001001001111011101000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000110111001100001000000001010010101110011000001101100100000010001010000010101000100011011110001101110101110111000010100000010100101111101110010111000100010111101110100000000100001100000110011010010001100011000100111001111111101010001101110011110001111011100100101000000000110000"
"01011001000110011110111111110000101010001100111110010011011111101110101111100000011011100100001110010001010001000111100011111100001010000010001101000111011101000010001011111111001110011111001100101101110011100111011000110000000010101110010001100001110000100011011010111111111001101"
},
/*23*/ { BARCODE_DBAR_EXPSTK, -1, "12", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*24*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[20]12", "", 0, "Input mode ignored",
"010011010011100000101111111100001011000011101110010111000110110001001011111100001110001111000010101101"
"000000101100011111010000000010100100111100010001101000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000100000000101110010000110100011000111110110010100101000000101001000001111010000000000000000000000"
"101110011111111010001101111001011100111000001001101010000111111000110111110000101001000000000000000000"
},
/*25*/ { BARCODE_DBAR_EXPSTK, UNICODE_MODE, "[01]12345678901231[20]12", "", 0, "Input mode ignored",
"010011010011100000101111111100001011000011101110010111000110110001001011111100001110001111000010101101"
"000000101100011111010000000010100100111100010001101000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000100000000101110010000110100011000111110110010100101000000101001000001111010000000000000000000000"
"101110011111111010001101111001011100111000001001101010000111111000110111110000101001000000000000000000"
},
/*26*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[21](21)", "", 0, "Parentheses in AI data",
"010000100011011001101111111100001010010000111011000111000110110001001011111000000110001111000010101101"
"000011011100100110010000000010100101101111000100111000111001001110110100000101010001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"101100111100011101011100111111110100110111001001111000101100100001110100001111110001101111100001010010"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000010010011100000010100001010100101011111000010100000000000000000000000000000000000000000000000000000"
"010101101100011111100011110000001010100000111101000100000000000000000000000000000000000000000000000000"
},
/*27*/ { BARCODE_DBAR_EXPSTK, ESCAPE_MODE | GS1PARENS_MODE, "(01)12345678901231(21)\\(21\\)", "", 0, "Parentheses in AI data",
"010000100011011001101111111100001010010000111011000111000110110001001011111000000110001111000010101101"
"000011011100100110010000000010100101101111000100111000111001001110110100000101010001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"101100111100011101011100111111110100110111001001111000101100100001110100001111110001101111100001010010"
"000011000011100010100001000000001011001000110110000111010011011110001001010000001010010000011110100000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000010010011100000010100001010100101011111000010100000000000000000000000000000000000000000000000000000"
"010101101100011111100011110000001010100000111101000100000000000000000000000000000000000000000000000000"
},
/*28*/ { BARCODE_DBAR_EXPSTK_CC, -1, "12", "[21]1234", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*29*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[20]12", "[21]1234[8006]123456789012310102", 0, "Input mode ignored; (same as BARCODE_DBAR_EXP_CC above)",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*30*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(20)12", "(21)1234(8006)123456789012310102", 0, "Input mode ignored (parentheses instead of square brackets)",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*31*/ { BARCODE_DBAR_EXPSTK_CC, UNICODE_MODE, "[20]12", "[21]1234[8006]123456789012310102", 0, "Input mode ignored",
"001101001000110100001000001101001100111011000010010001101100001000001011011110111000101100111011001010"
"001101011000111110110100001001000111011111101010010000101101100001111001010100001111000100110011001010"
"001101011100100110011001111001001000001001111010110000101011011000011110010100110001111100110111001010"
"001101011110111100111001001101101001000011000010111000101111011100001011011010011101111000110111101010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*32*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]1)", "[21]12)(", 0, "Parentheses in AI data",
"001101101110110100001000001101110111011100111010011101001000010010000001010010001000010000110110001010"
"001101101100111101000010001001110000110111010010011001001101100011110001011010111000100000110010001010"
"001101101000111001111101011001011100100000011010011001101001111001000001010000011110010100111010001010"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"010011000110000110101111111100001011110011001110110111000110110001001011111100001110001111000010101101"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000011001001111100001000000001010000110111100110101111011011100001001010000001010010000011110100000"
"101011100110110000011100111111110101111001000011001010000100100011110100001111110001101111100001010010"
},
/*33*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(01)12345678901231(10)1\\)", "(21)12\\)\\(", 0, "Parentheses in AI data",
"001101101110110100001000001101110111011100111010011101001000010010000001010010001000010000110110001010"
"001101101100111101000010001001110000110111010010011001001101100011110001011010111000100000110010001010"
"001101101000111001111101011001011100100000011010011001101001111001000001010000011110010100111010001010"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"010011000110000110101111111100001011110011001110110111000110110001001011111100001110001111000010101101"
"000000111001111001010000000010100100001100110001001000111001001110110100000010100001110000111101010000"
"000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010000"
"000000011001001111100001000000001010000110111100110101111011011100001001010000001010010000011110100000"
"101011100110110000011100111111110101111001000011001010000100100011110100001111110001101111100001010010"
},
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
const char *text;
char escaped[1024];
char escaped2[1024];
char bwipp_buf[8196];
char bwipp_msg[1024];
/* Only do BWIPP test if asked, too slow otherwise */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript();
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
if (data[i].composite[0]) {
text = data[i].composite;
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
text, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = ZBarcode_Encode(symbol, TCU(text), length);
if (p_ctx->generate) {
const int data_len = (int) strlen(data[i].data);
const int composite_len = (int) strlen(data[i].composite);
if (data[i].ret == 0) {
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %d, \"%s\",\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, data_len, escaped, sizeof(escaped)),
testUtilEscape(data[i].composite, composite_len, escaped2, sizeof(escaped2)),
data[i].ret, data[i].comment);
testUtilModulesPrint(symbol, " ", "\n");
printf(" },\n");
} else {
printf(" /*%2d*/ { %s, %s, \"%s\", \"%s\", %s, \"%s\", \"\" },\n",
i, testUtilBarcodeName(data[i].symbology), testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, data_len, escaped, sizeof(escaped)),
testUtilEscape(data[i].composite, composite_len, escaped2, sizeof(escaped2)),
testUtilErrorName(data[i].ret), 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);
if (ret < ZINT_ERROR) {
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d %s testUtilModulesCmp ret %d != 0 width %d row %d (%s)\n",
i, testUtilBarcodeName(data[i].symbology), ret, width, row, data[i].data);
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
ret = testUtilBwipp(i, symbol, -1, -1, -1, text, length, symbol->primary, bwipp_buf,
sizeof(bwipp_buf), NULL);
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n",
i, testUtilBarcodeName(symbol->symbology), ret);
ret = testUtilBwippCmp(symbol, bwipp_msg, bwipp_buf, data[i].expected);
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
i, testUtilBarcodeName(symbol->symbology), ret, bwipp_msg, bwipp_buf,
data[i].expected);
}
}
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_hrt(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
int output_options;
const char *data;
const char *composite;
int ret;
const char *expected;
const char *expected_raw;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_EAN8_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" },
/* 1*/ { BARCODE_EANX_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" }, /* EAN-8 */
/* 2*/ { BARCODE_EAN8_CC, -1, BARCODE_RAW_TEXT, "1234567", "[20]12", 0, "12345670", "12345670|2012" },
/* 3*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567", "[20]12", 0, "12345670", "12345670|2012" },
/* 4*/ { BARCODE_EAN13_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128", "" },
/* 5*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[20]12", 0, "1234567890128", "" }, /* EAN-13 */
/* 6*/ { BARCODE_EAN13_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[20]12", 0, "1234567890128", "1234567890128|2012" },
/* 7*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[20]12", 0, "1234567890128", "1234567890128|2012" }, /* EAN-13 */
/* 8*/ { BARCODE_EAN13_CC, -1, -1, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "" },
/* 9*/ { BARCODE_EANX_CC, -1, -1, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "" }, /* EAN-13 */
/* 10*/ { BARCODE_EAN13_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "1234567890128|10LOT123\0352012" },
/* 11*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "123456789012", "[10]LOT123[20]12", 0, "1234567890128", "1234567890128|10LOT123\0352012" }, /* EAN-13 */
/* 12*/ { BARCODE_EAN13_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128", "" },
/* 13*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]12", 0, "1234567890128", "" },
/* 14*/ { BARCODE_EAN13_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 15*/ { BARCODE_EANX_CC, -1, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 16*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 17*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890123", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 18*/ { BARCODE_EAN13_CC, -1, -1, "1234567890128", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 19*/ { BARCODE_EANX_CC, -1, -1, "1234567890128", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 20*/ { BARCODE_EAN13_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128", "" },
/* 21*/ { BARCODE_EANX_CC, GS1NOCHECK_MODE, -1, "1234567890128", "[20]1A", 0, "1234567890128", "" },
/* 22*/ { BARCODE_EAN13_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12", "" },
/* 23*/ { BARCODE_EANX_CC, -1, -1, "1234567890128+12", "[20]12", 0, "1234567890128+12", "" },
/* 24*/ { BARCODE_EAN13_CC, -1, BARCODE_RAW_TEXT, "1234567890128+12", "[20]12", 0, "1234567890128+12", "123456789012812|2012" },
/* 25*/ { BARCODE_EANX_CC, -1, BARCODE_RAW_TEXT, "1234567890128+12", "[20]12", 0, "1234567890128+12", "123456789012812|2012" },
/* 26*/ { BARCODE_DBAR_OMN_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231", "" },
/* 27*/ { BARCODE_DBAR_OMN_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "(01)12345678901231", "0112345678901231|2012" },
/* 28*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231", "" },
/* 29*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 30*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 31*/ { BARCODE_DBAR_OMN_CC, -1, -1, "12345678901231", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 32*/ { BARCODE_DBAR_OMN_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231", "" },
/* 33*/ { BARCODE_DBAR_LTD_CC, -1, -1, "1234567890123", "[20]12", 0, "(01)12345678901231", "" },
/* 34*/ { BARCODE_DBAR_LTD_CC, -1, BARCODE_RAW_TEXT, "1234567890123", "[20]12", 0, "(01)12345678901231", "0112345678901231|2012" },
/* 35*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]12", 0, "(01)12345678901231", "" },
/* 36*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 37*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901232", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 38*/ { BARCODE_DBAR_LTD_CC, -1, -1, "12345678901231", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 39*/ { BARCODE_DBAR_LTD_CC, GS1NOCHECK_MODE, -1, "12345678901231", "[20]1A", 0, "(01)12345678901231", "" },
/* 40*/ { BARCODE_UPCA_CC, -1, -1, "12345678901", "[20]12", 0, "123456789012", "" },
/* 41*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "12345678901", "[20]12", 0, "123456789012", "0123456789012|2012" },
/* 42*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]12", 0, "123456789012", "" },
/* 43*/ { BARCODE_UPCA_CC, -1, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 44*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789013", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 45*/ { BARCODE_UPCA_CC, -1, -1, "123456789012", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 46*/ { BARCODE_UPCA_CC, GS1NOCHECK_MODE, -1, "123456789012", "[20]1A", 0, "123456789012", "" },
/* 47*/ { BARCODE_UPCA_CC, -1, -1, "123456789012+123", "[20]12", 0, "123456789012+00123", "" },
/* 48*/ { BARCODE_UPCA_CC, -1, BARCODE_RAW_TEXT, "123456789012+123", "[20]12", 0, "123456789012+00123", "012345678901200123|2012" },
/* 49*/ { BARCODE_UPCE_CC, -1, -1, "123456", "[20]12", 0, "01234565", "" },
/* 50*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "123456", "[20]12", 0, "01234565", "0012345000065|2012" },
/* 51*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]12", 0, "12345670", "" },
/* 52*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670", "" },
/* 53*/ { BARCODE_UPCE_CC, -1, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" },
/* 54*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "12345671", "[20]12", ZINT_ERROR_INVALID_CHECK, "", "" }, /* Still checked */
/* 55*/ { BARCODE_UPCE_CC, -1, -1, "12345670", "[20]12", 0, "12345670", "" }, /* Check digit can now be given for UPCE_CC, like UPCA_CC */
/* 56*/ { BARCODE_UPCE_CC, -1, -1, "1234567", "[20]1A", ZINT_ERROR_INVALID_DATA, "", "" }, /* AI (20) should be 2 nos. */
/* 57*/ { BARCODE_UPCE_CC, GS1NOCHECK_MODE, -1, "1234567", "[20]1A", 0, "12345670", "" },
/* 58*/ { BARCODE_UPCE_CC, -1, BARCODE_RAW_TEXT, "1234567+2", "[20]12", 0, "12345670+02", "012345600007002|2012" },
/* 59*/ { BARCODE_DBAR_STK_CC, -1, -1, "12345678901231", "[20]12", 0, "", "" }, /* No HRT for stacked symbologies */
/* 60*/ { BARCODE_DBAR_STK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "", "0112345678901231|2012" }, /* But have RAW_TEXT */
/* 61*/ { BARCODE_DBAR_OMNSTK_CC, -1, -1, "12345678901231", "[20]12", 0, "", "" },
/* 62*/ { BARCODE_DBAR_OMNSTK_CC, -1, BARCODE_RAW_TEXT, "12345678901231", "[20]12", 0, "", "0112345678901231|2012" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
int expected_length, expected_raw_length;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug);
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
strcpy(symbol->primary, data[i].data);
expected_length = (int) strlen(data[i].expected);
expected_raw_length = (int) strlen(data[i].expected_raw);
composite_length = (int) strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, TCU(data[i].composite), composite_length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, data[i].ret, ret, symbol->errtxt);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->text, data[i].expected);
if (symbol->output_options & BARCODE_RAW_TEXT) {
assert_nonnull(symbol->raw_segs, "i:%d raw_segs NULL\n", i);
assert_nonnull(symbol->raw_segs[0].source, "i:%d raw_segs[0].source NULL\n", i);
assert_equal(symbol->raw_segs[0].length, expected_raw_length,
"i:%d raw_segs[0].length %d != expected_raw_length %d\n",
i, symbol->raw_segs[0].length, expected_raw_length);
assert_zero(memcmp(symbol->raw_segs[0].source, data[i].expected_raw, expected_raw_length),
"i:%d memcmp(%.*s, %s, %d) != 0\n",
i, symbol->raw_segs[0].length, symbol->raw_segs[0].source, data[i].expected_raw,
expected_raw_length);
} else {
assert_null(symbol->raw_segs, "i:%d raw_segs not NULL\n", i);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_gs1_verify(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
const char *data;
int ret;
const char *expected;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { -1, "", ZINT_ERROR_INVALID_DATA, "", "264: Data does not start with an AI" },
/* 1*/ { -1, "A", ZINT_ERROR_INVALID_DATA, "", "264: Data does not start with an AI" },
/* 2*/ { -1, "[", ZINT_ERROR_INVALID_DATA, "", "268: Failed to parse AI data" },
/* 3*/ { -1, "[]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: " },
/* 4*/ { -1, "[1]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 1" },
/* 5*/ { -1, "[242]123456[1]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 1" },
/* 6*/ { -1, "[12345]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 12345" },
/* 7*/ { -1, "[9999]1234", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 9999" },
/* 8*/ { -1, "[[01]]1234", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: (01" },
/* 9*/ { GS1PARENS_MODE, "((01))1234", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: (01" },
/* 10*/ { -1, "[1A]12", ZINT_ERROR_INVALID_DATA, "", "268: Unrecognised AI: 1A" },
/* 11*/ { -1, "[10]", ZINT_ERROR_INVALID_DATA, "", "268: Failed to parse AI data" },
/* 12*/ { -1, "[90]\012", ZINT_ERROR_INVALID_DATA, "", "267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)|\\x0A|" },
/* 13*/ { -1, "[00]123456789012345678", ZINT_ERROR_INVALID_DATA, "", "267: AI (00): The numeric check digit is incorrect. (00)12345678901234567|8|" },
/* 14*/ { -1, "[00]123456789012345675", 0, "00123456789012345675", "" },
/* 15*/ { GS1PARENS_MODE, "(00)123456789012345675", 0, "00123456789012345675", "" },
/* 16*/ { -1, "[00]12345678901234567", ZINT_ERROR_INVALID_DATA, "", "268: AI (00) value is too short" },
/* 17*/ { -1, "[00]1234567890123456789", ZINT_ERROR_INVALID_DATA, "", "268: AI (00) value is too long" },
/* 18*/ { -1, "[3910]123123456789012345", ZINT_ERROR_INVALID_DATA, "", "267: AI (3910): A valid ISO 4217 three-digit currency code is required. (3910)|123|" },
/* 19*/ { -1, "[3910]997123456789012345", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (3910) are not satisfied: 8020" },
/* 20*/ { -1, "[3910]997123456789012345[8020]REF123", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8020) are not satisfied: 415" },
/* 21*/ { -1, "[3910]997123456789012345[8020]REF123[415]1234567890123", ZINT_ERROR_INVALID_DATA, "", "267: AI (415): The numeric check digit is incorrect. (415)123456789012|3|" },
/* 22*/ { -1, "[3910]997123456789012345[8020]REF123[415]1234567890128", 0, "3910997123456789012345\0358020REF123\0354151234567890128", "" },
/* 23*/ { GS1PARENS_MODE, "(3910)997123456789012345(8020)REF123(415)1234567890128", 0, "3910997123456789012345\0358020REF123\0354151234567890128", "" },
/* 24*/ { -1, "[402]13131313131313132", ZINT_ERROR_INVALID_DATA, "", "267: AI (402): The numeric check digit is incorrect. (402)1313131313131313|2|" },
/* 25*/ { -1, "[402]13131313131313130", 0, "40213131313131313130", "" },
/* 26*/ { -1, "[4309]1234567890123456789A", ZINT_ERROR_INVALID_DATA, "", "267: AI (4309): A non-digit character was found where a digit is expected. (4309)1234567890123456789|A|" },
/* 27*/ { -1, "[7006]200132", ZINT_ERROR_INVALID_DATA, "", "267: AI (7006): The date contains an illegal day of the month. (7006)2001|32|" },
/* 28*/ { -1, "[7006]200131", ZINT_ERROR_INVALID_DATA, "7006200131", "268: Required AIs for AI (7006) are not satisfied: 01,02" },
/* 29*/ { -1, "[7006]200131[01]12345678901231", 0, "7006200131\0350112345678901231", "" },
/* 30*/ { -1, "[8001]12345678901234", ZINT_ERROR_INVALID_DATA, "", "267: AI (8001): The winding direction must be either \"0\", \"1\" or \"9\". (8001)123456789012|3|" },
/* 31*/ { -1, "[8001]12345678901294", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8001) are not satisfied: 01" },
/* 32*/ { -1, "[8001]12345678901294[01]12345678901231", 0, "800112345678901294\0350112345678901231", "" },
/* 33*/ { -1, "[8004]abcdefghijklmnopqrstuvwxyz1234", ZINT_ERROR_INVALID_DATA, "", "267: AI (8004): The GS1 Company Prefix is invalid. (8004)|a|bcdefghijklmnopqrstuvwxyz1234" },
/* 34*/ { -1, "[8004]123", ZINT_ERROR_INVALID_DATA, "", "267: AI (8004): The component is shorter than the minimum length GS1 Company Prefix. (8004)|123|" },
/* 35*/ { -1, "[8004]1234efghijklmnopqrstuvwxyz1234", 0, "80041234efghijklmnopqrstuvwxyz1234", "" },
/* 36*/ { -1, "[8007]abcdefghijklmnopqrstuvwxyz12345678", ZINT_ERROR_INVALID_DATA, "", "267: AI (8007): The IBAN must start with a valid ISO 3166 two-character country code. (8007)|ab|cdefghijklmnopqrstuvwxyz12345678" },
/* 37*/ { -1, "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8007) are not satisfied: 415" },
/* 38*/ { -1, "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678[415]1234567890128", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (415) are not satisfied: 8020" },
/* 39*/ { -1, "[8007]AD95EFGHIJKLMNOPQRSTUVWXYZ12345678[415]1234567890128[8020]REF123", 0, "8007AD95EFGHIJKLMNOPQRSTUVWXYZ12345678\03541512345678901288020REF123", "" },
/* 40*/ { -1, "[8030]-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXY^", ZINT_ERROR_INVALID_DATA, "", "268: AI (8030) contains illegal ^ character" },
/* 41*/ { -1, "[8030]-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8030) are not satisfied: 00,01+21,253,255,8003,8004,8006+21,8010+8011,8017,8018" },
/* 42*/ { -1, "[8030]-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ[8018]123456789012345675", 0, "8030-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ\0358018123456789012345675", "" },
/* 43*/ { -1, "[01]12345678901234[7006]200101", ZINT_ERROR_INVALID_DATA, "", "267: AI (01): The numeric check digit is incorrect. (01)1234567890123|4|" },
/* 44*/ { -1, "[01]12345678901231[7006]200101", 0, "01123456789012317006200101", "" },
/* 45*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (3901) are not satisfied: 255,8020" },
/* 46*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[255]1234567890128", ZINT_ERROR_INVALID_DATA, "", "268: It is invalid to pair AI (01) with AI (255)" },
/* 47*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[8020]REF123", ZINT_ERROR_INVALID_DATA, "", "268: Required AIs for AI (8020) are not satisfied: 415" },
/* 48*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[8020]REF123[415]1234567890128", 0, "25312345678901284\0350112345678901231390112345678901234\03520128020REF123\0354151234567890128", "" },
/* 49*/ { -1, "[253]12345678901284[01]12345678901231[3901]12345678901234[20]12[8020]REF123[415]1234567890128[90]123", 0, "25312345678901284\0350112345678901231390112345678901234\03520128020REF123\035415123456789012890123", "" },
/* 50*/ { -1, "[8001]12345678901294[01]12345678901231|[8012]VER1", 0, "800112345678901294\0350112345678901231|8012VER1", "" }, /* Composite */
/* 51*/ { -1, "[8001]12345678901294[01]12345678901231[415]1234567890128|[8020]ABCDEFGHIJKLMNOPQRSTUVXWY", 0, "800112345678901294\03501123456789012314151234567890128|8020ABCDEFGHIJKLMNOPQRSTUVXWY", "" },
/* 52*/ { -1, "[8001]12345678901294[01]12345678901231|[415]1234567890128[8020]ABCDEFGHIJKLMNOPQRSTUVXWY", 0, "800112345678901294\0350112345678901231|41512345678901288020ABCDEFGHIJKLMNOPQRSTUVXWY", "" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int reduced_length = 0; /* Suppress clang -fsanitize=memory false positive */
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[1024];
char escaped2[1024];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_GS1_128, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(ret),
data[i].expected, symbol->errtxt);
} else {
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n",
i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
if (ret < ZINT_ERROR) {
const int expected_length = (int) strlen(data[i].expected);
assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, testUtilEscape(reduced, (int) strlen(reduced), escaped, (int) sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, (int) sizeof(escaped2)));
assert_equal(reduced_length, (int) strlen(reduced), "i:%d reduced_length %d != strlen %d\n",
i, reduced_length, (int) strlen(reduced));
}
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
static void test_gs1_digital_link(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int input_mode;
const char *data;
int ret;
const char *expected;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 53*/ { -1, "https://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 54*/ { -1, "HTTPS://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 55*/ { -1, "http://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 56*/ { -1, "HTTP://", ZINT_ERROR_INVALID_DATA, "", "268: URI must contain a domain and path info" },
/* 57*/ { -1, "Https://", ZINT_ERROR_INVALID_DATA, "", "265: Data does not start with an AI or a Digital Link URI" },
/* 58*/ { -1, "http:/", ZINT_ERROR_INVALID_DATA, "", "265: Data does not start with an AI or a Digital Link URI" },
/* 59*/ { -1, "https://example.com/123", ZINT_ERROR_INVALID_DATA, "", "268: No GS1 DL keys found in path info" },
/* 60*/ { -1, "https://example.com/01/12345678901231", 0, "https://example.com/01/12345678901231", "" },
/* 61*/ { -1, "https://example.com/gtin/12345678901231", ZINT_ERROR_INVALID_DATA, "", "268: No GS1 DL keys found in path info" },
/* 62*/ { -1, "https://example.com/gtin/01/12345678901231", 0, "https://example.com/gtin/01/12345678901231", "" },
/* 63*/ { -1, "https://example.com/01/12345678901231/90/123", ZINT_ERROR_INVALID_DATA, "", "268: The AIs in the path are not a valid key-qualifier sequence for the key" },
/* 64*/ { -1, "https://example.com/01/12345678901231/10/123", 0, "https://example.com/01/12345678901231/10/123", "" },
/* 65*/ { -1, "https://example.com/01/12345678901231/10/12+3", 0, "https://example.com/01/12345678901231/10/12+3", "" },
/* 66*/ { -1, "https://example.com/01/12345678901231/10/12%2B3", 0, "https://example.com/01/12345678901231/10/12%2B3", "" },
/* 67*/ { -1, "http://example.com/01/09520123456788/22/2A?linkType=gs1:traceability", 0, "http://example.com/01/09520123456788/22/2A?linkType=gs1:traceability", "" },
/* 68*/ { -1, "https://example.com/01/12345678901231/10/12?3", 0, "https://example.com/01/12345678901231/10/12?3", "" },
/* 69*/ { -1, "https://example.com/01/12345678901231/10/12=3", 0, "https://example.com/01/12345678901231/10/12=3", "" },
/* 70*/ { -1, "https://example.com/01/12345678901231/10/1?2=3", ZINT_ERROR_INVALID_DATA, "", "268: Unknown AI (2) in query parameters" },
/* 71*/ { -1, "https://example.com/01/12345678901231/10/1%3F2=3", 0, "https://example.com/01/12345678901231/10/1%3F2=3", "" },
/* 72*/ { -1, "https://example.com/01/12345678901231?3103=000195", 0, "https://example.com/01/12345678901231?3103=000195", "" },
/* 73*/ { -1, "https://example.com/01/12345678901231|(20)12", ZINT_ERROR_INVALID_DATA, "", "268: URI contains illegal characters" },
/* 74*/ { -1, "https://example.com/01/12345678901231|", ZINT_ERROR_INVALID_DATA, "", "268: URI contains illegal characters" },
/* 75*/ { -1, "https://example.com/01/12345678901231(", ZINT_ERROR_INVALID_DATA, "", "268: AI (01) value is too long" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int reduced_length = 0; /* Suppress clang -fsanitize=memory false positive */
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[1024];
char escaped2[1024];
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, BARCODE_QRCODE, GS1_MODE | GS1SYNTAXENGINE_MODE, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
data[i].data, -1, debug);
if (data[i].input_mode != -1) {
symbol->input_mode |= data[i].input_mode;
}
ret = zint_gs1_verify(symbol, ZUCP(data[i].data), length, ZUCP(reduced), &reduced_length);
if (p_ctx->generate) {
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode),
testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(ret),
data[i].expected, symbol->errtxt);
} else {
assert_equal(ret, data[i].ret, "i:%d ret %d != %d (length %d \"%s\") (%s)\n",
i, ret, data[i].ret, length, data[i].data, symbol->errtxt);
if (ret < ZINT_ERROR) {
const int expected_length = (int) strlen(data[i].expected);
assert_zero(strcmp(reduced, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, testUtilEscape(reduced, (int) strlen(reduced), escaped, (int) sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, (int) sizeof(escaped2)));
assert_equal(reduced_length, (int) strlen(reduced), "i:%d reduced_length %d != strlen %d\n",
i, reduced_length, (int) strlen(reduced));
}
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
/* Check non-forced GS1 compliant symbologies (see gs1_compliant() in library.c) */
static void test_non_forced(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
const char *data;
int input_mode;
int output_options;
int ret;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_AZTEC, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 1*/ { BARCODE_AZTEC, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 2*/ { BARCODE_AZTEC, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 3*/ { BARCODE_AZTEC, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 4*/ { BARCODE_AZTEC, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 5*/ { BARCODE_AZTEC, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 6*/ { BARCODE_AZTEC, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 7*/ { BARCODE_AZTEC, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 8*/ { BARCODE_AZTEC, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 9*/ { BARCODE_AZTEC, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 10*/ { BARCODE_AZTEC, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 11*/ { BARCODE_AZTEC, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 12*/ { BARCODE_AZTEC, "[01]12345678901231", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION },
/* 13*/ { BARCODE_AZTEC, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 14*/ { BARCODE_AZTEC, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 15*/ { BARCODE_AZTEC, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 16*/ { BARCODE_AZTEC, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 17*/ { BARCODE_AZTEC, "1234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, ZINT_ERROR_INVALID_DATA }, /* Must still begin with AI */
/* 18*/ { BARCODE_CODABLOCKF, "[01]12345678901231", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION }, /* Codablock-F does not support GS1 */
/* 19*/ { BARCODE_CODABLOCKF, "[01]12345678901231", GS1_MODE | GS1NOCHECK_MODE, -1, ZINT_ERROR_INVALID_OPTION },
/* 20*/ { BARCODE_CODABLOCKF, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION },
/* 21*/ { BARCODE_CODEONE, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 22*/ { BARCODE_CODEONE, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 23*/ { BARCODE_CODEONE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 24*/ { BARCODE_CODEONE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 25*/ { BARCODE_CODEONE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 26*/ { BARCODE_CODEONE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 27*/ { BARCODE_CODEONE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 28*/ { BARCODE_CODEONE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 29*/ { BARCODE_CODEONE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 30*/ { BARCODE_CODEONE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 31*/ { BARCODE_CODEONE, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 32*/ { BARCODE_CODEONE, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 33*/ { BARCODE_CODEONE, "[10]()[01]12345678901231", GS1_MODE, -1, 0 },
/* 34*/ { BARCODE_CODEONE, "(10)()(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 35*/ { BARCODE_CODEONE, "(10)\\(\\)(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 36*/ { BARCODE_CODEONE, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 37*/ { BARCODE_CODE16K, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 38*/ { BARCODE_CODE16K, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 39*/ { BARCODE_CODE16K, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 40*/ { BARCODE_CODE16K, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 41*/ { BARCODE_CODE16K, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 42*/ { BARCODE_CODE16K, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 43*/ { BARCODE_CODE16K, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 44*/ { BARCODE_CODE16K, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 45*/ { BARCODE_CODE16K, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 46*/ { BARCODE_CODE16K, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 47*/ { BARCODE_CODE16K, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 48*/ { BARCODE_CODE16K, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 49*/ { BARCODE_CODE16K, "[01]12345678901231", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION },
/* 50*/ { BARCODE_CODE16K, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 51*/ { BARCODE_CODE16K, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 52*/ { BARCODE_CODE16K, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 53*/ { BARCODE_CODE16K, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 54*/ { BARCODE_CODE49, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 55*/ { BARCODE_CODE49, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 56*/ { BARCODE_CODE49, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 57*/ { BARCODE_CODE49, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 58*/ { BARCODE_CODE49, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 59*/ { BARCODE_CODE49, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 60*/ { BARCODE_CODE49, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 61*/ { BARCODE_CODE49, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 62*/ { BARCODE_CODE49, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 63*/ { BARCODE_CODE49, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 64*/ { BARCODE_CODE49, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 65*/ { BARCODE_CODE49, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 66*/ { BARCODE_CODE49, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 67*/ { BARCODE_CODE49, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 68*/ { BARCODE_CODE49, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 69*/ { BARCODE_CODE49, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 70*/ { BARCODE_DATAMATRIX, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 71*/ { BARCODE_DATAMATRIX, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 72*/ { BARCODE_DATAMATRIX, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 73*/ { BARCODE_DATAMATRIX, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 74*/ { BARCODE_DATAMATRIX, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 75*/ { BARCODE_DATAMATRIX, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 76*/ { BARCODE_DATAMATRIX, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 77*/ { BARCODE_DATAMATRIX, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 78*/ { BARCODE_DATAMATRIX, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 79*/ { BARCODE_DATAMATRIX, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 80*/ { BARCODE_DATAMATRIX, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 81*/ { BARCODE_DATAMATRIX, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 82*/ { BARCODE_DATAMATRIX, "[01]12345678901231", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION },
/* 83*/ { BARCODE_DATAMATRIX, "[01]12345678901231[10]()", GS1_MODE, -1, 0 },
/* 84*/ { BARCODE_DATAMATRIX, "(01)12345678901231(10)()", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 85*/ { BARCODE_DATAMATRIX, "(01)12345678901231(10)\\(\\)", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 86*/ { BARCODE_DATAMATRIX, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 87*/ { BARCODE_DOTCODE, "[01]12345678901231", GS1_MODE, -1, 0 },
/* 88*/ { BARCODE_DOTCODE, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/* 89*/ { BARCODE_DOTCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 90*/ { BARCODE_DOTCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 91*/ { BARCODE_DOTCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 92*/ { BARCODE_DOTCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 93*/ { BARCODE_DOTCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 94*/ { BARCODE_DOTCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 95*/ { BARCODE_DOTCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 96*/ { BARCODE_DOTCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 97*/ { BARCODE_DOTCODE, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/* 98*/ { BARCODE_DOTCODE, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/* 99*/ { BARCODE_DOTCODE, "[01]12345678901231", GS1_MODE, READER_INIT, 0 }, /* Reader Init permissible with default GS1 mode */
/*100*/ { BARCODE_DOTCODE, "[10]()[01]12345678901231", GS1_MODE, -1, 0 },
/*101*/ { BARCODE_DOTCODE, "(10)()(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*102*/ { BARCODE_DOTCODE, "(10)\\(\\)(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/*103*/ { BARCODE_DOTCODE, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*104*/ { BARCODE_QRCODE, "[01]12345678901231", GS1_MODE, -1, 0 },
/*105*/ { BARCODE_QRCODE, "(01)12345678901231", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/*106*/ { BARCODE_QRCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*107*/ { BARCODE_QRCODE, "(01)12345678901234", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*108*/ { BARCODE_QRCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*109*/ { BARCODE_QRCODE, "(01)123456789012345", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*110*/ { BARCODE_QRCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*111*/ { BARCODE_QRCODE, "(01)12345678901234A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*112*/ { BARCODE_QRCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*113*/ { BARCODE_QRCODE, "(01)1234567890123A", GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE, -1, 0 },
/*114*/ { BARCODE_QRCODE, "[01]1234567890123", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*115*/ { BARCODE_QRCODE, "[01]1234567890123", GS1_MODE | GS1NOCHECK_MODE, -1, 0 },
/*116*/ { BARCODE_QRCODE, "[02]12345678901231[10]()[37]12345678[00]123456789012345675", GS1_MODE, -1, 0 },
/*117*/ { BARCODE_QRCODE, "(02)12345678901231(10)()(37)12345678(00)123456789012345675", GS1_MODE | GS1PARENS_MODE, -1, ZINT_ERROR_INVALID_DATA },
/*118*/ { BARCODE_QRCODE, "(02)12345678901231(10)\\(\\)(37)12345678(00)123456789012345675", GS1_MODE | GS1PARENS_MODE, -1, 0 },
/*119*/ { BARCODE_QRCODE, "1234", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, data[i].output_options,
data[i].data, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
i, ret, data[i].ret, symbol->errtxt);
ZBarcode_Delete(symbol);
}
testFinish();
}
/* Check GS1_128-based and DBAR_EXP-based symbologies */
static void test_gs1_128_dbar_exp(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int symbology;
int input_mode;
const char *data;
const char *composite;
int ret;
const char *expected_errtxt;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_GS1_128, -1, "[01]12345678901231", "", 0, "" },
/* 1*/ { BARCODE_GS1_128, -1, "[01]12345678901234", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): The numeric check digit is incorrect. (01)1234567890123|4|" },
/* 2*/ { BARCODE_GS1_128, -1, "[01]123456789012345", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too long" },
/* 3*/ { BARCODE_GS1_128, -1, "[01]1234567890123", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 4*/ { BARCODE_GS1_128, -1, "[01]12345678901231[20]1", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (20) value is too short" },
/* 5*/ { BARCODE_GS1_128, -1, "[04]1234[05]12345[06]123456", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 04" },
/* 6*/ { BARCODE_GS1_128, -1, "[01]1234567890123A", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|A|" },
/* 7*/ { BARCODE_GS1_128, -1, "[01]1234567890123.", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|.|" },
/* 8*/ { BARCODE_GS1_128, -1, "[01]1234567890123\177", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|\\x7F|" },
/* 9*/ { BARCODE_GS1_128, -1, "[01]1234567890123\200", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890123|\\x80|" },
/* 10*/ { BARCODE_GS1_128, -1, "0112345678901231", "", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 11*/ { BARCODE_GS1_128, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 12*/ { BARCODE_GS1_128, -1, "[01][20]12", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 13*/ { BARCODE_GS1_128, -1, "[0]123", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 0" },
/* 14*/ { BARCODE_GS1_128, -1, "[0]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 0" },
/* 15*/ { BARCODE_GS1_128, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 16*/ { BARCODE_GS1_128, -1, "[01]12345678901231[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 17*/ { BARCODE_GS1_128, -1, "[123456789012345]123", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 123456789012345" },
/* 18*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)AB[", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (91): A non-CSET 82 character was found where a CSET 82 character is expected. (91)AB|[|" },
/* 19*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(91)12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789[", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (91): A non-CSET 82 character was found where a CSET 82 character is expected." },
/* 20*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]12", 0, "" },
/* 21*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901234", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): The numeric check digit is incorrect. (01)1234567890123|4|" },
/* 22*/ { BARCODE_GS1_128_CC, -1, "[01]123456789012345", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too long" },
/* 23*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]123", ZINT_ERROR_INVALID_DATA, "Error 268: AI (20) value is too long" },
/* 24*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[20]1A", ZINT_ERROR_INVALID_DATA, "Error 267: AI (20): A non-digit character was found where a digit is expected. (20)1|A|" },
/* 25*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[20]", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 26*/ { BARCODE_GS1_128_CC, -1, "[01]1234567890121", "[2]12", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 27*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 28*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[90]12[34", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 29*/ { BARCODE_GS1_128_CC, -1, "https://example.com/01/12345678901231", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 30*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231", "", 0, "" },
/* 31*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 32*/ { BARCODE_DBAR_EXP, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): A non-digit character was found where a digit is expected. (11)12345|A|" },
/* 33*/ { BARCODE_DBAR_EXP, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 34*/ { BARCODE_DBAR_EXP, -1, "[10]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 35*/ { BARCODE_DBAR_EXP, -1, "[2]1", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 2" },
/* 36*/ { BARCODE_DBAR_EXP, -1, "[]1", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 37*/ { BARCODE_DBAR_EXP, -1, "[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 38*/ { BARCODE_DBAR_EXP, -1, "[20]12[]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 39*/ { BARCODE_DBAR_EXP, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 40*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/* 41*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 42*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): The date contains an illegal month of the year. (11)12|34|56" },
/* 43*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 268: AI (30) value is too long" },
/* 44*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_ERROR_INVALID_DATA, "Error 267: AI (30): A non-digit character was found where a digit is expected. (30)1234567|A|" },
/* 45*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121\177", "[20]12", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890121|\\x7F|" },
/* 46*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 267: AI (20): A non-digit character was found where a digit is expected. (20)1|\\x7F|" },
/* 47*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "2012", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 48*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "2012", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 49*/ { BARCODE_DBAR_EXP_CC, -1, "[01]1234567890121", "[10]", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 50*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[10]", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 51*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[2]1", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: 2" },
/* 52*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[]12", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 53*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[]", ZINT_ERROR_INVALID_DATA, "Error 268: Unrecognised AI: " },
/* 54*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 55*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231", "", 0, "" },
/* 56*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]1234", "", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 57*/ { BARCODE_DBAR_EXPSTK, -1, "[01]12345678901231[10]123[11]12345A", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): A non-digit character was found where a digit is expected. (11)12345|A|" },
/* 58*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\177", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890121|\\x7F|" },
/* 59*/ { BARCODE_DBAR_EXPSTK, -1, "[01]1234567890121\200", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (01): A non-digit character was found where a digit is expected. (01)1234567890121|\\x80|" },
/* 60*/ { BARCODE_DBAR_EXPSTK, -1, "011234567890121", "", ZINT_ERROR_INVALID_DATA, "Error 264: Data does not start with an AI" },
/* 61*/ { BARCODE_DBAR_EXPSTK, -1, "[01]", "", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 62*/ { BARCODE_DBAR_EXPSTK, -1, "[90]12]34", "", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
/* 63*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345", 0, "" },
/* 64*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]1234", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 268: AI (11) value is too short" },
/* 65*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]123456", "[21]ABC123[22]12345", ZINT_ERROR_INVALID_DATA, "Error 267: AI (11): The date contains an illegal month of the year. (11)12|34|56" },
/* 66*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]123456789", ZINT_ERROR_INVALID_DATA, "Error 268: AI (30) value is too long" },
/* 67*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[10]123[11]121212", "[21]ABC123[22]12345[30]1234567A", ZINT_ERROR_INVALID_DATA, "Error 267: AI (30): A non-digit character was found where a digit is expected. (30)1234567|A|" },
/* 68*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[20]1\177", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 69*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "[20]1\200", ZINT_ERROR_INVALID_DATA, "Error 267: AI (20): A non-digit character was found where a digit is expected. (20)1|\\x80|" },
/* 70*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "2012", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 71*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]1234567890121", "[235]", ZINT_ERROR_INVALID_DATA, "Error 268: AI (01) value is too short" },
/* 72*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "[235]", ZINT_ERROR_INVALID_DATA, "Error 268: Failed to parse AI data" },
/* 73*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231", "[90]12]34", ZINT_ERROR_INVALID_DATA, "Error 267: AI (90): A non-CSET 82 character was found where a CSET 82 character is expected. (90)12|]|34" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
const char *text;
testStartSymbol(p_ctx->func_name, &symbol);
for (i = 0; i < data_size; i++) {
if (testContinue(p_ctx, i)) continue;
symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
if (data[i].composite[0]) {
text = data[i].composite;
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/,
-1 /*option_1*/, -1 /*option_2*/, -1 /*option_3*/, -1 /*output_options*/,
text, -1, debug);
symbol->input_mode |= GS1SYNTAXENGINE_MODE;
ret = ZBarcode_Encode(symbol, TCU(text), length);
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_errtxt), "i:%d strcmp(%s, %s) != 0\n",
i, symbol->errtxt, data[i].expected_errtxt);
ZBarcode_Delete(symbol);
}
testFinish();
}
int main(int argc, char *argv[]) {
testFunction funcs[] = { /* name, func */
{ "test_gs1_reduce", test_gs1_reduce },
{ "test_hrt", test_hrt },
{ "test_gs1_verify", test_gs1_verify },
{ "test_gs1_digital_link", test_gs1_digital_link },
{ "test_non_forced", test_non_forced },
{ "test_gs1_128_dbar_exp", test_gs1_128_dbar_exp },
};
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
testReport();
return 0;
}
/* vim: set ts=4 sw=4 et : */
+1 -2
View File
@@ -4351,8 +4351,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
expected = escaped;
}
if (gs1 && symbology != BARCODE_EAN14 && symbology != BARCODE_NVE18) {
int len = expected_len;
ret = zint_gs1_verify(symbol, ZUCP(expected), &len, ZUCP(reduced), &expected_len);
ret = zint_gs1_verify(symbol, ZUCP(expected), expected_len, ZUCP(reduced), &expected_len);
if (ret >= ZINT_ERROR) {
sprintf(msg, "zint_gs1_verify %d != 0", ret);
return 3;
+4
View File
@@ -325,6 +325,7 @@ extern "C" {
/* Note: affects DATAMATRIX, MICROPDF417, PDF417, QRCODE & UPNQR only */
#define EXTRA_ESCAPE_MODE 0x0100 /* Process special symbology-specific escape sequences as well as others */
/* Note: currently Code 128 only */
#define GS1SYNTAXENGINE_MODE 0x0200 /* Use the GS1 Syntax Engine (if available) to strictly validate GS1 input */
/* Data Matrix specific options (`symbol->option_3`) */
#define DM_SQUARE 100 /* Only consider square versions on automatic symbol size selection */
@@ -511,6 +512,9 @@ extern "C" {
/* Whether Zint built without PNG support */
ZINT_EXTERN int ZBarcode_NoPng(void);
/* Whether Zint built with GS1 Syntax Engine support */
ZINT_EXTERN int ZBarcode_HaveGS1SyntaxEngine(void);
/* Return the version of Zint linked to */
ZINT_EXTERN int ZBarcode_Version(void);
+18 -1
View File
@@ -199,7 +199,7 @@ namespace Zint {
m_compliant_height(false),
m_rotate_angle(0),
m_eci(0),
m_gs1parens(false), m_gs1nocheck(false),
m_gs1parens(false), m_gs1nocheck(false), m_gs1syntaxengine(false),
m_reader_init(false),
m_guard_whitespace(false),
m_embed_vector_font(false),
@@ -278,6 +278,9 @@ namespace Zint {
if (m_gs1nocheck) {
m_zintSymbol->input_mode |= GS1NOCHECK_MODE;
}
if (m_gs1syntaxengine) {
m_zintSymbol->input_mode |= GS1SYNTAXENGINE_MODE;
}
m_zintSymbol->eci = m_eci;
m_zintSymbol->dpmm = m_dpmm;
m_zintSymbol->dot_size = m_dot_size;
@@ -738,6 +741,15 @@ namespace Zint {
m_gs1nocheck = gs1NoCheck;
}
/* Use GS1 Syntax Engine to validate GS1 data */
bool QZint::gs1SyntaxEngine() const {
return m_gs1syntaxengine;
}
void QZint::setGS1SyntaxEngine(bool gs1SyntaxEngine) {
m_gs1syntaxengine = gs1SyntaxEngine;
}
/* Reader Initialisation (Programming) */
bool QZint::readerInit() const {
return m_reader_init;
@@ -1233,6 +1245,11 @@ namespace Zint {
return ZBarcode_NoPng() == 1;
}
/* Whether Zint library "libzint" built with PNG support or not */
bool QZint::haveGS1SyntaxEngine() {
return ZBarcode_HaveGS1SyntaxEngine() == 1;
}
/* Version of Zint library "libzint" linked to */
int QZint::getVersion() {
return ZBarcode_Version();
+8
View File
@@ -208,6 +208,10 @@ public:
bool gs1NoCheck() const; // `symbol->input_mode | GS1NOCHECK_MODE`
void setGS1NoCheck(bool gs1NoCheck);
/* Use GS1 Syntax Engine to validate GS1 data */
bool gs1SyntaxEngine() const; // `symbol->input_mode | GS1SYNTAXENGINE_MODE`
void setGS1SyntaxEngine(bool gs1SyntaxEngine);
/* Reader Initialisation (Programming) */
bool readerInit() const; // `symbol->output_options | READER_INIT`
void setReaderInit(bool readerInit);
@@ -317,6 +321,9 @@ public:
/* Whether Zint library "libzint" built with PNG support or not */
static bool noPng(); // `ZBarcode_NoPng()`
/* Whether Zint library "libzint" built with GS1 Syntax Engine support or not */
static bool haveGS1SyntaxEngine(); // `ZBarcode_HaveGS1SyntaxEngine()`
/* Version of Zint library "libzint" linked to */
static int getVersion(); // `ZBarcode_Version()`
@@ -391,6 +398,7 @@ private:
int m_eci;
bool m_gs1parens;
bool m_gs1nocheck;
bool m_gs1syntaxengine;
bool m_reader_init;
bool m_guard_whitespace;
bool m_embed_vector_font;
+127 -102
View File
@@ -912,14 +912,16 @@ into bitmaps.</p>
<h1 id="installing-zint">2. Installing Zint</h1>
<h2 id="linux">2.1 Linux</h2>
<p>The easiest way to configure compilation is to take advantage of the
CMake utilities. You will need to install CMake and
CMake utilities. You will need to install CMake, and
<code>libpng-dev</code> first. For instance on <code>apt</code>
systems:</p>
<div class="sourceCode" id="cb1"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sudo</span> apt install git cmake build-essential libpng-dev</span></code></pre></div>
<p>If you want to take advantage of Zint Barcode Studio you will also
need to have Qt and its component <code>"Desktop gcc 64-bit"</code>
installed, as well as <code>mesa</code>. For details see
installed, as well as <code>mesa</code>. Other steps are required to
avail of the GS1 Syntax Engine.<a href="#fn1" class="footnote-ref"
id="fnref1" role="doc-noteref"><sup>1</sup></a> For details see
<code>"README.linux"</code> in the project root directory.</p>
<p>Once you have fulfilled these requirements unzip the source code
tarball or clone the latest source</p>
@@ -979,8 +981,8 @@ $664 per year to have the application digitally signed by Microsoft.</p>
<code>"win32/README"</code>.</p>
<h2 id="apple-macos">2.4 Apple macOS</h2>
<p>The latest Zint CLI and <code>libzint</code> can be installed using
Homebrew.<a href="#fn1" class="footnote-ref" id="fnref1"
role="doc-noteref"><sup>1</sup></a> To install Homebrew input the
Homebrew.<a href="#fn2" class="footnote-ref" id="fnref2"
role="doc-noteref"><sup>2</sup></a> To install Homebrew input the
following line into the macOS terminal</p>
<div class="sourceCode" id="cb9"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="ex">/bin/bash</span> <span class="at">-c</span> <span class="st">&quot;</span><span class="va">$(</span><span class="ex">curl</span> <span class="at">-fsSL</span> <span class="dt">\</span></span>
@@ -1448,8 +1450,8 @@ hexadecimal (00-FF)</td>
<td style="text-align: left;"><code>\uNNNN</code></td>
<td style="text-align: left;"></td>
<td style="text-align: left;"></td>
<td style="text-align: left;">Any 16-bit Unicode BMP<a href="#fn2"
class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a>
<td style="text-align: left;">Any 16-bit Unicode BMP<a href="#fn3"
class="footnote-ref" id="fnref3" role="doc-noteref"><sup>3</sup></a>
character where NNNN is hexadecimal (0000-FFFF)</td>
</tr>
<tr>
@@ -1571,8 +1573,8 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb22-1"><a href=
<thead>
<tr>
<th style="text-align: left;">Numeric Value</th>
<th style="text-align: left;">Name<a href="#fn3" class="footnote-ref"
id="fnref3" role="doc-noteref"><sup>3</sup></a></th>
<th style="text-align: left;">Name<a href="#fn4" class="footnote-ref"
id="fnref4" role="doc-noteref"><sup>4</sup></a></th>
<th style="text-align: left;">Barcode Name</th>
</tr>
</thead>
@@ -2262,8 +2264,8 @@ class="sourceCode bash"><code class="sourceCode bash"><span id="cb34-1"><a href=
<p>will give different results for PNG and SVG. Experimentation is
advised!</p>
<p>In addition the <code>--nobackground</code> option will remove the
background from all output formats except BMP.<a href="#fn4"
class="footnote-ref" id="fnref4" role="doc-noteref"><sup>4</sup></a></p>
background from all output formats except BMP.<a href="#fn5"
class="footnote-ref" id="fnref5" role="doc-noteref"><sup>5</sup></a></p>
<p>The <code>--cmyk</code> option is specific to output in Encapsulated
PostScript (EPS) and TIF, and selects the CMYK colour space. Custom
colours should then usually be given in the comma-separated
@@ -2417,8 +2419,8 @@ X-dimension at 600 dpi specify:</p>
class="sourceCode bash"><code class="sourceCode bash"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a><span class="ex">zint</span> <span class="at">-b</span> MAXICODE <span class="at">-d</span> <span class="st">&quot;MaxiCode (19 chars)&quot;</span> <span class="at">--scalexdimdp</span><span class="op">=</span>0,600dpi</span></code></pre></div>
<h2 id="human-readable-text-hrt-options">4.10 Human Readable Text (HRT)
Options</h2>
<p>For linear barcodes the text present<a href="#fn5"
class="footnote-ref" id="fnref5" role="doc-noteref"><sup>5</sup></a> in
<p>For linear barcodes the text present<a href="#fn6"
class="footnote-ref" id="fnref6" role="doc-noteref"><sup>6</sup></a> in
the output image can be removed by using the <code>--notext</code>
option. Note also that for raster output text will not be printed for
scales less than 1 (see <a href="#adjusting-image-size-x-dimension">4.9
@@ -2536,8 +2538,8 @@ data-tag=": Default Character Sets">
<tr>
<td style="text-align: left;">Micro QR Code</td>
<td style="text-align: left;">Latin-1</td>
<td>Shift JIS (includes ASCII<a href="#fn6" class="footnote-ref"
id="fnref6" role="doc-noteref"><sup>6</sup></a>)</td>
<td>Shift JIS (includes ASCII<a href="#fn7" class="footnote-ref"
id="fnref7" role="doc-noteref"><sup>7</sup></a>)</td>
</tr>
<tr>
<td style="text-align: left;">PDF417</td>
@@ -2580,11 +2582,12 @@ Modes and ECI</a> below.</p>
<p>GS1 data can be encoded in a number of symbologies. Application
Identifiers (AIs) should be enclosed in <code>[square brackets]</code>
followed by the data to be encoded (see <a href="#gs1-128">6.1.10.3
GS1-128</a>). To encode GS1 data use the <code>--gs1</code> option. GS1
mode is assumed (and doesnt need to be set) for GS1-128, EAN-14, GS1
DataBar and GS1 Composite symbologies but is also available for Aztec
Code, Code 16K, Code 49, Code One, Data Matrix, DotCode, QR Code and
Ultracode.</p>
GS1-128</a>). GS1 Digital Link URIs are also supported. To encode GS1
data use the <code>--gs1</code> option. Also recommended is the
<code>--gs1strict</code> option, which verifies the GS1 data. GS1 mode
is assumed (and doesnt need to be set) for GS1-128, EAN-14, GS1 DataBar
and GS1 Composite symbologies but is also available for Aztec Code, Code
16K, Code 49, Code One, Data Matrix, DotCode, QR Code and Ultracode.</p>
<p>Health Industry Barcode (HIBC) data may also be encoded in the
symbologies Aztec Code, Codablock-F, Code 128, Code 39, Data Matrix,
MicroPDF417, PDF417 and QR Code. Within this mode, the leading
@@ -2785,8 +2788,8 @@ translates the data into the target encoding.</p>
</tr>
<tr>
<td>170</td>
<td>ISO/IEC 646 Invariant<a href="#fn7" class="footnote-ref" id="fnref7"
role="doc-noteref"><sup>7</sup></a></td>
<td>ISO/IEC 646 Invariant<a href="#fn8" class="footnote-ref" id="fnref8"
role="doc-noteref"><sup>8</sup></a></td>
</tr>
<tr>
<td>899</td>
@@ -3371,8 +3374,8 @@ member <code>memfile</code> instead of to the output file
<span id="cb63-16"><a href="#cb63-16" aria-hidden="true" tabindex="-1"></a><span class="op">}</span></span></code></pre></div>
<p>will print the SVG output to <code>stdout</code> (the file
<code>"mem.svg"</code> is not created). This is particularly useful for
the textual formats EPS and SVG,<a href="#fn8" class="footnote-ref"
id="fnref8" role="doc-noteref"><sup>8</sup></a> allowing the output to
the textual formats EPS and SVG,<a href="#fn9" class="footnote-ref"
id="fnref9" role="doc-noteref"><sup>9</sup></a> allowing the output to
be manipulated and processed by the client.</p>
<h2 id="setting-options">5.7 Setting Options</h2>
<p>So far our application is not very useful unless we plan to only make
@@ -3412,8 +3415,8 @@ href="#specifying-a-symbology">5.9 Specifying a Symbology</a>.</td>
<td style="text-align: left;"><code>height</code></td>
<td style="text-align: left;">float</td>
<td style="text-align: left;">Symbol height in X-dimensions, excluding
fixed width-to-height symbols.<a href="#fn9" class="footnote-ref"
id="fnref9" role="doc-noteref"><sup>9</sup></a></td>
fixed width-to-height symbols.<a href="#fn10" class="footnote-ref"
id="fnref10" role="doc-noteref"><sup>10</sup></a></td>
<td style="text-align: left;">Symbol dependent</td>
</tr>
<tr>
@@ -3488,8 +3491,8 @@ resulting barcode symbol to. Must end in <code>.png</code>,
<code>.gif</code>, <code>.bmp</code>, <code>.emf</code>,
<code>.eps</code>, <code>.pcx</code>, <code>.svg</code>,
<code>.tif</code> or <code>.txt</code> followed by a terminating
<code>NUL</code>.<a href="#fn10" class="footnote-ref" id="fnref10"
role="doc-noteref"><sup>10</sup></a></td>
<code>NUL</code>.<a href="#fn11" class="footnote-ref" id="fnref11"
role="doc-noteref"><sup>11</sup></a></td>
<td style="text-align: left;"><code>"out.png"</code></td>
</tr>
<tr>
@@ -3905,15 +3908,15 @@ value:</p>
<tr>
<td style="text-align: left;"><code>BARCODE_BIND_TOP</code></td>
<td style="text-align: left;">Boundary bar above the symbol only.<a
href="#fn11" class="footnote-ref" id="fnref11"
role="doc-noteref"><sup>11</sup></a></td>
href="#fn12" class="footnote-ref" id="fnref12"
role="doc-noteref"><sup>12</sup></a></td>
</tr>
<tr>
<td style="text-align: left;"><code>BARCODE_BIND</code></td>
<td style="text-align: left;">Boundary bars above and below the symbol
and between rows if stacking multiple symbols.<a href="#fn12"
class="footnote-ref" id="fnref12"
role="doc-noteref"><sup>12</sup></a></td>
and between rows if stacking multiple symbols.<a href="#fn13"
class="footnote-ref" id="fnref13"
role="doc-noteref"><sup>13</sup></a></td>
</tr>
<tr>
<td style="text-align: left;"><code>BARCODE_BOX</code></td>
@@ -3963,8 +3966,8 @@ Memory (raster)</a>.</td>
<tr>
<td style="text-align: left;"><code>BARCODE_QUIET_ZONES</code></td>
<td style="text-align: left;">Add compliant quiet zones (additional to
any specified whitespace).<a href="#fn13" class="footnote-ref"
id="fnref13" role="doc-noteref"><sup>13</sup></a></td>
any specified whitespace).<a href="#fn14" class="footnote-ref"
id="fnref14" role="doc-noteref"><sup>14</sup></a></td>
</tr>
<tr>
<td style="text-align: left;"><code>BARCODE_NO_QUIET_ZONES</code></td>
@@ -4011,8 +4014,8 @@ below.</p>
<caption><span>Table <span class="math inline"> </span>:</span> API
<code>input_mode</code> Values </caption>
<colgroup>
<col style="width: 25%" />
<col style="width: 74%" />
<col style="width: 30%" />
<col style="width: 69%" />
</colgroup>
<thead>
<tr>
@@ -4049,14 +4052,13 @@ sequences.</td>
<td style="text-align: left;"><code>GS1PARENS_MODE</code></td>
<td style="text-align: left;">Parentheses (round brackets) used in GS1
data instead of square brackets to delimit Application Identifiers
(parentheses in the data must be escaped and <code>ESCAPE_MODE</code>
selected).</td>
(parentheses in the data must be escaped).</td>
</tr>
<tr>
<td style="text-align: left;"><code>GS1NOCHECK_MODE</code></td>
<td style="text-align: left;">Do not check GS1 data for validity,
i.e. suppress checks for valid AIs and data lengths. Invalid characters
(e.g. control characters, extended ASCII characters) are still checked
(e.g. control characters, extended ASCII characters) are still checked
for.</td>
</tr>
<tr>
@@ -4076,18 +4078,24 @@ other shortcuts if available (affects <code>DATAMATRIX</code>,
<td style="text-align: left;">Process special symbology-specific escape
sequences (<code>CODE128</code> only).</td>
</tr>
<tr>
<td style="text-align: left;"><code>GS1SYNTAXENGINE_MODE</code></td>
<td style="text-align: left;">Use the GS1 Syntax Engine (if available)
to strictly validate GS1 input.</td>
</tr>
</tbody>
</table>
</div>
<p>The default mode is <code>DATA_MODE</code>. (Note that this differs
from the default for the CLI and GUI, which is
<code>UNICODE_MODE</code>.)</p>
<p>The default mode is <code>DATA_MODE</code> (CLI option
<code>--binary</code>). (Note that this differs from the default for the
CLI and GUI, which is <code>UNICODE_MODE</code>.)</p>
<p><code>DATA_MODE</code>, <code>UNICODE_MODE</code> and
<code>GS1_MODE</code> are mutually exclusive, whereas
<code>ESCAPE_MODE</code>, <code>GS1PARENS_MODE</code>,
<code>GS1NOCHECK_MODE</code>, <code>HEIGHTPERROW_MODE</code>,
<code>FAST_MODE</code> and <code>EXTRA_ESCAPE_MODE</code> are optional.
So, for example, you can set</p>
<code>FAST_MODE</code>, <code>EXTRA_ESCAPE_MODE</code> and
<code>GS1SYNTAXENGINE_MODE</code> are optional. So, for example, you can
set</p>
<div class="sourceCode" id="cb71"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb71-1"><a href="#cb71-1" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>input_mode <span class="op">=</span> UNICODE_MODE <span class="op">|</span> ESCAPE_MODE<span class="op">;</span></span></code></pre></div>
<p>or</p>
<div class="sourceCode" id="cb72"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb72-1"><a href="#cb72-1" aria-hidden="true" tabindex="-1"></a>my_symbol<span class="op">-&gt;</span>input_mode <span class="op">=</span> GS1_MODE <span class="op">|</span> GS1PARENS_MODE <span class="op">|</span> GS1NOCHECK_MODE<span class="op">;</span></span></code></pre></div>
@@ -4100,14 +4108,20 @@ special Code 128-only <code>EXTRA_ESCAPE_MODE</code> escape sequences
are given in <a href="#standard-code-128-iso-15417">6.1.10.1 Standard
Code 128 (ISO 15417)</a>. An example of <code>GS1PARENS_MODE</code>
usage is given in section <a href="#gs1-128">6.1.10.3 GS1-128</a>.</p>
<p><code>GS1NOCHECK_MODE</code> is for use with legacy systems that have
data that does not conform to the current GS1 standard. Printable ASCII
input is still checked for, as is the validity of GS1 data specified
without AIs (e.g. linear data for GS1 DataBar
Omnidirectional/Limited/etc.). Also checked is GS1 DataBar Expanded and
GS1 Composite input that is not in the GS1 encodable character set 82
(see GS1 General Specifications Figure 7.11.1 GS1 AI encodable
character set 82), otherwise encodation would fail.</p>
<p><code>GS1NOCHECK_MODE</code> (CLI <code>--gs1nocheck</code>) is for
use with legacy systems that have data that does not conform to the
current GS1 standard. Printable ASCII input is still checked for, as is
the validity of GS1 data specified without AIs (e.g. linear data for GS1
DataBar Omnidirectional/Limited/etc.). Also checked is GS1 DataBar
Expanded and GS1 Composite input that is not in the GS1 encodable
character set 82 (see GS1 General Specifications Figure 7.11.1 GS1 AI
encodable character set 82), otherwise encodation would fail.</p>
<p>In contrast <code>GS1SYNTAXENGINE_MODE</code> (CLI
<code>--gs1strict</code>) enables the use the GS1 Syntax Engine to
strictly validate GS1 data, including GS1 Digital Link URIs (by default
ZINT does not validate Digital Links at all). It requires that the
<code>gs1encoders</code> library was present when Zint was built,
otherwise the default built-in validation will be used.</p>
<p>For <code>HEIGHTPERROW_MODE</code>, see <code>--heightperrow</code>
in section <a href="#adjusting-height">4.4 Adjusting Height</a>. The
<code>height</code> member should be set to the desired per-row value on
@@ -4262,8 +4276,8 @@ stacked symbologies are not stackable.</td>
</tr>
<tr>
<td style="text-align: left;"><code>ZINT_CAP_EANUPC</code><a
href="#fn14" class="footnote-ref" id="fnref14"
role="doc-noteref"><sup>14</sup></a></td>
href="#fn15" class="footnote-ref" id="fnref15"
role="doc-noteref"><sup>15</sup></a></td>
<td style="text-align: left;">Is the symbology EAN/UPC?</td>
</tr>
<tr>
@@ -4349,8 +4363,8 @@ etc.) the <code>option_1</code>, <code>option_2</code> and
<code>option_3</code> members will be set to the values used by Zint to
create the barcode. This is useful for feedback if the values were left
as defaults or were overridden by Zint.</p>
<p>In particular for symbologies that have masks,<a href="#fn15"
class="footnote-ref" id="fnref15" role="doc-noteref"><sup>15</sup></a>
<p>In particular for symbologies that have masks,<a href="#fn16"
class="footnote-ref" id="fnref16" role="doc-noteref"><sup>16</sup></a>
<code>option_3</code> will contain the mask used as
<code>(N + 1) &lt;&lt; 8</code>, N being the mask. Also Aztec Code will
return the actual ECC percentage used in <code>option_1</code> as
@@ -4373,8 +4387,8 @@ members of <code>zint_seg</code> will be set accordingly - the
unconverted data in <code>source</code>, the data length in
<code>length</code>, and the character set the data was converted to in
<code>eci</code>. Any check characters encoded will be included,<a
href="#fn16" class="footnote-ref" id="fnref16"
role="doc-noteref"><sup>16</sup></a> and for GS1 data any
href="#fn17" class="footnote-ref" id="fnref17"
role="doc-noteref"><sup>17</sup></a> and for GS1 data any
<code>FNC1</code> separators will be represented as <code>GS</code>
(ASCII 29) characters. UPC-A and UPC-E data will be expanded to EAN-13,
as will EAN-8 but only if it has an add-on (otherwise it will remain at
@@ -4391,8 +4405,8 @@ member using the two helper functions discussed next.</p>
convenience functions</h2>
<p>As a convenience the conversion done by Zint from UTF-8 to ECIs is
exposed in two helper functions (compatible with the
<code>libzueci</code><a href="#fn17" class="footnote-ref" id="fnref17"
role="doc-noteref"><sup>17</sup></a> functions
<code>libzueci</code><a href="#fn18" class="footnote-ref" id="fnref18"
role="doc-noteref"><sup>18</sup></a> functions
<code>zueci_utf8_to_eci()</code> and
<code>zueci_dest_len_eci()</code>):</p>
<div class="sourceCode" id="cb85"><pre class="sourceCode c"><code class="sourceCode c"><span id="cb85-1"><a href="#cb85-1" aria-hidden="true" tabindex="-1"></a><span class="dt">int</span> ZBarcode_UTF8_To_ECI<span class="op">(</span><span class="dt">int</span> eci<span class="op">,</span> <span class="dt">const</span> <span class="dt">unsigned</span> <span class="dt">char</span> <span class="op">*</span>source<span class="op">,</span> <span class="dt">int</span> length<span class="op">,</span></span>
@@ -5062,8 +5076,8 @@ aria-hidden="true"><code>zint -b CODE128AB -d "130170X178"</code></figcaption>
</figure>
<p>It is sometimes advantageous to stop Code 128 from using Code Set C
which compresses numerical data. The <code>BARCODE_CODE128AB</code><a
href="#fn18" class="footnote-ref" id="fnref18"
role="doc-noteref"><sup>18</sup></a> variant (symbology 60) suppresses
href="#fn19" class="footnote-ref" id="fnref19"
role="doc-noteref"><sup>19</sup></a> variant (symbology 60) suppresses
Code Set C in favour of Code Sets A and B.</p>
<p>Note that the special extra escapes mentioned above are not available
for this variant (nor for any other).</p>
@@ -5812,8 +5826,8 @@ the 6-digit version the first and last digit are ignored, leaving a
2047. The second format <code>"NNN-NN"</code> represents the DX Extract
as two numbers separated by a dash (<code>-</code>), the first number
being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range
0 to 15).<a href="#fn19" class="footnote-ref" id="fnref19"
role="doc-noteref"><sup>19</sup></a></p>
0 to 15).<a href="#fn20" class="footnote-ref" id="fnref20"
role="doc-noteref"><sup>20</sup></a></p>
<p>The optional frame number is a number in the range 0 to 63, and may
have a half frame indicator <code>"A"</code> appended. Special character
sequences (with or without a half frame indicator appended) may also be
@@ -9212,6 +9226,11 @@ than square brackets <code>"[]"</code>. If the AI data contains
parentheses, they must be backslashed (<code>"\("</code> or
<code>"\)"</code>) and the <code>--esc</code> option selected.</p>
</dd>
<dt><code>--gs1strict</code></dt>
<dd>
<p>Uses the GS1 Syntax Engine (if available) to strictly verify GS1
data. Ignored if <code>--gs1nocheck</code> also given.</p>
</dd>
<dt><code>--gssep</code></dt>
<dd>
<p>For Data Matrix in GS1 mode, use <code>GS</code> (0x1D) as the GS1
@@ -9703,91 +9722,97 @@ class="email">robin@zint.org.uk</a></p>
role="doc-endnotes">
<hr />
<ol>
<li id="fn1"><p>See the Homebrew website <a
href="https://brew.sh">https://brew.sh</a>.<a href="#fnref1"
<li id="fn1"><p>The GS1 Syntax Engine (<code>gs1encoders</code>
library), which is officially sanctioned by GS1, offers strict
validation of GS1 data, including GS1 Digital Link URIs - see “GS1
Barcode Syntax Engine” at <a
href="https://github.com/gs1/gs1-syntax-engine">https://github.com/gs1/gs1-syntax-engine</a>.<a
href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn2"><p>See the Homebrew website <a
href="https://brew.sh">https://brew.sh</a>.<a href="#fnref2"
class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn2"><p>In Unicode contexts, BMP stands for Basic Multilingual
<li id="fn3"><p>In Unicode contexts, BMP stands for Basic Multilingual
Plane, the plane 0 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!<a href="#fnref2" class="footnote-back"
file format BMP!<a href="#fnref3" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn3"><p>The symbology names marked with an asterisk
<li id="fn4"><p>The symbology names marked with an asterisk
(<code>*</code>) in Table <a href="#tbl:barcode_types">: Barcode Types
(Symbologies)</a> above used different names in previous versions of
Zint. These names are now deprecated but are still recognised by Zint.
Those marked with a dagger (<code></code>) are replacements for
<code>BARCODE_EANX</code> (13), <code>BARCODE_EANX_CHK</code> (14) and
<code>BARCODE_EANX_CC</code> (130), which are still recognised by
Zint.<a href="#fnref3" class="footnote-back"
Zint.<a href="#fnref4" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn4"><p>The background is omitted for vector outputs EMF, EPS
<li id="fn5"><p>The background is omitted for vector outputs EMF, EPS
and SVG when <code>--nobackground</code> is given. For raster outputs
GIF, PCX, PNG and TIF, the backgrounds alpha channel is set to zero
(fully transparent).<a href="#fnref4" class="footnote-back"
(fully transparent).<a href="#fnref5" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn5"><p>For linear barcodes, Human Readable Text (HRT) is not
<li id="fn6"><p>For linear barcodes, Human Readable Text (HRT) is not
shown for the postal codes Australia Post (all variants), USPS
Intelligent Mail, POSTNET and PLANET, Brazilian CEPNet, Royal Mail
4-State Customer Code and 4-State Mailmark, Dutch Post KIX Code,
Japanese Postal Code, DAFT Code and FIM, the pharma codes Pharmacode
One-Track and Pharmacode Two-Track, and the specialist codes DX Film
Edge Barcode and Flattermarken. Note that HRT is never shown for stacked
and matrix barcodes.<a href="#fnref5" class="footnote-back"
and matrix barcodes.<a href="#fnref6" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn6"><p>Shift JIS (JIS X 0201 Roman) re-maps two ASCII
<li id="fn7"><p>Shift JIS (JIS X 0201 Roman) re-maps two ASCII
characters: backslash (<code>\</code>) to the yen sign (¥), and tilde
(<code>~</code>) to overline (U+203E).<a href="#fnref6"
(<code>~</code>) to overline (U+203E).<a href="#fnref7"
class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn7"><p>ISO/IEC 646 Invariant is a subset of ASCII with 12
<li id="fn8"><p>ISO/IEC 646 Invariant is a subset of ASCII with 12
characters undefined: <code>#</code>, <code>$</code>, <code>@</code>,
<code>[</code>, <code>\</code>, <code>]</code>, <code>^</code>,
<code>`</code>, <code>{</code>, <code>|</code>, <code>}</code>,
<code>~</code> (tilde).<a href="#fnref7" class="footnote-back"
<code>~</code> (tilde).<a href="#fnref8" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn8"><p>BARCODE_MEMORY_FILE textual formats EPS and SVG will
<li id="fn9"><p>BARCODE_MEMORY_FILE textual formats EPS and SVG will
have Unix newlines (LF) on both Windows and Unix, i.e. not CR+LF on
Windows.<a href="#fnref8" class="footnote-back"
Windows.<a href="#fnref9" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn9"><p>The <code>height</code> value is ignored for Aztec
<li id="fn10"><p>The <code>height</code> value is ignored for Aztec
(including HIBC and Aztec Rune), Code One, Data Matrix (including HIBC),
DotCode, Grid Matrix, Han Xin, MaxiCode, QR Code (including HIBC, Micro
QR, rMQR and UPNQR), and Ultracode - all of which have a fixed
width-to-height ratio (or, in the case of Code One, a fixed height).<a
href="#fnref9" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn10"><p>For Windows, <code>outfile</code> is assumed to be
UTF-8 encoded.<a href="#fnref10" class="footnote-back"
href="#fnref10" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn11"><p>For Windows, <code>outfile</code> is assumed to be
UTF-8 encoded.<a href="#fnref11" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn11"><p>The <code>BARCODE_BIND_TOP</code> flag is set by
<li id="fn12"><p>The <code>BARCODE_BIND_TOP</code> flag is set by
default for DPD - see <a href="#dpd-code">6.1.10.7 DPD Code</a>.<a
href="#fnref11" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn12"><p>The <code>BARCODE_BIND</code> flag is always set for
href="#fnref12" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn13"><p>The <code>BARCODE_BIND</code> flag is always set for
Codablock-F, Code 16K and Code 49. Special considerations apply to
ITF-14 - see <a href="#itf-14">6.1.2.6 ITF-14</a>.<a href="#fnref12"
ITF-14 - see <a href="#itf-14">6.1.2.6 ITF-14</a>.<a href="#fnref13"
class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn13"><p>Codablock-F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC
<li id="fn14"><p>Codablock-F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC
add-ons, ISBN, ITF-14, UPC-A and UPC-E have compliant quiet zones added
by default.<a href="#fnref13" class="footnote-back"
by default.<a href="#fnref14" class="footnote-back"
role="doc-backlink">↩︎</a></p></li>
<li id="fn14"><p><code>ZINT_CAP_EANUPC</code> was previously named
<li id="fn15"><p><code>ZINT_CAP_EANUPC</code> was previously named
<code>ZINT_CAP_EXTENDABLE</code>, which is still recognised.<a
href="#fnref14" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn15"><p>DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have
variable masks. Rectangular Micro QR Code has a fixed mask (4).<a
href="#fnref15" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn16"><p>Except for Japanese Postal Code, whose check character
is not truly representable in the encoded data.<a href="#fnref16"
<li id="fn16"><p>DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have
variable masks. Rectangular Micro QR Code has a fixed mask (4).<a
href="#fnref16" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn17"><p>Except for Japanese Postal Code, whose check character
is not truly representable in the encoded data.<a href="#fnref17"
class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn17"><p>The library <code>libzueci</code>, which can convert
<li id="fn18"><p>The library <code>libzueci</code>, which can convert
both to and from UTF-8 and ECI, is available at <a
href="https://sourceforge.net/projects/libzueci/">https://sourceforge.net/projects/libzueci/</a>.<a
href="#fnref17" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn18"><p><code>BARCODE_CODE128AB</code> previously used the name
<code>BARCODE_CODE128B</code>, which is still recognised.<a
href="#fnref18" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn19"><p>The DX number may be looked up in The (Modified) Big
<li id="fn19"><p><code>BARCODE_CODE128AB</code> previously used the name
<code>BARCODE_CODE128B</code>, which is still recognised.<a
href="#fnref19" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn20"><p>The DX number may be looked up in The (Modified) Big
Film Database at <a
href="https://thebigfilmdatabase.merinorus.com">https://thebigfilmdatabase.merinorus.com</a>.<a
href="#fnref19" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
href="#fnref20" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section>
</body>
+87 -69
View File
@@ -125,7 +125,7 @@ vector
## 2.1 Linux
The easiest way to configure compilation is to take advantage of the CMake
utilities. You will need to install CMake and `libpng-dev` first. For instance
utilities. You will need to install CMake, and `libpng-dev` first. For instance
on `apt` systems:
```bash
@@ -133,8 +133,9 @@ sudo apt install git cmake build-essential libpng-dev
```
If you want to take advantage of Zint Barcode Studio you will also need to have
Qt and its component `"Desktop gcc 64-bit"` installed, as well as `mesa`. For
details see `"README.linux"` in the project root directory.
Qt and its component `"Desktop gcc 64-bit"` installed, as well as `mesa`. Other
steps are required to avail of the GS1 Syntax Engine.[^1] For details see
`"README.linux"` in the project root directory.
Once you have fulfilled these requirements unzip the source code tarball or
clone the latest source
@@ -175,6 +176,12 @@ the `"frontend"` sub-directory. To run the test type
This should create numerous files in the sub-directory `"frontend/test_sh_out"`
showing the many modes of operation which are available from Zint.
[^1]: The GS1 Syntax Engine (`gs1encoders` library), which is officially
sanctioned by GS1, offers strict validation of GS1 data, including GS1 Digital
Link URIs - see "GS1 Barcode Syntax Engine" at
[https://github.com/gs1/gs1-syntax-engine](
https://github.com/gs1/gs1-syntax-engine).
## 2.2 BSD
The latest Zint CLI, `libzint` library and GUI can be installed from the `zint`
@@ -216,7 +223,7 @@ To build Zint on Windows from source, see `"win32/README"`.
## 2.4 Apple macOS
The latest Zint CLI and `libzint` can be installed using Homebrew.[^1] To
The latest Zint CLI and `libzint` can be installed using Homebrew.[^2] To
install Homebrew input the following line into the macOS terminal
```bash
@@ -234,7 +241,7 @@ brew install zint
To build from source (and install the GUI) see `"README.macos"` in the project
root directory.
[^1]: See the Homebrew website [https://brew.sh](https://brew.sh).
[^2]: See the Homebrew website [https://brew.sh](https://brew.sh).
## 2.5 Zint Tcl Backend
@@ -564,7 +571,7 @@ Sequence Equivalent
`\xNN` 0xNN Any 8-bit character where NN is hexadecimal
(00-FF)
`\uNNNN` Any 16-bit Unicode BMP[^2] character where
`\uNNNN` Any 16-bit Unicode BMP[^3] character where
NNNN is hexadecimal (0000-FFFF)
`\UNNNNNN` Any 21-bit Unicode character where NNNNNN
@@ -573,7 +580,7 @@ Sequence Equivalent
Table: {#tbl:escape_sequences tag=": Escape Sequences"}
[^2]: In Unicode contexts, BMP stands for Basic Multilingual Plane, the plane 0
[^3]: In Unicode contexts, BMP stands for Basic Multilingual Plane, the plane 0
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!
@@ -658,7 +665,7 @@ Names are treated case-insensitively by the CLI, and the `BARCODE_` prefix and
any underscores are optional.
-----------------------------------------------------------------------------
Numeric Name[^3] Barcode Name
Numeric Name[^4] Barcode Name
Value
------- -------------------------- ---------------------------------------
1 `BARCODE_CODE11` Code 11
@@ -884,7 +891,7 @@ Value
Table: {#tbl:barcode_types tag=": Barcode Types (Symbologies)"}
[^3]: The symbology names marked with an asterisk (`*`) in Table
[^4]: The symbology names marked with an asterisk (`*`) in Table
{@tbl:barcode_types} above used different names in previous versions of Zint.
These names are now deprecated but are still recognised by Zint. Those marked
with a dagger (`†`) are replacements for `BARCODE_EANX` (13), `BARCODE_EANX_CHK`
@@ -1058,7 +1065,7 @@ zint --bg=ff0000 --fg=ffffff00 ...
will give different results for PNG and SVG. Experimentation is advised!
In addition the `--nobackground` option will remove the background from all
output formats except BMP.[^4]
output formats except BMP.[^5]
The `--cmyk` option is specific to output in Encapsulated PostScript (EPS) and
TIF, and selects the CMYK colour space. Custom colours should then usually be
@@ -1066,7 +1073,7 @@ given in the comma-separated `"C,M,Y,K"` format, where `C`, `M`, `Y` and `K` are
expressed as decimal percentage values from 0 to 100. RGB values may still be
used, in which case they will be converted formulaically to CMYK approximations.
[^4]: The background is omitted for vector outputs EMF, EPS and SVG when
[^5]: The background is omitted for vector outputs EMF, EPS and SVG when
`--nobackground` is given. For raster outputs GIF, PCX, PNG and TIF, the
background's alpha channel is set to zero (fully transparent).
@@ -1193,7 +1200,7 @@ zint -b MAXICODE -d "MaxiCode (19 chars)" --scalexdimdp=0,600dpi
## 4.10 Human Readable Text (HRT) Options
For linear barcodes the text present[^5] in the output image can be removed by
For linear barcodes the text present[^6] in the output image can be removed by
using the `--notext` option. Note also that for raster output text will not be
printed for scales less than 1 (see [4.9 Adjusting Image Size (X-dimension)]).
@@ -1217,7 +1224,7 @@ for all others) can be embedded in the file for portability using the
![`zint -d "Áccent" --embedfont`](images/code128_embedfont.svg){.lin}
[^5]: For linear barcodes, Human Readable Text (HRT) is not shown for the postal
[^6]: For linear barcodes, Human Readable Text (HRT) is not shown for the postal
codes Australia Post (all variants), USPS Intelligent Mail, POSTNET and PLANET,
Brazilian CEPNet, Royal Mail 4-State Customer Code and 4-State Mailmark, Dutch
Post KIX Code, Japanese Postal Code, DAFT Code and FIM, the pharma codes
@@ -1253,7 +1260,7 @@ Grid Matrix GB 2312 (includes ASCII) N/A
Han Xin Latin-1 GB 18030 (includes ASCII)
MaxiCode Latin-1 None
MicroPDF417 Latin-1 None
Micro QR Code Latin-1 Shift JIS (includes ASCII[^6])
Micro QR Code Latin-1 Shift JIS (includes ASCII[^7])
PDF417 Latin-1 None
QR Code Latin-1 Shift JIS (see above)
rMQR Latin-1 Shift JIS (see above)
@@ -1263,7 +1270,7 @@ All others ASCII N/A
Table: {#tbl:default_character_sets tag=": Default Character Sets"}
[^6]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`)
[^7]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`)
to the yen sign (¥), and tilde (`~`) to overline (U+203E).
If Zint encounters characters which can not be encoded using the default
@@ -1273,10 +1280,12 @@ Interpretations) mechanism to encode the data if the symbology supports it - see
GS1 data can be encoded in a number of symbologies. Application Identifiers
(AIs) should be enclosed in `[square brackets]` followed by the data to be
encoded (see [6.1.10.3 GS1-128]). To encode GS1 data use the `--gs1` option.
GS1 mode is assumed (and doesn't need to be set) for GS1-128, EAN-14, GS1
DataBar and GS1 Composite symbologies but is also available for Aztec Code, Code
16K, Code 49, Code One, Data Matrix, DotCode, QR Code and Ultracode.
encoded (see [6.1.10.3 GS1-128]). GS1 Digital Link URIs are also supported. To
encode GS1 data use the `--gs1` option. Also recommended is the `--gs1strict`
option, which verifies the GS1 data. GS1 mode is assumed (and doesn't need to be
set) for GS1-128, EAN-14, GS1 DataBar and GS1 Composite symbologies but is also
available for Aztec Code, Code 16K, Code 49, Code One, Data Matrix, DotCode, QR
Code and Ultracode.
Health Industry Barcode (HIBC) data may also be encoded in the symbologies Aztec
Code, Codablock-F, Code 128, Code 39, Data Matrix, MicroPDF417, PDF417 and QR
@@ -1358,12 +1367,12 @@ ECI Code Character Encoding Scheme (ISO/IEC 8859 schemes include ASCII)
33 UTF-16LE (Low order byte first)
34 UTF-32BE (High order bytes first)
35 UTF-32LE (Low order bytes first)
170 ISO/IEC 646 Invariant[^7]
170 ISO/IEC 646 Invariant[^8]
899 8-bit binary data
Table: {#tbl:eci_codes tag=": ECI Codes"}
[^7]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined:
[^8]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined:
`#`, `$`, `@`, `[`, `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~` (tilde).
An ECI value of 0 does not encode any ECI information in the code symbol (unless
@@ -1923,10 +1932,10 @@ int main(int argc, char **argv)
```
will print the SVG output to `stdout` (the file `"mem.svg"` is not created).
This is particularly useful for the textual formats EPS and SVG,[^8] allowing
This is particularly useful for the textual formats EPS and SVG,[^9] allowing
the output to be manipulated and processed by the client.
[^8]: BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines
[^9]: BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines
(LF) on both Windows and Unix, i.e. not CR+LF on Windows.
## 5.7 Setting Options
@@ -1947,7 +1956,7 @@ Member Name Type Meaning Default Value
`height` float Symbol height in Symbol dependent
X-dimensions, excluding
fixed width-to-height
symbols.[^9]
symbols.[^10]
`scale` float Scale factor for 1.0
adjusting size of image
@@ -1997,7 +2006,7 @@ Member Name Type Meaning Default Value
`.eps`, `.pcx`, `.svg`,
`.tif` or `.txt` followed
by a terminating
`NUL`.[^10]
`NUL`.[^11]
`primary` character Primary message data for `""` (empty)
string more complex symbols,
@@ -2124,13 +2133,13 @@ Member Name Type Meaning Default Value
Table: API Structure `zint_symbol` {#tbl:api_structure_zint_symbol tag="$ $"}
[^9]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune),
[^10]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune),
Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode,
QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which
have a fixed width-to-height ratio (or, in the case of Code One, a fixed
height).
[^10]: For Windows, `outfile` is assumed to be UTF-8 encoded.
[^11]: For Windows, `outfile` is assumed to be UTF-8 encoded.
To alter these values use the syntax shown in the example below. This code has
the same result as the previous example except the output is now taller and
@@ -2302,10 +2311,10 @@ Value Effect
------------------------- ---------------------------------------------------
0 No options selected.
`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^11]
`BARCODE_BIND_TOP` Boundary bar above the symbol only.[^12]
`BARCODE_BIND` Boundary bars above and below the symbol and
between rows if stacking multiple symbols.[^12]
between rows if stacking multiple symbols.[^13]
`BARCODE_BOX` Add a box surrounding the symbol and whitespace.
@@ -2332,7 +2341,7 @@ Value Effect
Symbols in Memory (raster)].
`BARCODE_QUIET_ZONES` Add compliant quiet zones (additional to any
specified whitespace).[^13]
specified whitespace).[^14]
`BARCODE_NO_QUIET_ZONES` Disable quiet zones, notably those with defaults.
@@ -2354,13 +2363,13 @@ Value Effect
Table: API `output_options` Values {#tbl:api_output_options tag="$ $"}
[^11]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD
[^12]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD
Code].
[^12]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code
[^13]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code
49. Special considerations apply to ITF-14 - see [6.1.2.6 ITF-14].
[^13]: Codablock-F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN,
[^14]: Codablock-F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN,
ITF-14, UPC-A and UPC-E have compliant quiet zones added by default.
## 5.11 Setting the Input Mode
@@ -2370,7 +2379,7 @@ member. Valid values are shown in the table below.
------------------------------------------------------------------------------
Value Effect
------------------ ----------------------------------------------------------
---------------------- ------------------------------------------------------
`DATA_MODE` Uses full 8-bit range interpreted as binary data.
`UNICODE_MODE` Uses UTF-8 input.
@@ -2382,36 +2391,39 @@ Value Effect
`ESCAPE_MODE` Process input data for escape sequences.
`GS1PARENS_MODE` Parentheses (round brackets) used in GS1 data instead of
square brackets to delimit Application Identifiers
(parentheses in the data must be escaped and `ESCAPE_MODE`
selected).
`GS1PARENS_MODE` Parentheses (round brackets) used in GS1 data instead
of square brackets to delimit Application Identifiers
(parentheses in the data must be escaped).
`GS1NOCHECK_MODE` Do not check GS1 data for validity, i.e. suppress checks
for valid AIs and data lengths. Invalid characters (e.g.
control characters, extended ASCII characters) are still
checked for.
`GS1NOCHECK_MODE` Do not check GS1 data for validity, i.e. suppress
checks for valid AIs and data lengths. Invalid
characters (e.g. control characters, extended ASCII
characters) are still checked for.
`HEIGHTPERROW_MODE` Interpret the `height` member as per-row rather than as
overall height.
`HEIGHTPERROW_MODE` Interpret the `height` member as per-row rather than
as overall height.
`FAST_MODE` Use faster if less optimal encodation or other shortcuts
if available (affects `DATAMATRIX`, `MICROPDF417`,
`PDF417`, `QRCODE` and `UPNQR` only).
`FAST_MODE` Use faster if less optimal encodation or other
shortcuts if available (affects `DATAMATRIX`,
`MICROPDF417`, `PDF417`, `QRCODE` and `UPNQR` only).
`EXTRA_ESCAPE_MODE` Process special symbology-specific escape sequences
(`CODE128` only).
`GS1SYNTAXENGINE_MODE` Use the GS1 Syntax Engine (if available) to strictly
validate GS1 input.
------------------------------------------------------------------------------
Table: API `input_mode` Values {#tbl:api_input_mode tag="$ $"}
The default mode is `DATA_MODE`. (Note that this differs from the default for
the CLI and GUI, which is `UNICODE_MODE`.)
The default mode is `DATA_MODE` (CLI option `--binary`). (Note that this differs
from the default for the CLI and GUI, which is `UNICODE_MODE`.)
`DATA_MODE`, `UNICODE_MODE` and `GS1_MODE` are mutually exclusive, whereas
`ESCAPE_MODE`, `GS1PARENS_MODE`, `GS1NOCHECK_MODE`, `HEIGHTPERROW_MODE`,
`FAST_MODE` and `EXTRA_ESCAPE_MODE` are optional. So, for example, you can set
`FAST_MODE`, `EXTRA_ESCAPE_MODE` and `GS1SYNTAXENGINE_MODE` are optional. So,
for example, you can set
```c
my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
@@ -2436,13 +2448,19 @@ Permissible escape sequences (`ESCAPE_MODE`) are listed in Table
escape sequences are given in [6.1.10.1 Standard Code 128 (ISO 15417)]. An
example of `GS1PARENS_MODE` usage is given in section [6.1.10.3 GS1-128].
`GS1NOCHECK_MODE` is for use with legacy systems that have data that does not
conform to the current GS1 standard. Printable ASCII input is still checked for,
as is the validity of GS1 data specified without AIs (e.g. linear data for GS1
DataBar Omnidirectional/Limited/etc.). Also checked is GS1 DataBar Expanded and
GS1 Composite input that is not in the GS1 encodable character set 82 (see GS1
General Specifications Figure 7.11.1 'GS1 AI encodable character set 82'),
otherwise encodation would fail.
`GS1NOCHECK_MODE` (CLI `--gs1nocheck`) is for use with legacy systems that have
data that does not conform to the current GS1 standard. Printable ASCII input is
still checked for, as is the validity of GS1 data specified without AIs (e.g.
linear data for GS1 DataBar Omnidirectional/Limited/etc.). Also checked is GS1
DataBar Expanded and GS1 Composite input that is not in the GS1 encodable
character set 82 (see GS1 General Specifications Figure 7.11.1 'GS1 AI encodable
character set 82'), otherwise encodation would fail.
In contrast `GS1SYNTAXENGINE_MODE` (CLI `--gs1strict`) enables the use the GS1
Syntax Engine to strictly validate GS1 data, including GS1 Digital Link URIs (by
default ZINT does not validate Digital Links at all). It requires that the
`gs1encoders` library was present when Zint was built, otherwise the default
built-in validation will be used.
For `HEIGHTPERROW_MODE`, see `--heightperrow` in section [4.4 Adjusting Height].
The `height` member should be set to the desired per-row value on input (it will
@@ -2618,7 +2636,7 @@ Value Meaning
`ZINT_CAP_STACKABLE` Is the symbology stackable? Note that stacked
symbologies are not stackable.
`ZINT_CAP_EANUPC`[^14] Is the symbology EAN/UPC?
`ZINT_CAP_EANUPC`[^15] Is the symbology EAN/UPC?
`ZINT_CAP_COMPOSITE` Does the symbology support composite data? (see
[6.3 GS1 Composite Symbols (ISO 24723)] below)
@@ -2654,7 +2672,7 @@ Value Meaning
Table: {#tbl:api_cap tag=": API Capability Flags"}
[^14]: `ZINT_CAP_EANUPC` was previously named `ZINT_CAP_EXTENDABLE`, which is
[^15]: `ZINT_CAP_EANUPC` was previously named `ZINT_CAP_EXTENDABLE`, which is
still recognised.
For example:
@@ -2681,7 +2699,7 @@ On successful encodation (after using `ZBarcode_Encode()` etc.) the `option_1`,
create the barcode. This is useful for feedback if the values were left as
defaults or were overridden by Zint.
In particular for symbologies that have masks,[^15] `option_3` will contain the
In particular for symbologies that have masks,[^16] `option_3` will contain the
mask used as `(N + 1) << 8`, N being the mask. Also Aztec Code will return the
actual ECC percentage used in `option_1` as `P << 8`, where P is the integer
percentage, the low byte containing the values given in Table {@tbl:aztec_eccs}
@@ -2698,7 +2716,7 @@ being set in `raw_seg_count` - which will always be at least one.
The `source`, `length` and `eci` members of `zint_seg` will be set accordingly -
the unconverted data in `source`, the data length in `length`, and the character
set the data was converted to in `eci`. Any check characters encoded will be
included,[^16] and for GS1 data any `FNC1` separators will be represented as
included,[^17] and for GS1 data any `FNC1` separators will be represented as
`GS` (ASCII 29) characters. UPC-A and UPC-E data will be expanded to EAN-13, as
will EAN-8 but only if it has an add-on (otherwise it will remain at 8 digits),
and any add-ons will follow the 13 digits directly (no separator). GS1 Composite
@@ -2710,16 +2728,16 @@ is `DATA_MODE`, it remains in binary; otherwise it will be in UTF-8. The UTF-8
source may be converted to the character set of the corresponding `eci` member
using the two helper functions discussed next.
[^15]: DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks.
[^16]: DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks.
Rectangular Micro QR Code has a fixed mask (4).
[^16]: Except for Japanese Postal Code, whose check character is not truly
[^17]: Except for Japanese Postal Code, whose check character is not truly
representable in the encoded data.
## 5.17 UTF-8 to ECI convenience functions
As a convenience the conversion done by Zint from UTF-8 to ECIs is exposed in
two helper functions (compatible with the `libzueci`[^17] functions
two helper functions (compatible with the `libzueci`[^18] functions
`zueci_utf8_to_eci()` and `zueci_dest_len_eci()`):
@@ -2739,7 +2757,7 @@ returned in `p_dest_length`, may be smaller than the estimate given by
NUL-terminated. The destination buffer is not NUL-terminated. The obsolete ECIs
0, 1 and 2 are supported.
[^17]: The library `libzueci`, which can convert both to and from UTF-8 and ECI,
[^18]: The library `libzueci`, which can convert both to and from UTF-8 and ECI,
is available at [https://sourceforge.net/projects/libzueci/](
https://sourceforge.net/projects/libzueci/).
@@ -3315,13 +3333,13 @@ alphanumerics) are not recommended.
![`zint -b CODE128AB -d "130170X178"`](images/code128ab.svg){.lin}
It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The `BARCODE_CODE128AB`[^18] variant (symbology 60)
compresses numerical data. The `BARCODE_CODE128AB`[^19] variant (symbology 60)
suppresses Code Set C in favour of Code Sets A and B.
Note that the special extra escapes mentioned above are not available for this
variant (nor for any other).
[^18]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
[^19]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
still recognised.
#### 6.1.10.3 GS1-128
@@ -3917,7 +3935,7 @@ first and last digit are ignored, leaving a 4-digit DX Extract number in any
case, which must be in the range 16 to 2047. The second format `"NNN-NN"`
represents the DX Extract as two numbers separated by a dash (`-`), the first
number being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range
0 to 15).[^19]
0 to 15).[^20]
The optional frame number is a number in the range 0 to 63, and may have a half
frame indicator `"A"` appended. Special character sequences (with or without a
@@ -3927,7 +3945,7 @@ number 62, `"K"` or `"00"` means frame number 63, and `"F"` means frame number
A parity bit is automatically added by Zint.
[^19]: The DX number may be looked up in The (Modified) Big Film Database at
[^20]: The DX number may be looked up in The (Modified) Big Film Database at
[https://thebigfilmdatabase.merinorus.com](
https://thebigfilmdatabase.merinorus.com).
+92 -70
View File
@@ -328,14 +328,15 @@ vector
2.1 Linux
The easiest way to configure compilation is to take advantage of the CMake
utilities. You will need to install CMake and libpng-dev first. For instance on
utilities. You will need to install CMake, and libpng-dev first. For instance on
apt systems:
sudo apt install git cmake build-essential libpng-dev
If you want to take advantage of Zint Barcode Studio you will also need to have
Qt and its component "Desktop gcc 64-bit" installed, as well as mesa. For
details see "README.linux" in the project root directory.
Qt and its component "Desktop gcc 64-bit" installed, as well as mesa. Other
steps are required to avail of the GS1 Syntax Engine.[1] For details see
"README.linux" in the project root directory.
Once you have fulfilled these requirements unzip the source code tarball or
clone the latest source
@@ -403,7 +404,7 @@ To build Zint on Windows from source, see "win32/README".
2.4 Apple macOS
The latest Zint CLI and libzint can be installed using Homebrew.[1] To install
The latest Zint CLI and libzint can be installed using Homebrew.[2] To install
Homebrew input the following line into the macOS terminal
/bin/bash -c "$(curl -fsSL \
@@ -719,7 +720,7 @@ sequences are shown in the table below.
\xNN 0xNN Any 8-bit character where NN is hexadecimal
(00-FF)
\uNNNN Any 16-bit Unicode BMP[2] character where
\uNNNN Any 16-bit Unicode BMP[3] character where
NNNN is hexadecimal (0000-FFFF)
\UNNNNNN Any 21-bit Unicode character where NNNNNN is
@@ -797,7 +798,7 @@ Names are treated case-insensitively by the CLI, and the BARCODE_ prefix and any
underscores are optional.
-----------------------------------------------------------------------------
Numeric Name[3] Barcode Name
Numeric Name[4] Barcode Name
Value
--------- --------------------------- ---------------------------------------
1 BARCODE_CODE11 Code 11
@@ -1164,7 +1165,7 @@ transparent foreground. For instance
will give different results for PNG and SVG. Experimentation is advised!
In addition the --nobackground option will remove the background from all output
formats except BMP.[4]
formats except BMP.[5]
The --cmyk option is specific to output in Encapsulated PostScript (EPS) and
TIF, and selects the CMYK colour space. Custom colours should then usually be
@@ -1283,7 +1284,7 @@ MaxiCode symbols have fixed size ranges of 24.82mm to 27.93mm in width, and
4.10 Human Readable Text (HRT) Options
For linear barcodes the text present[5] in the output image can be removed by
For linear barcodes the text present[6] in the output image can be removed by
using the --notext option. Note also that for raster output text will not be
printed for scales less than 1 (see 4.9 Adjusting Image Size (X-dimension)).
@@ -1335,7 +1336,7 @@ Latin-2 (ISO/IEC 8859-2 plus ASCII).
Han Xin Latin-1 GB 18030 (includes ASCII)
MaxiCode Latin-1 None
MicroPDF417 Latin-1 None
Micro QR Code Latin-1 Shift JIS (includes ASCII[6])
Micro QR Code Latin-1 Shift JIS (includes ASCII[7])
PDF417 Latin-1 None
QR Code Latin-1 Shift JIS (see above)
rMQR Latin-1 Shift JIS (see above)
@@ -1352,10 +1353,12 @@ Interpretations) mechanism to encode the data if the symbology supports it - see
GS1 data can be encoded in a number of symbologies. Application Identifiers
(AIs) should be enclosed in [square brackets] followed by the data to be encoded
(see 6.1.10.3 GS1-128). To encode GS1 data use the --gs1 option. GS1 mode is
assumed (and doesnt need to be set) for GS1-128, EAN-14, GS1 DataBar and GS1
Composite symbologies but is also available for Aztec Code, Code 16K, Code 49,
Code One, Data Matrix, DotCode, QR Code and Ultracode.
(see 6.1.10.3 GS1-128). GS1 Digital Link URIs are also supported. To encode GS1
data use the --gs1 option. Also recommended is the --gs1strict option, which
verifies the GS1 data. GS1 mode is assumed (and doesnt need to be set) for
GS1-128, EAN-14, GS1 DataBar and GS1 Composite symbologies but is also available
for Aztec Code, Code 16K, Code 49, Code One, Data Matrix, DotCode, QR Code and
Ultracode.
Health Industry Barcode (HIBC) data may also be encoded in the symbologies Aztec
Code, Codablock-F, Code 128, Code 39, Data Matrix, MicroPDF417, PDF417 and QR
@@ -1437,7 +1440,7 @@ formatted. Zint automatically translates the data into the target encoding.
33 UTF-16LE (Low order byte first)
34 UTF-32BE (High order bytes first)
35 UTF-32LE (Low order bytes first)
170 ISO/IEC 646 Invariant[7]
170 ISO/IEC 646 Invariant[8]
899 8-bit binary data
Table : ECI Codes
@@ -1945,7 +1948,7 @@ the buffer is given in memfile_size. For instance:
}
will print the SVG output to stdout (the file "mem.svg" is not created). This is
particularly useful for the textual formats EPS and SVG,[8] allowing the output
particularly useful for the textual formats EPS and SVG,[9] allowing the output
to be manipulated and processed by the client.
5.7 Setting Options
@@ -1966,7 +1969,7 @@ the following members:
height float Symbol height in Symbol dependent
X-dimensions, excluding
fixed width-to-height
symbols.[9]
symbols.[10]
scale float Scale factor for adjusting 1.0
size of image (sets
@@ -2013,7 +2016,7 @@ the following members:
end in .png, .gif, .bmp,
.emf, .eps, .pcx, .svg,
.tif or .txt followed by a
terminating NUL.[10]
terminating NUL.[11]
primary character Primary message data for "" (empty)
string more complex symbols, with
@@ -2292,10 +2295,10 @@ together when adjusting this value:
-------------------------- ---------------------------------------------------
0 No options selected.
BARCODE_BIND_TOP Boundary bar above the symbol only.[11]
BARCODE_BIND_TOP Boundary bar above the symbol only.[12]
BARCODE_BIND Boundary bars above and below the symbol and
between rows if stacking multiple symbols.[12]
between rows if stacking multiple symbols.[13]
BARCODE_BOX Add a box surrounding the symbol and whitespace.
@@ -2322,7 +2325,7 @@ together when adjusting this value:
Symbols in Memory (raster).
BARCODE_QUIET_ZONES Add compliant quiet zones (additional to any
specified whitespace).[13]
specified whitespace).[14]
BARCODE_NO_QUIET_ZONES Disable quiet zones, notably those with defaults.
@@ -2351,46 +2354,50 @@ member. Valid values are shown in the table below.
------------------------------------------------------------------------------
Value Effect
------------------- ----------------------------------------------------------
----------------------- ------------------------------------------------------
DATA_MODE Uses full 8-bit range interpreted as binary data.
UNICODE_MODE Uses UTF-8 input.
GS1_MODE Encodes GS1 data using FNC1 characters.
The above are exclusive, the following optional and OR-ed.
The above are exclusive, the following optional and
OR-ed.
ESCAPE_MODE Process input data for escape sequences.
GS1PARENS_MODE Parentheses (round brackets) used in GS1 data instead of
square brackets to delimit Application Identifiers
(parentheses in the data must be escaped and ESCAPE_MODE
selected).
GS1PARENS_MODE Parentheses (round brackets) used in GS1 data instead
of square brackets to delimit Application Identifiers
(parentheses in the data must be escaped).
GS1NOCHECK_MODE Do not check GS1 data for validity, i.e. suppress checks
for valid AIs and data lengths. Invalid characters (e.g.
control characters, extended ASCII characters) are still
checked for.
GS1NOCHECK_MODE Do not check GS1 data for validity, i.e. suppress
checks for valid AIs and data lengths. Invalid
characters (e.g. control characters, extended ASCII
characters) are still checked for.
HEIGHTPERROW_MODE Interpret the height member as per-row rather than as
overall height.
FAST_MODE Use faster if less optimal encodation or other shortcuts
if available (affects DATAMATRIX, MICROPDF417, PDF417,
QRCODE and UPNQR only).
FAST_MODE Use faster if less optimal encodation or other
shortcuts if available (affects DATAMATRIX,
MICROPDF417, PDF417, QRCODE and UPNQR only).
EXTRA_ESCAPE_MODE Process special symbology-specific escape sequences
(CODE128 only).
GS1SYNTAXENGINE_MODE Use the GS1 Syntax Engine (if available) to strictly
validate GS1 input.
------------------------------------------------------------------------------
: Table  : API input_mode Values
The default mode is DATA_MODE. (Note that this differs from the default for the
CLI and GUI, which is UNICODE_MODE.)
The default mode is DATA_MODE (CLI option --binary). (Note that this differs
from the default for the CLI and GUI, which is UNICODE_MODE.)
DATA_MODE, UNICODE_MODE and GS1_MODE are mutually exclusive, whereas
ESCAPE_MODE, GS1PARENS_MODE, GS1NOCHECK_MODE, HEIGHTPERROW_MODE, FAST_MODE and
EXTRA_ESCAPE_MODE are optional. So, for example, you can set
ESCAPE_MODE, GS1PARENS_MODE, GS1NOCHECK_MODE, HEIGHTPERROW_MODE, FAST_MODE,
EXTRA_ESCAPE_MODE and GS1SYNTAXENGINE_MODE are optional. So, for example, you
can set
my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
@@ -2409,13 +2416,19 @@ Permissible escape sequences (ESCAPE_MODE) are listed in Table
sequences are given in 6.1.10.1 Standard Code 128 (ISO 15417). An example of
GS1PARENS_MODE usage is given in section 6.1.10.3 GS1-128.
GS1NOCHECK_MODE is for use with legacy systems that have data that does not
conform to the current GS1 standard. Printable ASCII input is still checked for,
as is the validity of GS1 data specified without AIs (e.g. linear data for GS1
DataBar Omnidirectional/Limited/etc.). Also checked is GS1 DataBar Expanded and
GS1 Composite input that is not in the GS1 encodable character set 82 (see GS1
General Specifications Figure 7.11.1 GS1 AI encodable character set 82),
otherwise encodation would fail.
GS1NOCHECK_MODE (CLI --gs1nocheck) is for use with legacy systems that have data
that does not conform to the current GS1 standard. Printable ASCII input is
still checked for, as is the validity of GS1 data specified without AIs (e.g.
linear data for GS1 DataBar Omnidirectional/Limited/etc.). Also checked is GS1
DataBar Expanded and GS1 Composite input that is not in the GS1 encodable
character set 82 (see GS1 General Specifications Figure 7.11.1 GS1 AI encodable
character set 82), otherwise encodation would fail.
In contrast GS1SYNTAXENGINE_MODE (CLI --gs1strict) enables the use the GS1
Syntax Engine to strictly validate GS1 data, including GS1 Digital Link URIs (by
default ZINT does not validate Digital Links at all). It requires that the
gs1encoders library was present when Zint was built, otherwise the default
built-in validation will be used.
For HEIGHTPERROW_MODE, see --heightperrow in section 4.4 Adjusting Height. The
height member should be set to the desired per-row value on input (it will be
@@ -2570,7 +2583,7 @@ see which are set.
ZINT_CAP_STACKABLE Is the symbology stackable? Note that stacked
symbologies are not stackable.
ZINT_CAP_EANUPC[14] Is the symbology EAN/UPC?
ZINT_CAP_EANUPC[15] Is the symbology EAN/UPC?
ZINT_CAP_COMPOSITE Does the symbology support composite data? (see
6.3 GS1 Composite Symbols (ISO 24723) below)
@@ -2628,7 +2641,7 @@ option_2 and option_3 members will be set to the values used by Zint to create
the barcode. This is useful for feedback if the values were left as defaults or
were overridden by Zint.
In particular for symbologies that have masks,[15] option_3 will contain the
In particular for symbologies that have masks,[16] option_3 will contain the
mask used as (N + 1) << 8, N being the mask. Also Aztec Code will return the
actual ECC percentage used in option_1 as P << 8, where P is the integer
percentage, the low byte containing the values given in Table
@@ -2644,7 +2657,7 @@ in raw_seg_count - which will always be at least one.
The source, length and eci members of zint_seg will be set accordingly - the
unconverted data in source, the data length in length, and the character set the
data was converted to in eci. Any check characters encoded will be included,[16]
data was converted to in eci. Any check characters encoded will be included,[17]
and for GS1 data any FNC1 separators will be represented as GS (ASCII 29)
characters. UPC-A and UPC-E data will be expanded to EAN-13, as will EAN-8 but
only if it has an add-on (otherwise it will remain at 8 digits), and any add-ons
@@ -2660,7 +2673,7 @@ two helper functions discussed next.
5.17 UTF-8 to ECI convenience functions
As a convenience the conversion done by Zint from UTF-8 to ECIs is exposed in
two helper functions (compatible with the libzueci[17] functions
two helper functions (compatible with the libzueci[18] functions
zueci_utf8_to_eci() and zueci_dest_len_eci()):
int ZBarcode_UTF8_To_ECI(int eci, const unsigned char *source, int length,
@@ -3194,7 +3207,7 @@ alphanumerics) are not recommended.
[zint -b CODE128AB -d "130170X178"]
It is sometimes advantageous to stop Code 128 from using Code Set C which
compresses numerical data. The BARCODE_CODE128AB[18] variant (symbology 60)
compresses numerical data. The BARCODE_CODE128AB[19] variant (symbology 60)
suppresses Code Set C in favour of Code Sets A and B.
Note that the special extra escapes mentioned above are not available for this
@@ -3753,7 +3766,7 @@ first and last digit are ignored, leaving a 4-digit DX Extract number in any
case, which must be in the range 16 to 2047. The second format "NNN-NN"
represents the DX Extract as two numbers separated by a dash (-), the first
number being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range
0 to 15).[19]
0 to 15).[20]
The optional frame number is a number in the range 0 to 63, and may have a half
frame indicator "A" appended. Special character sequences (with or without a
@@ -5019,7 +5032,7 @@ configured barcode is updated when the "Generate" button is pressed.
Annex D. Man Page ZINT(1)
% ZINT(1) Version 2.15.0.9 % % April 2025
% ZINT(1) Version 2.15.0.9 % % September 2025
NAME
@@ -5258,6 +5271,11 @@ OPTIONS
"[]". If the AI data contains parentheses, they must be backslashed ("\(" or
"\)") and the --esc option selected.
--gs1strict
Uses the GS1 Syntax Engine (if available) to strictly verify GS1 data.
Ignored if --gs1nocheck also given.
--gssep
For Data Matrix in GS1 mode, use GS (0x1D) as the GS1 data separator instead
@@ -5731,24 +5749,28 @@ AUTHOR
Robin Stuart robin@zint.org.uk
[1] See the Homebrew website https://brew.sh.
[1] The GS1 Syntax Engine (gs1encoders library), which is officially sanctioned
by GS1, offers strict validation of GS1 data, including GS1 Digital Link URIs -
see “GS1 Barcode Syntax Engine” at https://github.com/gs1/gs1-syntax-engine.
[2] In Unicode contexts, BMP stands for Basic Multilingual Plane, the plane 0
[2] See the Homebrew website https://brew.sh.
[3] In Unicode contexts, BMP stands for Basic Multilingual Plane, the plane 0
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!
[3] The symbology names marked with an asterisk (*) in Table
[4] The symbology names marked with an asterisk (*) in Table
: Barcode Types (Symbologies) above used different names in previous versions of
Zint. These names are now deprecated but are still recognised by Zint. Those
marked with a dagger (†) are replacements for BARCODE_EANX (13),
BARCODE_EANX_CHK (14) and BARCODE_EANX_CC (130), which are still recognised by
Zint.
[4] The background is omitted for vector outputs EMF, EPS and SVG when
[5] The background is omitted for vector outputs EMF, EPS and SVG when
--nobackground is given. For raster outputs GIF, PCX, PNG and TIF, the
backgrounds alpha channel is set to zero (fully transparent).
[5] For linear barcodes, Human Readable Text (HRT) is not shown for the postal
[6] For linear barcodes, Human Readable Text (HRT) is not shown for the postal
codes Australia Post (all variants), USPS Intelligent Mail, POSTNET and PLANET,
Brazilian CEPNet, Royal Mail 4-State Customer Code and 4-State Mailmark, Dutch
Post KIX Code, Japanese Postal Code, DAFT Code and FIM, the pharma codes
@@ -5756,46 +5778,46 @@ Pharmacode One-Track and Pharmacode Two-Track, and the specialist codes DX Film
Edge Barcode and Flattermarken. Note that HRT is never shown for stacked and
matrix barcodes.
[6] Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (\) to
[7] Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (\) to
the yen sign (¥), and tilde (~) to overline (U+203E).
[7] ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined: #,
[8] ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined: #,
$, @, [, \, ], ^, `, {, |, }, ~ (tilde).
[8] BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines (LF)
[9] BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines (LF)
on both Windows and Unix, i.e. not CR+LF on Windows.
[9] The height value is ignored for Aztec (including HIBC and Aztec Rune), Code
[10] The height value is ignored for Aztec (including HIBC and Aztec Rune), Code
One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode, QR
Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which
have a fixed width-to-height ratio (or, in the case of Code One, a fixed
height).
[10] For Windows, outfile is assumed to be UTF-8 encoded.
[11] For Windows, outfile is assumed to be UTF-8 encoded.
[11] The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD
[12] The BARCODE_BIND_TOP flag is set by default for DPD - see 6.1.10.7 DPD
Code.
[12] The BARCODE_BIND flag is always set for Codablock-F, Code 16K and Code 49.
[13] The BARCODE_BIND flag is always set for Codablock-F, Code 16K and Code 49.
Special considerations apply to ITF-14 - see 6.1.2.6 ITF-14.
[13] Codablock-F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN,
[14] Codablock-F, Code 16K, Code 49, EAN-13, EAN-8, EAN/UPC add-ons, ISBN,
ITF-14, UPC-A and UPC-E have compliant quiet zones added by default.
[14] ZINT_CAP_EANUPC was previously named ZINT_CAP_EXTENDABLE, which is still
[15] ZINT_CAP_EANUPC was previously named ZINT_CAP_EXTENDABLE, which is still
recognised.
[15] DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks.
[16] DotCode, Han Xin, Micro QR Code, QR Code and UPNQR have variable masks.
Rectangular Micro QR Code has a fixed mask (4).
[16] Except for Japanese Postal Code, whose check character is not truly
[17] Except for Japanese Postal Code, whose check character is not truly
representable in the encoded data.
[17] The library libzueci, which can convert both to and from UTF-8 and ECI, is
[18] The library libzueci, which can convert both to and from UTF-8 and ECI, is
available at https://sourceforge.net/projects/libzueci/.
[18] BARCODE_CODE128AB previously used the name BARCODE_CODE128B, which is still
[19] BARCODE_CODE128AB previously used the name BARCODE_CODE128B, which is still
recognised.
[19] The DX number may be looked up in The (Modified) Big Film Database at
[20] The DX number may be looked up in The (Modified) Big Film Database at
https://thebigfilmdatabase.merinorus.com.
+5 -1
View File
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.7.0.2
.\"
.TH "ZINT" "1" "April 2025" "Version 2.15.0.9"
.TH "ZINT" "1" "September 2025" "Version 2.15.0.9"
.SH NAME
\f[CR]zint\f[R] \- encode data as a barcode image
.SH SYNOPSIS
@@ -242,6 +242,10 @@ If the AI data contains parentheses, they must be backslashed
(\f[CR]\(dq\(rs(\(dq\f[R] or \f[CR]\(dq\(rs)\(dq\f[R]) and the
\f[CR]\-\-esc\f[R] option selected.
.TP
\f[CR]\-\-gs1strict\f[R]
Uses the GS1 Syntax Engine (if available) to strictly verify GS1 data.
Ignored if \f[CR]\-\-gs1nocheck\f[R] also given.
.TP
\f[CR]\-\-gssep\f[R]
For Data Matrix in GS1 mode, use \f[CR]GS\f[R] (0x1D) as the GS1 data
separator instead of \f[CR]FNC1\f[R].
+5 -1
View File
@@ -1,6 +1,6 @@
% ZINT(1) Version 2.15.0.9
%
% April 2025
% September 2025
# NAME
@@ -215,6 +215,10 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
: Process parentheses `"()"` as GS1 AI delimiters, rather than square brackets `"[]"`. If the AI data contains
parentheses, they must be backslashed (`"\("` or `"\)"`) and the `--esc` option selected.
`--gs1strict`
: Uses the GS1 Syntax Engine (if available) to strictly verify GS1 data. Ignored if `--gs1nocheck` also given.
`--gssep`
: For Data Matrix in GS1 mode, use `GS` (0x1D) as the GS1 data separator instead of `FNC1`.
+23 -12
View File
@@ -122,8 +122,9 @@ static void types(void) {
}
/* Output version information */
static void version(const int no_png) {
static void version(const int no_png, const int have_gs1syntaxengine) {
const char *no_png_lib = no_png ? " (no libpng)" : "";
const char *have_gs1syntaxengine_lib = !have_gs1syntaxengine ? " (no GS1 Syntax Engine)" : "";
const int zint_version = ZBarcode_Version();
const int version_major = zint_version / 10000;
const int version_minor = (zint_version % 10000) / 100;
@@ -134,20 +135,21 @@ static void version(const int no_png) {
/* This is a test release */
version_release = version_release / 10;
version_build = zint_version % 10;
printf("Zint version %d.%d.%d.%d (dev)%s\n", version_major, version_minor, version_release, version_build,
no_png_lib);
printf("Zint version %d.%d.%d.%d (dev)%s%s\n", version_major, version_minor, version_release, version_build,
no_png_lib, have_gs1syntaxengine_lib);
} else {
/* This is a stable release */
printf("Zint version %d.%d.%d%s\n", version_major, version_minor, version_release, no_png_lib);
printf("Zint version %d.%d.%d%s%s\n", version_major, version_minor, version_release, no_png_lib,
have_gs1syntaxengine_lib);
}
}
/* Output usage information */
static void usage(const int no_png) {
static void usage(const int no_png, const int have_gs1syntaxengine) {
const char *no_png_type = no_png ? "" : "/PNG";
const char *no_png_ext = no_png ? "gif" : "png";
version(no_png);
version(no_png, have_gs1syntaxengine);
/* Breaking up strings so don't get too long (i.e. 500 or so) */
printf("Encode input data in a barcode and save as BMP/EMF/EPS/GIF/PCX%s/SVG/TIF/TXT\n\n", no_png_type);
@@ -182,8 +184,11 @@ static void usage(const int no_png) {
fputs( " --fullmultibyte Use multibyte for binary/Latin (QR/Han Xin/Grid Matrix)\n"
" --gs1 Treat input as GS1 compatible data\n"
" --gs1nocheck Do not check validity of GS1 data\n"
" --gs1parens Process parentheses \"()\" as GS1 AI delimiters, not \"[]\"\n"
" --gssep Use separator GS for GS1 (Data Matrix)\n", stdout);
" --gs1parens Process parentheses \"()\" as GS1 AI delimiters, not \"[]\"\n", stdout);
if (have_gs1syntaxengine) {
fputs( " --gs1strict Use GS1 Syntax Engine to strictly validate GS1 data\n", stdout);
}
fputs( " --gssep Use separator GS for GS1 (Data Matrix)\n", stdout);
fputs( " --guarddescent=NUMBER Set height of guard bar descent in X-dims (EAN/UPC)\n"
" --guardwhitespace Add quiet zone indicators (\"<\"/\">\") to HRT (EAN/UPC)\n"
" -h, --help Display help message\n"
@@ -1454,9 +1459,10 @@ int main(int argc, char **argv) {
arg_opt *arg_opts = (arg_opt *) z_alloca(sizeof(arg_opt) * argc);
const int no_png = ZBarcode_NoPng();
const int have_gs1syntaxengine = ZBarcode_HaveGS1SyntaxEngine();
if (argc == 1) {
usage(no_png);
usage(no_png, have_gs1syntaxengine);
exit(ZINT_ERROR_INVALID_DATA);
}
@@ -1478,7 +1484,8 @@ int main(int argc, char **argv) {
OPT_CMYK, OPT_COLS, OPT_COMPLIANTHEIGHT,
OPT_DIRECT, OPT_DMISO144, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
OPT_ECI, OPT_EMBEDFONT, OPT_ESC, OPT_EXTRAESC, OPT_FAST, OPT_FG, OPT_FILETYPE, OPT_FULLMULTIBYTE,
OPT_GS1, OPT_GS1NOCHECK, OPT_GS1PARENS, OPT_GSSEP, OPT_GUARDDESCENT, OPT_GUARDWHITESPACE,
OPT_GS1, OPT_GS1NOCHECK, OPT_GS1PARENS, OPT_GS1STRICT /*GS1SYNTAXENGINE_MODE*/,
OPT_GSSEP, OPT_GUARDDESCENT, OPT_GUARDWHITESPACE,
OPT_HEIGHT, OPT_HEIGHTPERROW, OPT_INIT, OPT_MIRROR, OPT_MASK, OPT_MODE,
OPT_NOBACKGROUND, OPT_NOQUIETZONES, OPT_NOTEXT, OPT_PRIMARY, OPT_QUIETZONES,
OPT_ROTATE, OPT_ROWS, OPT_SCALE, OPT_SCALEXDIM, OPT_SCMVV, OPT_SECURE,
@@ -1523,6 +1530,7 @@ int main(int argc, char **argv) {
{"gs1", 0, 0, OPT_GS1},
{"gs1nocheck", 0, NULL, OPT_GS1NOCHECK},
{"gs1parens", 0, NULL, OPT_GS1PARENS},
{"gs1strict", 0, NULL, OPT_GS1STRICT /*GS1SYNTAXENGINE_MODE*/},
{"gssep", 0, NULL, OPT_GSSEP},
{"guarddescent", 1, NULL, OPT_GUARDDESCENT},
{"guardwhitespace", 0, NULL, OPT_GUARDWHITESPACE},
@@ -1734,6 +1742,9 @@ int main(int argc, char **argv) {
case OPT_GS1PARENS:
my_symbol->input_mode |= GS1PARENS_MODE;
break;
case OPT_GS1STRICT:
my_symbol->input_mode |= GS1SYNTAXENGINE_MODE;
break;
case OPT_GSSEP:
my_symbol->output_options |= GS1_GS_SEPARATOR;
break;
@@ -2023,11 +2034,11 @@ int main(int argc, char **argv) {
break;
case 'h':
usage(no_png);
usage(no_png, have_gs1syntaxengine);
help = 1;
break;
case 'v':
version(no_png);
version(no_png, have_gs1syntaxengine);
help = 1;
break;
case 't':
+21 -1
View File
@@ -229,7 +229,7 @@ void MainWindow::mac_hack_statusBars(QWidget *win, const char* name)
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags fl)
: QWidget(parent, fl), m_previewBgColor(0xF4, 0xF4, 0xF4), m_optionWidget(nullptr), m_symbology(0),
m_menu(nullptr),
m_menu(nullptr), m_chkGS1SyntaxEngine(nullptr),
m_lblHeightPerRow(nullptr), m_spnHeightPerRow(nullptr),
m_btnHeightPerRowDisable(nullptr), m_btnHeightPerRowDefault(nullptr),
m_scaleWindow(nullptr)
@@ -354,6 +354,14 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags fl)
connect(chkRInit, SIGNAL(toggled(bool)), SLOT(update_preview()));
connect(chkGS1Parens, SIGNAL(toggled(bool)), SLOT(update_preview()));
connect(chkGS1NoCheck, SIGNAL(toggled(bool)), SLOT(update_preview()));
if (m_bc.bc.haveGS1SyntaxEngine()) {
m_chkGS1SyntaxEngine = new QCheckBox(tr("GS1 St&rict"));
m_chkGS1SyntaxEngine->setToolTip(tr("Use GS1 Syntax Engine to\n"
"strictly verify GS1 data\n"
"(ignored if disabled)"));
hLayoutChks->insertWidget(-1, m_chkGS1SyntaxEngine);
connect(m_chkGS1SyntaxEngine, SIGNAL(toggled(bool)), SLOT(update_preview()));
}
connect(spnWhitespace, SIGNAL(valueChanged(int)), SLOT(update_preview()));
connect(spnVWhitespace, SIGNAL(valueChanged(int)), SLOT(update_preview()));
connect(btnMenu, SIGNAL(clicked(bool)), SLOT(menu()));
@@ -462,6 +470,9 @@ MainWindow::~MainWindow()
settings.setValue(QSL("studio/chk_rinit"), chkRInit->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/chk_gs1parens"), chkGS1Parens->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/chk_gs1nocheck"), chkGS1NoCheck->isChecked() ? 1 : 0);
if (m_chkGS1SyntaxEngine) {
settings.setValue(QSL("studio/chk_gs1syntax"), m_chkGS1SyntaxEngine->isChecked() ? 1 : 0);
}
settings.setValue(QSL("studio/appearance/autoheight"), chkAutoHeight->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/appearance/compliantheight"), chkCompliantHeight->isChecked() ? 1 : 0);
settings.setValue(QSL("studio/appearance/height"), heightb->value());
@@ -533,6 +544,9 @@ void MainWindow::load_settings(QSettings &settings)
chkRInit->setChecked(settings.value(QSL("studio/chk_rinit")).toInt() ? true : false);
chkGS1Parens->setChecked(settings.value(QSL("studio/chk_gs1parens")).toInt() ? true : false);
chkGS1NoCheck->setChecked(settings.value(QSL("studio/chk_gs1nocheck")).toInt() ? true : false);
if (m_chkGS1SyntaxEngine) {
m_chkGS1SyntaxEngine->setChecked(settings.value(QSL("studio/chk_gs1syntax")).toInt() ? true : false);
}
chkAutoHeight->setChecked(settings.value(QSL("studio/appearance/autoheight"), 1).toInt() ? true : false);
chkCompliantHeight->setChecked(
settings.value(QSL("studio/appearance/compliantheight"), 1).toInt() ? true : false);
@@ -3348,6 +3362,9 @@ void MainWindow::update_preview()
btnClearData->setEnabled(!txtData->text().isEmpty());
chkGS1Parens->setEnabled(m_bc.bc.takesGS1AIData(m_symbology) || (m_bc.bc.inputMode() & 0x07) == GS1_MODE);
chkGS1NoCheck->setEnabled(chkGS1Parens->isEnabled());
if (m_chkGS1SyntaxEngine) {
m_chkGS1SyntaxEngine->setEnabled(chkGS1Parens->isEnabled() && !chkGS1NoCheck->isChecked());
}
chkRInit->setEnabled(m_bc.bc.supportsReaderInit() && (m_bc.bc.inputMode() & 0x07) != GS1_MODE);
chkCompliantHeight->setEnabled(m_bc.bc.hasCompliantHeight());
@@ -3369,6 +3386,9 @@ void MainWindow::update_preview()
m_bc.bc.setECI(cmbECI->isEnabled() ? cmbECI->currentIndex() : 0);
m_bc.bc.setGS1Parens(chkGS1Parens->isEnabled() && chkGS1Parens->isChecked());
m_bc.bc.setGS1NoCheck(chkGS1NoCheck->isEnabled() && chkGS1NoCheck->isChecked());
if (m_chkGS1SyntaxEngine) {
m_bc.bc.setGS1SyntaxEngine(m_chkGS1SyntaxEngine->isEnabled() && m_chkGS1SyntaxEngine->isChecked());
}
m_bc.bc.setReaderInit(chkRInit->isEnabled() && chkRInit->isChecked());
m_bc.bc.setShowText(chkHRTShow->isEnabled() && chkHRTShow->isChecked());
m_bc.bc.setBorderType(btype->currentIndex());
+1
View File
@@ -216,6 +216,7 @@ private:
QGraphicsScene *scene;
int m_symbology;
QMenu *m_menu;
QCheckBox *m_chkGS1SyntaxEngine;
QShortcut *m_saveAsShortcut;
QShortcut *m_factoryResetShortcut;
QShortcut *m_openCLIShortcut;
+28 -10
View File
@@ -1,4 +1,4 @@
% win32/README 2024-01-18
% win32/README 2025-09-12
Visual Studio 2022
------------------
@@ -17,8 +17,8 @@ Make sure git and cmake are in your PATH, e.g. (your paths may differ)
set "PATH=C:\Program Files\Git\cmd;%PATH%"
set "PATH=C:\Program Files\CMake\bin;%PATH%"
Download zint, zlib and libpng by going to the directory you want to clone them
into:
Download zint, zlib, libpng and gs1encoders (GS1 Syntax Engine) by going to the
directory you want to clone them into:
cd <project-directory>
@@ -27,6 +27,7 @@ and cloning each:
git clone https://git.code.sf.net/p/zint/code zint
git clone https://git.code.sf.net/p/libpng/code lpng
git clone https://github.com/madler/zlib.git zlib
git clone https://github.com/gs1/gs1-syntax-engine
First build zlib:
@@ -42,6 +43,16 @@ and then lpng:
nmake -f scripts\makefile.vcwin32
cd ..
and then gs1encoders:
cd gs1-syntax-engine\src
msbuild /p:Configuration=Release;Platform=x86 gs1encoders.sln /t:gs1encoders
cd ..\..
and add the location of gs1encoders.dll to your path:
set "PATH=%cd%\gs1-syntax-engine\src\c-lib\build\library\Win32\Release;%PATH%"
If you now open "%cd%\zint\win32\zint.sln" with Visual Studio 2022, you
should be able to build the Release configuration for Win32.
@@ -117,16 +128,23 @@ CMake and Visual Studio
Zint can also be built using CMake with Visual Studio 2022, 2019, 2017 or 2015.
The following example uses Visual Studio 2019 to build for x86/Win32:
As above, follow the steps to build zlib and lpng.
As above, follow the steps to build zlib, lpng and gs1encoders.
CMake needs to be able to find zlib and lpng. One way to do this (requires
Administrator privileges) is to create two sub-directories in
"C:\Program Files (x86)" called "include" and "lib", and then copy
CMake needs to be able to find zlib, lpng and gs1encoders. One way to do this
(requires Administrator privileges) is to create two sub-directories in
"C:\Program Files (x86)" called "include" and "lib", and then copy:
"zlib\zlib.h", "zlib\zconf.h", "lpng\png.h", "lpng\pngconf.h" and
"lpng\pnglibconf.h" into "include", and
for %I in (zlib\zlib.h zlib\zconf.h ^
lpng\png.h lpng\pngconf.h lpng\pnglibconf.h ^
gs1-syntax-engine\src\c-lib\build\library\Win32\Release\gs1encoders.h) ^
do copy %I "C:\Program Files (x86)\include"
for %I in (zlib\zlib.lib lpng\libpng.lib ^
gs1-syntax-engine\src\c-lib\build\library\Win32\Release\gs1encoders.lib) ^
do copy %I "C:\Program Files (x86)\lib"
"zlib\zlib.lib" and "lpng\libpng.lib" into "lib".
and add the location of gs1encoders.dll to your path:
set "PATH=%cd%\gs1-syntax-engine\src\c-lib\build\library\Win32\Release;%PATH%"
This example uses Qt 5.15.2 and component "MSVC 2019 32-bit" so install them and
add to path (your path may differ):
+8 -8
View File
@@ -56,8 +56,8 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\zlib;..\..\lpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.15.0.9";BUILD_ZINT_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\zlib;..\..\lpng;..\..\gs1-syntax-engine\src\c-lib\build\library\Win32\Release;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_HAVE_GS1SE;ZINT_VERSION="2.15.0.9";BUILD_ZINT_DLL;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<ExceptionHandling />
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -76,9 +76,9 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalDependencies>libpng.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libpng.lib;zlib.lib;gs1encoders.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)zint.dll</OutputFile>
<AdditionalLibraryDirectories>..\..\lpng;..\..\zlib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\..\lpng;..\..\zlib;..\..\gs1-syntax-engine\src\c-lib\build\library\Win32\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>libcmtd.lib;msvcrt.lib;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
@@ -90,8 +90,8 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\zlib;..\..\lpng;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_VERSION="2.15.0.9";BUILD_ZINT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\zlib;..\..\lpng;..\..\gs1-syntax-engine\src\c-lib\build\library\Win32\Release;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;ZINT_HAVE_GS1SE;ZINT_VERSION="2.15.0.9";BUILD_ZINT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling />
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
@@ -109,9 +109,9 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference>
<Link>
<AdditionalDependencies>libpng.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libpng.lib;zlib.lib;gs1encoders.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)zint.dll</OutputFile>
<AdditionalLibraryDirectories>..\..\lpng;..\..\zlib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\..\lpng;..\..\zlib;..\..\gs1-syntax-engine\src\c-lib\build\library\Win32\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>