1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-07-31 02:19:50 +00:00

DATAMATRIX: add manual FNC1 support

CODE128: error on unrecognized extra escape sequences instead of
  just passing them thru;
  fix possible shifting before manual FNC1 in 2nd position
  after single alpha (otherwise won't be recognized as AIM)
  fix not removing manual FNC1 in 1st/2nd position from content
  segs (as implied by symbology identifier)
CLI: warn if both "--dmre" and "--square" given (as "--square"
  overwrites "--dmre")
common: new routines `z_isalpha()`, `z_extra_escapes()` and
  `z_ct_set_seg_extra_escapes_eci()`
library: new helper `supports_extra_escape_mode()`;
  fix some error_number dups
BWIPP: update to latest, and allow for removal of DBAR_LTD_CC RHS
  quiet zones & extra row when have add-on in EAN/UPC composites
test suite: fix BWIPP escaping
manual/man/tcl: update for DATAMATRIX manual FNC1 support
Windows: resource scripts: make more consistent (libzint, CLI, GUI)
win32/README: update with MSVC 2026
This commit is contained in:
gitlost
2026-04-18 22:55:52 +01:00
parent f9a493522f
commit 7b076717f2
30 changed files with 1650 additions and 869 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
# Copyright (C) 2009-2025 Robin Stuart <rstuart114@gmail.com>
# Copyright (C) 2009-2026 Robin Stuart <rstuart114@gmail.com>
# vim: set ts=4 sw=4 et :
cmake_minimum_required(VERSION 3.10)
+68 -30
View File
@@ -226,7 +226,7 @@ static int c128_cost(const unsigned char source[], const int length, const int i
https://github.com/bwipp/postscriptbarcode/pull/278 */
static int c128_set_values(const unsigned char source[], const int length, const int start_idx,
const char priority[C128_STATES], const char fncs[C128_MAX], const char manuals[C128_MAX],
int values[C128_VALUES_MAX], int *p_final_cset) {
int values[C128_VALUES_MAX], int *p_first_cset, int *p_final_cset) {
short (*costs)[C128_STATES] = (short (*)[C128_STATES]) z_alloca(sizeof(*costs) * length);
char (*modes)[C128_STATES] = (char (*)[C128_STATES]) z_alloca(sizeof(*modes) * length);
@@ -243,6 +243,18 @@ static int c128_set_values(const unsigned char source[], const int length, const
return costs[0][0];
}
if (p_first_cset) {
*p_first_cset = modes[0][0];
}
/* Make sure FNC1 in 2nd position after single alpha does not switch modes before FNC1 */
if (length > 1 && !fncs[0] && fncs[1] && z_isalpha(source[0])) {
const int mode = modes[0][0];
if (mode == (mode & 0x0F) && mode != modes[1][mode]) {
modes[1][mode] = mode;
}
}
/* Output codewords into `values` */
for (i = 0; i < length; i++) {
const unsigned char ch = source[i];
@@ -377,6 +389,7 @@ INTERNAL int zint_code128(struct zint_symbol *symbol, unsigned char source[], in
char priority[C128_STATES];
int values[C128_VALUES_MAX] = {0};
int glyph_count;
int first_cset;
unsigned char src_buf[C128_MAX + 1];
unsigned char *src = source;
const int ab_only = symbol->symbology == BARCODE_CODE128AB;
@@ -397,23 +410,27 @@ INTERNAL int zint_code128(struct zint_symbol *symbol, unsigned char source[], in
char manual = 0;
int j = 0;
for (i = 0; i < length; i++) {
if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^'
&& ((source[i + 2] >= '@' && source[i + 2] <= 'C') || source[i + 2] == '1'
|| source[i + 2] == '^')) {
if (source[i + 2] == '^') { /* Escape sequence '\^^' */
manuals[j] = manual;
src_buf[j++] = source[i++];
manuals[j] = manual;
src_buf[j++] = source[i++];
/* Drop second '^' */
} else if (source[i + 2] == '1') { /* FNC1 */
i += 2;
fncs[j] = have_fnc1 = 1;
manuals[j] = manual;
src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */
} else { /* Manual mode A/B/C/@ */
i += 2;
manual = source[i] == 'C' ? C128_C0 : source[i] - '@'; /* Assuming A0 = 1, B0 = 2 */
if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^') {
const unsigned char ch = source[i + 2];
if ((ch >= '@' && ch <= 'C') || ch == '1' || ch == '^') {
if (ch == '^') { /* Escape sequence '\^^' */
manuals[j] = manual;
src_buf[j++] = source[i++];
manuals[j] = manual;
src_buf[j++] = source[i++];
/* Drop second '^' */
} else if (ch == '1') { /* FNC1 */
i += 2;
fncs[j] = have_fnc1 = 1;
manuals[j] = manual;
src_buf[j++] = '\x1D'; /* Manual FNC1 dummy */
} else { /* Manual mode A/B/C/@ */
i += 2;
manual = ch == 'C' ? C128_C0 : ch - '@'; /* Assuming A0 = 1, B0 = 2 */
}
} else {
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 348, "Unrecognized extra escape \"\\^%c\"",
!z_isascii(ch) || z_iscntrl(ch) ? '?' : ch);
}
} else {
manuals[j] = manual;
@@ -468,7 +485,8 @@ INTERNAL int zint_code128(struct zint_symbol *symbol, unsigned char source[], in
}
c128_set_priority(priority, have_a, have_b, have_c, have_extended);
glyph_count = c128_set_values(src, length, start_idx, priority, fncs, manuals, values, NULL /*p_final_cset*/);
glyph_count = c128_set_values(src, length, start_idx, priority, fncs, manuals, values, &first_cset,
NULL /*p_final_cset*/);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Data (%d): %.*s", length, length >= 100 ? 1 : length >= 10 ? 2 : 3, " ");
@@ -487,6 +505,36 @@ INTERNAL int zint_code128(struct zint_symbol *symbol, unsigned char source[], in
/* ISO/IEC 15417:2007 leaves dimensions/height as application specification */
/* Do content segs before HRT to deal with manual FNC1s in 1st position & 2nd position */
if (content_segs) {
if (have_fnc1) {
int mv_idx = 0;
assert(length > 0);
/* Remove manual FNC1 in 1st position */
if (fncs[0]) {
mv_idx = 1;
/* Remove manual FNC1 in 2nd position, alphabetic */
} else if (length > 1 && fncs[1] && z_isalpha(src[0])) {
mv_idx = 2;
/* Remove manual FNC1 in 2nd position, 2 digits */
} else if (first_cset == C128_C0 && length > 2 && fncs[2] && z_isdigit(src[0]) && z_isdigit(src[1])) {
mv_idx = 3;
}
if (mv_idx) {
memmove(src + (mv_idx - 1), src + mv_idx, length - mv_idx);
memmove(fncs + (mv_idx - 1), fncs + mv_idx, length - mv_idx);
length--;
}
}
if ((symbol->input_mode & 0x07) == DATA_MODE) {
if (z_ct_cpy(symbol, src, length)) {
return ZINT_ERROR_MEMORY; /* `z_ct_cpy()` only fails with OOM */
}
} else if (z_ct_cpy_iso8859_1(symbol, src, length)) {
return ZINT_ERROR_MEMORY; /* `z_ct_cpy_iso8859_1()` only fails with OOM */
}
}
/* HRT */
if (have_fnc1) {
/* Remove any manual FNC1 dummies ('\x1D') */
@@ -500,16 +548,6 @@ INTERNAL int zint_code128(struct zint_symbol *symbol, unsigned char source[], in
}
error_number = z_hrt_cpy_iso8859_1(symbol, src, length); /* Returns warning only */
if (content_segs) {
if ((symbol->input_mode & 0x07) == DATA_MODE) {
if (z_ct_cpy(symbol, src, length)) {
return ZINT_ERROR_MEMORY; /* `z_ct_cpy()` only fails with OOM */
}
} else if (z_ct_cpy_iso8859_1(symbol, src, length)) {
return ZINT_ERROR_MEMORY; /* `z_ct_cpy_iso8859_1()` only fails with OOM */
}
}
return error_number;
}
@@ -553,7 +591,7 @@ INTERNAL int zint_gs1_128_cc(struct zint_symbol *symbol, unsigned char source[],
c128_set_priority(priority, 0 /*have_a*/, 1 /*have_b*/, 1 /*have_c*/, 0 /*have_extended*/);
glyph_count = c128_set_values(reduced, reduced_length, 1 /*start_idx*/, priority, fncs, manuals, values,
&final_cset);
NULL /*p_first_cset*/, &final_cset);
if (symbol->debug & ZINT_DEBUG_PRINT) {
printf("Data (%d): %.*s", reduced_length, reduced_length >= 100 ? 1 : reduced_length >= 10 ? 2 : 3, " ");
+79 -2
View File
@@ -776,6 +776,41 @@ INTERNAL int z_utf8_to_unicode(struct zint_symbol *symbol, const unsigned char s
return 0;
}
/* Process `source` for manual FNC1 extra escape sequences, placing result in `dest` with result length in `p_len`,
and setting `fncs` with found FNC1s. `dest` & `fncs` must be at least `length` in size. `eci` is checked to be
ASCII-compatible (UTF-8 & single-byte ECIs, excl. Binary 899). On error sets `errtxt` & returns error no. */
INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int eci, unsigned char dest[], char *fncs, int *p_len) {
int i, j = 0;
if (eci == 20 || eci == 25 || eci >= 28) {
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 716, "Extra escape mode requires ASCII-compatible ECI");
}
for (i = 0; i < length; i++) {
if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^') {
const unsigned char ch = source[i + 2];
if (ch == '1' || ch == '^') {
if (ch == '^') { /* Escape sequence '\^^' */
dest[j++] = source[i++];
dest[j++] = source[i++];
/* Drop second '^' */
} else { /* ch == '1' FNC1 */
i += 2;
fncs[j] = 1;
dest[j++] = '\x1D'; /* Manual FNC1 dummy */
}
} else {
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 717, "Unrecognized extra escape \"\\^%c\"",
!z_isascii(ch) || z_iscntrl(ch) ? '?' : ch);
}
} else {
dest[j++] = source[i];
}
}
*p_len = j;
return 0;
}
/* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and
non-ISO/IEC 8859-1 (0x80-9F) are replaced with spaces. Returns warning if truncated, else 0 */
INTERNAL int z_hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char source[], const int length) {
@@ -988,10 +1023,52 @@ INTERNAL int z_ct_cpy_segs(struct zint_symbol *symbol, const struct zint_seg seg
return 0;
}
/* Update the ECI of content seg `seg_idx` to `eci`, to reflect (feedback) the actual ECI used */
INTERNAL void z_ct_set_seg_eci(struct zint_symbol *symbol, const int seg_idx, const int eci) {
/* Process content seg `seg_idx` buffer for manual FNC1 extra escape sequences (which must exist),
and update its ECI to `eci`, if set, to reflect (feedback) the actual ECI used */
INTERNAL void z_ct_set_seg_extra_escapes_eci(struct zint_symbol *symbol, const int seg_idx, const int eci) {
int i, j = 0;
unsigned char *source;
int length;
const int no_fnc1_position_check = seg_idx != 0 || eci != 0;
assert(symbol->content_segs);
assert(seg_idx >= 0 && seg_idx < symbol->content_seg_count);
assert(symbol->content_segs[seg_idx].source);
source = symbol->content_segs[seg_idx].source;
length = symbol->content_segs[seg_idx].length;
for (i = 0; i < length; i++) {
if (source[i] == '\\' && i + 2 < length && source[i + 1] == '^'
&& (source[i + 2] == '1' || source[i + 2] == '^')) {
if (source[i + 2] == '^') { /* Escape sequence '\^^' */
source[j++] = source[i++];
source[j++] = source[i++];
/* Drop second '^' */
} else { /* source[i + 2] == '1' FNC1 */
/* Do not emit <GS> if FNC1 in 1st/2nd position */
if (no_fnc1_position_check || j > 2 || (j == 1 && !z_isalpha(source[0]))
|| (j == 2 && (!z_isdigit(source[0]) || !z_isdigit(source[1]))) ) {
source[j++] = '\x1D'; /* GS */
}
i += 2;
}
} else {
source[j++] = source[i];
}
}
assert(j > 0 && j < length);
symbol->content_segs[seg_idx].length = j;
if (eci) {
symbol->content_segs[seg_idx].eci = eci;
}
}
/* Update the ECI of content seg `seg_idx` to `eci`, to reflect (feedback) the actual ECI used */
INTERNAL void z_ct_set_seg_eci(struct zint_symbol *symbol, const int seg_idx, const int eci) {
assert(seg_idx >= 0 && seg_idx < symbol->content_seg_count);
assert(eci);
assert(symbol->content_segs);
symbol->content_segs[seg_idx].eci = eci;
}
+12
View File
@@ -140,6 +140,7 @@ typedef unsigned __int64 uint64_t;
#define z_isdigit(ch) ((ch) <= '9' && (ch) >= '0')
#define z_isupper(ch) ((ch) >= 'A' && (ch) <= 'Z')
#define z_islower(ch) ((ch) >= 'a' && (ch) <= 'z')
#define z_isalpha(ch) (z_isupper(ch) || z_islower(ch))
#define z_isascii(ch) (!((ch) & ~0x7F))
#define z_iscntrl(ch) (!((ch) & ~0x1F) || (ch) == 127)
@@ -307,6 +308,13 @@ INTERNAL int z_utf8_to_unicode(struct zint_symbol *symbol, const unsigned char s
int *length, const int disallow_4byte);
/* Process `source` for manual FNC1 extra escape sequences, placing result in `dest` with result length in `p_len`,
and setting `fncs` with found FNC1s. `dest` & `fncs` must be at least `length` in size. `eci` is checked to be
ASCII-compatible (UTF-8 & single-byte ECIs, excl. Binary 899). On error sets `errtxt` & returns error no. */
INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int eci, unsigned char dest[], char *fncs, int *p_len);
/* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and
non-ISO/IEC 8859-1 (0x80-9F) are replaced with spaces. Returns warning if truncated, else 0 */
INTERNAL int z_hrt_cpy_iso8859_1(struct zint_symbol *symbol, const unsigned char source[], const int length);
@@ -346,6 +354,10 @@ INTERNAL void z_ct_free_segs(struct zint_symbol *symbol);
If seg eci not set, content seg eci set to 3. On error sets `errxtxt`, returning BARCODE_ERROR_MEMORY */
INTERNAL int z_ct_cpy_segs(struct zint_symbol *symbol, const struct zint_seg segs[], const int seg_count);
/* Process content seg `seg_idx` buffer for manual FNC1 extra escape sequences (which must exist),
and update its ECI to `eci`, if set, to reflect (feedback) the actual ECI used */
INTERNAL void z_ct_set_seg_extra_escapes_eci(struct zint_symbol *symbol, const int seg_idx, const int eci);
/* Update the ECI of content seg `seg_idx` to `eci`, to reflect (feedback) the actual ECI used */
INTERNAL void z_ct_set_seg_eci(struct zint_symbol *symbol, const int seg_idx, const int eci);
+100 -82
View File
@@ -282,7 +282,7 @@ static int dm_text_sp_cnt(const unsigned char source[], const int position, cons
/* 'look ahead test' from Annex J */
static int dm_look_ahead_test(const unsigned char source[], const int length, const int position,
const int current_mode, const int mode_arg, const int gs1, const int debug_print) {
const int current_mode, const int mode_arg, const char *fncs, const int debug_print) {
int ascii_count, c40_count, text_count, x12_count, edf_count, b256_count;
int ascii_rnded, c40_rnded, text_rnded, x12_rnded, edf_rnded, b256_rnded;
int cnt_1;
@@ -316,11 +316,11 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
}
for (sp = position; sp < length; sp++) {
const unsigned char c = source[sp];
const int is_extended = c & 0x80;
const unsigned char ch = source[sp];
const int is_extended = ch & 0x80;
/* ASCII ... step (l) */
if (z_isdigit(c)) {
if (z_isdigit(ch)) {
ascii_count += DM_MULT_1_DIV_2; /* (l)(1) */
} else {
if (is_extended) {
@@ -331,7 +331,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
}
/* C40 ... step (m) */
if (dm_isc40(c)) {
if (dm_isc40(ch)) {
c40_count += DM_MULT_2_DIV_3; /* (m)(1) */
} else {
if (is_extended) {
@@ -342,7 +342,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
}
/* TEXT ... step (n) */
if (dm_istext(c)) {
if (dm_istext(ch)) {
text_count += DM_MULT_2_DIV_3; /* (n)(1) */
} else {
if (is_extended) {
@@ -353,7 +353,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
}
/* X12 ... step (o) */
if (dm_isX12(c)) {
if (dm_isX12(ch)) {
x12_count += DM_MULT_2_DIV_3; /* (o)(1) */
} else {
if (is_extended) {
@@ -364,7 +364,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
}
/* EDIFACT ... step (p) */
if (dm_isedifact(c)) {
if (dm_isedifact(ch)) {
edf_count += DM_MULT_3_DIV_4; /* (p)(1) */
} else {
if (is_extended) {
@@ -375,7 +375,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
}
/* Base 256 ... step (q) */
if (gs1 == 1 && c == '\x1D') {
if (fncs[sp] && ch == '\x1D') {
/* FNC1 separator */
b256_count += DM_MULT_4; /* (q)(1) */
} else {
@@ -615,10 +615,10 @@ static int dm_codewords_remaining(struct zint_symbol *symbol, const int tp, cons
}
/* Number of C40/TEXT elements needed to encode `input` */
static int dm_c40text_cnt(const int current_mode, const int gs1, unsigned char input) {
static int dm_c40text_cnt(const int current_mode, const char fnc, unsigned char input) {
int cnt;
if (gs1 && input == '\x1D') {
if (fnc && input == '\x1D') {
return 2;
}
cnt = 1;
@@ -933,7 +933,7 @@ static void dm_addEdge(struct zint_symbol *symbol, const unsigned char *source,
/* Add edges for the various modes at a vertex */
static void dm_addEdges(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int last_seg, struct dm_edge *edges, const int from, struct dm_edge *previous, const int gs1) {
const int last_seg, struct dm_edge *edges, const int from, struct dm_edge *previous, const char *fncs) {
int i, pos;
assert(from < length); /* Suppress clang-tidy-21 clang-analyzer-security.ArrayBound */
@@ -965,7 +965,7 @@ static void dm_addEdges(struct zint_symbol *symbol, const unsigned char source[]
dm_addEdge(symbol, source, length, last_seg, edges, DM_X12, from, 3, previous, 0);
}
if (gs1 != 1 || source[from] != '\x1D') {
if (!fncs[from] || source[from] != '\x1D') {
dm_addEdge(symbol, source, length, last_seg, edges, DM_BASE256, from, 1, previous, 0);
}
}
@@ -981,7 +981,7 @@ static void dm_addEdges(struct zint_symbol *symbol, const unsigned char source[]
/* Calculate optimized encoding modes */
static int dm_define_modes(struct zint_symbol *symbol, char modes[], const unsigned char source[], const int length,
const int last_seg, const int gs1, const int debug_print) {
const int last_seg, const char *fncs, const int debug_print) {
int i, j, v_i;
int minimalJ, minimalSize;
@@ -995,7 +995,7 @@ static int dm_define_modes(struct zint_symbol *symbol, char modes[], const unsig
}
assert((length + 1) * DM_NUM_MODES < USHRT_MAX); /* Guaranteed by input length limit */
dm_addEdges(symbol, source, length, last_seg, edges, 0, NULL, gs1);
dm_addEdges(symbol, source, length, last_seg, edges, 0, NULL, fncs);
DM_TRACE_Edges("DEBUG Initial situation\n", source, length, edges, 0);
@@ -1003,7 +1003,7 @@ static int dm_define_modes(struct zint_symbol *symbol, char modes[], const unsig
v_i = i * DM_NUM_MODES;
for (j = 0; j < DM_NUM_MODES; j++) {
if (edges[v_i + j].mode) {
dm_addEdges(symbol, source, length, last_seg, edges, i, edges + v_i + j, gs1);
dm_addEdges(symbol, source, length, last_seg, edges, i, edges + v_i + j, fncs);
}
}
DM_TRACE_Edges("DEBUG situation after adding edges to vertices at position %d\n", source, length, edges, i);
@@ -1060,7 +1060,7 @@ static int dm_define_modes(struct zint_symbol *symbol, char modes[], const unsig
/* Do default minimal encodation */
static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int last_seg, int *p_sp, unsigned char target[], int *p_tp, int process_buffer[8], int *p_process_p,
int *p_b256_start, int *p_current_mode, const int gs1, const int debug_print) {
int *p_b256_start, int *p_current_mode, const char *fncs, const int debug_print) {
int sp = *p_sp;
int tp = *p_tp;
int process_p = *p_process_p;
@@ -1070,7 +1070,7 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
assert(length <= 10921); /* Can only handle (10921 + 1) * 6 = 65532 < 65536 (2*16) due to sizeof(previous) */
if (!dm_define_modes(symbol, modes, source, length, last_seg, gs1, debug_print)) {
if (!dm_define_modes(symbol, modes, source, length, last_seg, fncs, debug_print)) {
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 728, "Insufficient memory for mode buffers");
}
@@ -1129,14 +1129,9 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
target[tp++] = (source[sp] - 128) + 1;
if (debug_print) printf("FN4 A%02X ", target[tp - 1] - 1);
} else {
if (gs1 && source[sp] == '\x1D') {
if (gs1 == 2) {
target[tp++] = 29 + 1; /* GS */
if (debug_print) fputs("GS ", stdout);
} else {
target[tp++] = 232; /* FNC1 */
if (debug_print) fputs("FN1 ", stdout);
}
if (fncs[sp] && source[sp] == '\x1D') {
target[tp++] = 232; /* FNC1 */
if (debug_print) fputs("FN1 ", stdout);
} else {
target[tp++] = source[sp] + 1;
if (debug_print) printf("A%02X ", target[tp - 1] - 1);
@@ -1164,14 +1159,9 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
shift_set = ct_shift[source[sp] - 128];
value = ct_value[source[sp] - 128];
} else {
if (gs1 && source[sp] == '\x1D') {
if (gs1 == 2) {
shift_set = ct_shift[29];
value = ct_value[29]; /* GS */
} else {
shift_set = 2;
value = 27; /* FNC1 */
}
if (fncs[sp] && source[sp] == '\x1D') {
shift_set = 2;
value = 27; /* FNC1 */
} else {
shift_set = ct_shift[source[sp]];
value = ct_value[source[sp]];
@@ -1247,7 +1237,7 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
/* Encode using algorithm based on ISO/IEC 21471:2020 Annex J (was ISO/IEC 21471:2006 Annex P) */
static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], const int length, int *p_sp,
unsigned char target[], int *p_tp, int process_buffer[8], int *p_process_p, int *p_b256_start,
int *p_current_mode, const int gs1, const int b256_end, const int c40_end, const int debug_print) {
int *p_current_mode, const char *fncs, const int b256_end, const int c40_end, const int debug_print) {
int sp = *p_sp;
int tp = *p_tp;
int process_p = *p_process_p;
@@ -1284,7 +1274,7 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
if (debug_print) printf("N%02d ", target[tp - 1] - 130);
sp += 2;
} else {
next_mode = dm_look_ahead_test(source, length, sp, current_mode, 0, gs1, debug_print);
next_mode = dm_look_ahead_test(source, length, sp, current_mode, 0, fncs, debug_print);
if (next_mode != DM_ASCII) {
tp = dm_switch_mode(next_mode, target, tp, p_b256_start, debug_print);
@@ -1295,14 +1285,9 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
target[tp++] = (source[sp] - 128) + 1;
if (debug_print) printf("FN4 A%02X ", target[tp - 1] - 1);
} else {
if (gs1 && source[sp] == '\x1D') {
if (gs1 == 2) {
target[tp++] = 29 + 1; /* GS */
if (debug_print) fputs("GS ", stdout);
} else {
target[tp++] = 232; /* FNC1 */
if (debug_print) fputs("FN1 ", stdout);
}
if (fncs[sp] && source[sp] == '\x1D') {
target[tp++] = 232; /* FNC1 */
if (debug_print) fputs("FN1 ", stdout);
} else {
target[tp++] = source[sp] + 1;
if (debug_print) printf("A%02X ", target[tp - 1] - 1);
@@ -1317,7 +1302,7 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
next_mode = current_mode;
if (process_p == 0 && not_first && (sp >= c40_end)) { /* `c40_end` only set if `current_mode` DM_C40 */
next_mode = dm_look_ahead_test(source, length, sp, current_mode, process_p, gs1, debug_print);
next_mode = dm_look_ahead_test(source, length, sp, current_mode, process_p, fncs, debug_print);
}
if (next_mode != current_mode) {
@@ -1342,14 +1327,9 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
shift_set = ct_shift[source[sp] - 128];
value = ct_value[source[sp] - 128];
} else {
if (gs1 && source[sp] == '\x1D') {
if (gs1 == 2) {
shift_set = ct_shift[29];
value = ct_value[29]; /* GS */
} else {
shift_set = 2;
value = 27; /* FNC1 */
}
if (fncs[sp] && source[sp] == '\x1D') {
shift_set = 2;
value = 27; /* FNC1 */
} else {
shift_set = ct_shift[source[sp]];
value = ct_value[source[sp]];
@@ -1376,7 +1356,7 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
} else {
next_mode = DM_X12;
if (process_p == 0 && not_first) {
next_mode = dm_look_ahead_test(source, length, sp, current_mode, process_p, gs1, debug_print);
next_mode = dm_look_ahead_test(source, length, sp, current_mode, process_p, fncs, debug_print);
}
}
@@ -1417,7 +1397,7 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
if (process_p == 3) {
/* Note different than spec Step (f)(2), which suggests checking when 0, but this seems to
work better in many cases as the switch to ASCII is "free" */
next_mode = dm_look_ahead_test(source, length, sp, current_mode, process_p, gs1, debug_print);
next_mode = dm_look_ahead_test(source, length, sp, current_mode, process_p, fncs, debug_print);
}
}
@@ -1446,12 +1426,12 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
/* step (g) Base 256 encodation */
} else if (current_mode == DM_BASE256) {
if (gs1 == 1 && source[sp] == '\x1D') {
if (fncs[sp] && source[sp] == '\x1D') {
next_mode = DM_ASCII;
} else {
next_mode = DM_BASE256;
if (not_first && sp >= b256_end) {
next_mode = dm_look_ahead_test(source, length, sp, current_mode, tp - (*p_b256_start + 1), gs1,
next_mode = dm_look_ahead_test(source, length, sp, current_mode, tp - (*p_b256_start + 1), fncs,
debug_print);
}
}
@@ -1490,8 +1470,8 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
/* Encodes data using ASCII, C40, Text, X12, EDIFACT or Base 256 modes as appropriate
Supports encoding FNC1 in supporting systems */
static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int eci, const int last_seg, const int gs1, const int b256_end, const int c40_end,
static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], int length,
const int eci, const int last_seg, const char *fncs, const int b256_end, const int c40_end,
unsigned char target[], int *p_tp) {
int sp = 0;
int tp = *p_tp;
@@ -1520,13 +1500,14 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
if (debug_print) printf("ECI %d ", eci + 1);
}
/* If FAST_MODE or MAILMARK_2D, do Annex J-based encodation */
if ((symbol->input_mode & FAST_MODE) || b256_end || c40_end) {
error_number = dm_isoenc(symbol, source, length, &sp, target, &tp, process_buffer, &process_p,
&b256_start, &current_mode, gs1, b256_end, c40_end, debug_print);
&b256_start, &current_mode, fncs, b256_end, c40_end, debug_print);
} else { /* Do default minimal encodation */
error_number = dm_minimalenc(symbol, source, length, last_seg, &sp, target, &tp, process_buffer, &process_p,
&b256_start, &current_mode, gs1, debug_print);
&b256_start, &current_mode, fncs, debug_print);
}
if (error_number) {
assert(error_number >= ZINT_ERROR);
@@ -1571,7 +1552,7 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
/* Backtrack to last complete triplet (same technique as BWIPP) */
while (sp > 0 && process_p % 3) {
sp--;
cnt = dm_c40text_cnt(current_mode, gs1, source[sp]);
cnt = dm_c40text_cnt(current_mode, fncs[sp], source[sp]);
total_cnt += cnt;
process_p -= cnt;
}
@@ -1588,14 +1569,9 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
target[tp++] = 235; /* FNC4 */
target[tp++] = (source[sp] - 128) + 1;
if (debug_print) printf("FN4 A%02X ", target[tp - 1] - 1);
} else if (gs1 && source[sp] == '\x1D') {
if (gs1 == 2) {
target[tp++] = 29 + 1; /* GS */
if (debug_print) fputs("GS ", stdout);
} else {
target[tp++] = 232; /* FNC1 */
if (debug_print) fputs("FN1 ", stdout);
}
} else if (fncs[sp] && source[sp] == '\x1D') {
target[tp++] = 232; /* FNC1 */
if (debug_print) fputs("FN1 ", stdout);
} else {
target[tp++] = source[sp] + 1;
if (debug_print) printf("A%02X ", target[tp - 1] - 1);
@@ -1670,10 +1646,10 @@ static int dm_encode(struct zint_symbol *symbol, const unsigned char source[], c
}
#ifdef ZINT_TEST /* Wrapper for direct testing */
INTERNAL int zint_test_dm_encode(struct zint_symbol *symbol, const unsigned char source[], const int length,
const int eci, const int last_seg, const int gs1, const int b256_end, const int c40_end,
INTERNAL int zint_test_dm_encode(struct zint_symbol *symbol, const unsigned char source[], int length,
const int eci, const int last_seg, const char *fncs, const int b256_end, const int c40_end,
unsigned char target[], int *p_tp) {
return dm_encode(symbol, source, length, eci, last_seg, gs1, b256_end, c40_end, target, p_tp);
return dm_encode(symbol, source, length, eci, last_seg, fncs, b256_end, c40_end, target, p_tp);
}
#endif
@@ -1685,10 +1661,12 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
int i;
int tp = 0;
int in_macro = 0;
int have_extra_escapes = 0;
int tot_length = 0, b256_have_fnc1 = 0;
const struct zint_seg *last_seg = &segs[seg_count - 1];
/* gs1 flag values: 0: no GS1, 1: GS1 with FNC1 serparator, 2: GS separator */
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE ? 1 + !!(symbol->output_options & GS1_GS_SEPARATOR) : 0;
const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE;
const int mailmark = symbol->symbology == BARCODE_MAILMARK_2D;
const int have_c40 = (symbol->option_3 & DM_C40_START) && symbol->option_1 >= 0;
const int have_b256 = (symbol->option_3 & DM_B256_START) && symbol->option_1 >= 0;
@@ -1757,6 +1735,14 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
target[tp++] = id2;
}
if (extra_escape_mode && (symbol->symbology != BARCODE_DATAMATRIX || gs1)) {
if (symbol->symbology != BARCODE_DATAMATRIX) {
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 843,
"Can only use extra escape mode with non-variant Data Matrix");
}
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 844, "Cannot use extra escape mode in GS1 mode");
}
if (gs1) {
target[tp++] = 232;
if (debug_print) fputs("FN1 ", stdout);
@@ -1799,6 +1785,8 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
for (i = 0; i < seg_count; i++) {
const unsigned char *source;
unsigned char *src_buf;
char *fncs;
int length;
int src_inc = 0, len_dec = 0;
int b256_end = 0, c40_end = 0;
@@ -1813,6 +1801,29 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
source = segs[i].source + src_inc;
length = segs[i].length - len_dec;
src_buf = (unsigned char *) z_alloca(length + 1);
fncs = (char *) z_alloca(length);
if (gs1) {
memset(fncs, gs1 == 1, length);
} else {
memset(fncs, 0, length);
if (extra_escape_mode) {
int len;
if ((error_number = z_extra_escapes(symbol, source, length, segs[i].eci, src_buf, fncs, &len))) {
return error_number;
}
if (len != length) {
assert(len < length);
length = len;
assert(length > 0);
src_buf[length] = '\0';
source = src_buf;
have_extra_escapes = 1;
}
}
}
if (mailmark) {
assert(seg_count == 1);
assert(length >= 45);
@@ -1834,6 +1845,7 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
if (b256_have_fnc1) {
b256_end = 0;
} else {
int b256_len;
if (symbol->option_1 == 0) {
b256_end = length;
} else if (symbol->option_1 < tot_length) {
@@ -1841,21 +1853,27 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
} else {
b256_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length;
}
if (gs1 == 1) {
/* Stop at first FNC1 */
const int b256_len = b256_end;
for (b256_end = 0; b256_end < b256_len && source[b256_end] != '\x1D'; b256_end++);
b256_have_fnc1 = b256_end != b256_len;
/* Stop at first FNC1 */
b256_len = b256_end;
for (b256_end = 0; b256_end < b256_len; b256_end++) {
if (fncs[b256_end] && source[b256_end] == '\x1D') {
break;
}
}
b256_have_fnc1 = b256_end != b256_len;
}
}
if ((error_number = dm_encode(symbol, source, length, segs[i].eci, i + 1 == seg_count, gs1, b256_end, c40_end,
target, &tp))) {
if ((error_number = dm_encode(symbol, source, length, segs[i].eci, i + 1 == seg_count, fncs, b256_end,
c40_end, target, &tp))) {
assert(error_number >= ZINT_ERROR);
return error_number;
}
if (content_segs && segs[i].eci) {
z_ct_set_seg_eci(symbol, i, segs[i].eci);
if (content_segs) {
if (have_extra_escapes) {
z_ct_set_seg_extra_escapes_eci(symbol, i, segs[i].eci);
} else if (segs[i].eci) {
z_ct_set_seg_eci(symbol, i, segs[i].eci);
}
}
tot_length += length;
}
+23 -11
View File
@@ -366,6 +366,12 @@ static int supports_non_iso8859_1(const int symbology) {
return 0;
}
/* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE */
static int supports_extra_escape_mode(const struct zint_symbol *const symbol) {
return symbol->symbology == BARCODE_CODE128
|| (symbol->symbology == BARCODE_DATAMATRIX && (symbol->input_mode & 0x07) != GS1_MODE);
}
/* Returns 1 if symbology supports HRT */
static int has_hrt(const int symbology) {
@@ -720,7 +726,8 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
int val;
int i;
unsigned int unicode;
const int extra_escape_mode = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128;
const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE;
const int can_extra_escape = supports_extra_escape_mode(symbol);
const int escape_parens = (symbol->input_mode & GS1PARENS_MODE)
&& ((symbol->input_mode & 0x07) == GS1_MODE || check_force_gs1(symbol->symbology));
@@ -748,10 +755,14 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
if (escaped_string) escaped_string[out_posn] = vals[z_posn(escs, ch)];
in_posn += 2;
break;
case '^': /* CODE128 specific */
if (!extra_escape_mode) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 798,
"Escape '\\^' only valid for Code 128 in extra escape mode");
case '^': /* Symbology specific */
if (!extra_escape_mode || !can_extra_escape) {
if (!extra_escape_mode) {
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 798,
"Escape '\\^' only valid in extra escape mode");
}
return z_errtxt(ZINT_ERROR_INVALID_DATA, symbol, 213,
"Extra escape '\\^' not valid for this symbology and/or input mode");
}
/* Pass thru unaltered */
if (escaped_string) {
@@ -814,7 +825,7 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
}
/* Exclude reversed BOM and surrogates and out-of-range */
if (unicode == 0xFFFE || (unicode >= 0xD800 && unicode < 0xE000) || unicode > 0x10FFFF) {
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 246,
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 216,
"Value of escape sequence '%.*s' in input out of range",
ch == 'u' ? 6 : 8, input_string + in_posn);
}
@@ -849,7 +860,8 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
break;
default:
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 234,
"Unrecognised escape character '\\%c' in input", ch);
"Unrecognised escape character '\\%c' in input",
!z_isascii(ch) || z_iscntrl(ch) ? '?' : ch);
break;
}
} else {
@@ -991,7 +1003,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
escape_mode = (symbol->input_mode & ESCAPE_MODE)
|| ((symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128);
|| ((symbol->input_mode & EXTRA_ESCAPE_MODE) && supports_extra_escape_mode(symbol));
content_segs = symbol->output_options & BARCODE_CONTENT_SEGS;
local_segs = (struct zint_seg *) z_alloca(sizeof(struct zint_seg) * (seg_count > 0 ? seg_count : 1));
@@ -1074,7 +1086,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
if (total_len > ZINT_MAX_DATA_LEN) {
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 243, "Input too long");
return error_tag(ZINT_ERROR_TOO_LONG, symbol, 214, "Input too long");
}
/* Reconcile symbol ECI and first segment ECI if both set */
@@ -1191,7 +1203,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
for (i = 0; i < seg_count; i++) {
if (!z_is_valid_utf8(local_segs[i].source, local_segs[i].length)) {
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 245, "Invalid UTF-8 in input");
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 215, "Invalid UTF-8 in input");
}
}
/* Only strip BOM on first segment */
@@ -1245,7 +1257,7 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
return error_tag(ZINT_ERROR_INVALID_OPTION, symbol, 210, "Selected symbology does not support GS1 mode");
}
} else if (content_segs && supports_non_iso8859_1(symbol->symbology)) {
/* Copy these as-is. The content seg `eci` will need to be updated individually */
/* Copy these as-is. The content seg `eci` (& maybe `source`) will need to be updated individually */
if (z_ct_cpy_segs(symbol, local_segs, seg_count)) {
return error_tag(ZINT_ERROR_MEMORY, symbol, -1, NULL); /* `z_ct_cpy_segs()` only fails with OOM */
}
+5 -8
View File
@@ -5,11 +5,7 @@
#define VER_FILEVERSION 2,16,0,9
#define VER_FILEVERSION_STR "2.16.0.9\0"
#ifdef GCC_WINDRES
VS_VERSION_INFO VERSIONINFO
#else
VS_VERSION_INFO VERSIONINFO
#endif
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_FILEVERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
@@ -24,13 +20,14 @@ FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
//language ID = U.S. English, char set = Windows, Multilingual
BLOCK "040904B0"
//language ID = U.S. English, char set = Windows, Unicode
BEGIN
VALUE "CompanyName", "Zint\0"
VALUE "FileDescription", "libzint barcode library\0"
VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "zint.dll\0"
VALUE "LegalCopyright", "Copyright © 2025 Robin Stuart & BogDan Vatra\0"
VALUE "LegalCopyright", "Copyright © 2026 Robin Stuart & BogDan Vatra\0"
VALUE "OriginalFilename", "zint.dll\0"
VALUE "ProductName", "libzint\0"
VALUE "ProductVersion", VER_FILEVERSION_STR
@@ -40,6 +37,6 @@ BEGIN
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1250
VALUE "Translation", 0x0409, 1200
END
END
+120 -83
View File
@@ -204,83 +204,113 @@ static void test_hrt(const testCtx *const p_ctx) {
int expected_length;
const char *expected_content;
int expected_content_length;
int bwipp_cmp;
int zxingcpp_cmp;
const char *comment;
};
/*
é U+00E9 (\351, 233), UTF-8 C3A9, CodeB-only extended ASCII
*/
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "1234567890", -1, "1234567890", -1, "", -1, 1 },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "1234567890", -1, "1234567890", -1, 1 },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "", -1, 1 },
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "\000ABC\000DEF\000", 9, 1 }, /* No replacements */
/* 4*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "12345\00067890", 11, "12345 67890", -1, "", -1, 1 },
/* 5*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\00067890", 11, "12345 67890", -1, "12345\00067890", 11, 1 },
/* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "12345\01167890\037\177", -1, "12345 67890 ", -1, "", -1, 1 },
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\01167890\037\177", -1, "12345 67890 ", -1, "12345\01167890\037\177", -1, 1 },
/* 8*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1 },
/* 9*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1 }, /* Now UTF-8, not converted */
/* 10*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé\302\240", -1, "abcdé\302\240", -1, "", -1, 1 }, /* \302\240 (U+A0) NBSP */
/* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé\302\240", -1, "abcdé\302\240", -1, "abcdé\302\240", -1, 1 },
/* 12*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 899 },
/* 13*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 899 },
/* 14*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\240cd\351", -1, "ab\302\240cdé", -1, "", -1, 899 }, /* \240 (U+A0) NBSP */
/* 15*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\240cd\351", -1, "ab\302\240cdé", -1, "ab\240cd\351", -1, 899 },
/* 16*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\200cd\351", -1, "ab cdé", -1, "", -1, 899 }, /* \200 (U+80) non-ISO/IEC 8859-1 */
/* 17*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\200cd\351", -1, "ab cdé", -1, "ab\200cd\351", -1, 899 },
/* 18*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "", -1, 1 }, /* Max length 198 + 19 special escapes = 99 + 19*3 = 255 */
/* 19*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, 1 },
/* 20*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1 },
/* 21*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1 },
/* 22*/ { BARCODE_CODE128AB, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 899 },
/* 23*/ { BARCODE_CODE128AB, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 899 },
/* 24*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "1234567890", -1, "*+12345678900*", -1, "", -1, 1 },
/* 25*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "*+12345678900*", -1, "+12345678900", -1, 1 },
/* 26*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "a99912345", -1, "*+A999123457*", -1, "", -1, 1 }, /* Converts to upper */
/* 27*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "a99912345", -1, "*+A999123457*", -1, "+A999123457", -1, 1 },
/* 28*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "", -1, 1 }, /* DPDAPPD 4.0.2 - Illustration 7 */
/* 29*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "%000393206219912345678101040", -1, 1 }, /* Includes '%', no spaces, no check digit */
/* 30*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "", -1, 1 }, /* DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect */
/* 31*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "%007110601782532948375101276", -1, 1 },
/* 32*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "", -1, 1 }, /* DPDPLS Section 4 */
/* 33*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "%008182709980000020028101276", -1, 1 },
/* 34*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "", -1, 1 }, /* DPDPLS Section 4.6 */
/* 35*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "%007110601632532948375179276", -1, 1 },
/* 36*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "", -1, 1 }, /* DPDPLS Section 5.1 */
/* 37*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "%001990009980000020084109203", -1, 1 },
/* 38*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "", -1, 1 }, /* DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT */
/* 39*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "007110601632532948375101276", -1, 1 }, /* No '%' */
/* 40*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3", -1, "", -1, 1 }, /* DPDPLS Section 8.1 */
/* 41*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L", -1, "", -1, 1 }, /* DPDPLS Section 8.2 */
/* 42*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J", -1, "", -1, 1 }, /* DPDPLS Section 8.3 */
/* 43*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W", -1, "", -1, 1 }, /* DPDPLS Section 8.4 */
/* 44*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C", -1, "", -1, 1 }, /* DPDPLS Section 8.5.1 */
/* 45*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I", -1, "", -1, 1 }, /* DPDPLS Section 8.5.2 */
/* 46*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H", -1, "", -1, 1 }, /* DPDPLS Section 8.5.3 */
/* 47*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5", -1, "", -1, 1 }, /* DPDPLS Section 8.5.4 */
/* 48*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6", -1, "", -1, 1 }, /* DPDPLS Section 8.5.5 */
/* 49*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U", -1, "", -1, 1 }, /* DPDPLS Section 8.5.6 */
/* 50*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R", -1, "", -1, 1 }, /* DPDPLS Section 8.6.1 */
/* 51*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "", -1, 1 }, /* DPDPLS Section 8.7.1 */
/* 52*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "%008182709980000020043113276", -1, 1 },
/* 53*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "", -1, 1 }, /* DPDPLS Section 8.7.2 relabel */
/* 54*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "006376209980000020044118276", -1, 1 },
/* 55*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C", -1, "", -1, 1 }, /* DPDPLS Section 8.8 */
/* 56*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N", -1, "", -1, 1 }, /* DPDPLS Section 8.9.1 */
/* 57*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "", -1, 1 }, /* DPDPLS Section 8.9.2 */
/* 58*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "%006374309980000020047337276", -1, 1 },
/* 59*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "", -1, 1 }, /* DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect */
/* 60*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "006374109980978004757332276", -1, 1 },
/* 61*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M", -1, "", -1, 1 }, /* DPDPLS Section 9.1 */
/* 62*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W", -1, "", -1, 1 }, /* DPDPLS Section 9.2 */
/* 63*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O", -1, "", -1, 1 }, /* DPDPLS Section 9.3 */
/* 64*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B", -1, "", -1, 1 }, /* DPDPLS Section 9.4 */
/* 65*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A", -1, "", -1, 1 }, /* DPDPLS Section 9.5 */
/* 66*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "", -1, 1 }, /* DPDPLS Section 9.6 */
/* 67*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "%008182709980000020056237276", -1, 1 },
/* 68*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, -1, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "", -1, 1 }, /* UPU S10 Annex A */
/* 69*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "EE876543216CA", -1, 1 }, /* No spaces */
/* 0*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "1234567890", -1, "1234567890", -1, "", -1, 1, 1, "" },
/* 1*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "1234567890", -1, "1234567890", -1, 1, 1, "" },
/* 2*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "", -1, 1, 1, "" },
/* 3*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "\000ABC\000DEF\000", 9, " ABC DEF ", -1, "\000ABC\000DEF\000", 9, 1, 1, "No replacements" },
/* 4*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "12345\00067890", 11, "12345 67890", -1, "", -1, 1, 1, "" },
/* 5*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\00067890", 11, "12345 67890", -1, "12345\00067890", 11, 1, 1, "" },
/* 6*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "12345\01167890\037\177", -1, "12345 67890 ", -1, "", -1, 1, 1, "" },
/* 7*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "12345\01167890\037\177", -1, "12345 67890 ", -1, "12345\01167890\037\177", -1, 1, 1, "" },
/* 8*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1, 1, "" },
/* 9*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1, 1, "Now UTF-8, not converted" },
/* 10*/ { BARCODE_CODE128, UNICODE_MODE, -1, -1, "abcdé\302\240", -1, "abcdé\302\240", -1, "", -1, 1, 1, "\302\240 (U+A0) NBSP" },
/* 11*/ { BARCODE_CODE128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé\302\240", -1, "abcdé\302\240", -1, "abcdé\302\240", -1, 1, 1, "" },
/* 12*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 1, 899, "" },
/* 13*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 1, 899, "" },
/* 14*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\240cd\351", -1, "ab\302\240cdé", -1, "", -1, 1, 899, "\240 (U+A0) NBSP" },
/* 15*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\240cd\351", -1, "ab\302\240cdé", -1, "ab\240cd\351", -1, 1, 899, "" },
/* 16*/ { BARCODE_CODE128, DATA_MODE, -1, -1, "ab\200cd\351", -1, "ab cdé", -1, "", -1, 1, 899, "\200 (U+80) non-ISO/IEC 8859-1" },
/* 17*/ { BARCODE_CODE128, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "ab\200cd\351", -1, "ab cdé", -1, "ab\200cd\351", -1, 1, 899, "" },
/* 18*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "", -1, 1, 1, "Max length 198 + 19 special escapes = 99 + 19*3 = 255" },
/* 19*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C1234567890\\^C123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678", -1, 1, 1, "" },
/* 20*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^10412345", -1, "0412345", -1, "", -1, 1, 1, "" },
/* 21*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^10412345", -1, "0412345", -1, "0412345", -1, 1, 1, "" },
/* 22*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1041234\\^15", -1, "0412345", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords) - see below (forced mode)" },
/* 23*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1041234\\^15", -1, "0412345", -1, "\035041234\0355", -1, 0, 1, "BWIPP - see below (forced mode)" },
/* 24*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1041234\\^B\\^15", -1, "0412345", -1, "", -1, 1, 1, "" },
/* 25*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1041234\\^B\\^15", -1, "0412345", -1, "\035041234\0355", -1, 1, 1, "" },
/* 26*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "A\\^1123456", -1, "A123456", -1, "", -1, 1, 1, "" },
/* 27*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "A\\^1123456", -1, "A123456", -1, "A123456", -1, 1, 1, "" },
/* 28*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "A\\^1123456\\^1", -1, "A123456", -1, "", -1, 1, 1, "" },
/* 29*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "A\\^1123456\\^1", -1, "A123456", -1, "A123456\035", -1, 1, 1, "" },
/* 30*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "?\\^1123456\\^1", -1, "?123456", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords) - see below (forced mode)" },
/* 31*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "?\\^1123456\\^1", -1, "?123456", -1, "?\035123456\035", -1, 0, 1, "BWIPP - see below (forced mode)" },
/* 32*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "?\\^B\\^1\\^@123456\\^1", -1, "?123456", -1, "", -1, 1, 1, "" },
/* 33*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "?\\^B\\^1\\^@123456\\^1", -1, "?123456", -1, "?\035123456\035", -1, 1, 1, "" },
/* 34*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "12\\^1123456", -1, "12123456", -1, "", -1, 1, 1, "" },
/* 35*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "12\\^1123456", -1, "12123456", -1, "12123456", -1, 1, 1, "" },
/* 36*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "12\\^1\\^1123456", -1, "12123456", -1, "", -1, 1, 1, "" },
/* 37*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "12\\^1\\^1123456", -1, "12123456", -1, "12\035123456", -1, 1, 1, "" },
/* 38*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^C12\\^1\\^1123456", -1, "12123456", -1, "", -1, 1, 1, "" },
/* 39*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^C12\\^1\\^1123456", -1, "12123456", -1, "12\035123456", -1, 1, 1, "" },
/* 40*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "1A\\^1123456", -1, "1A123456", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords)" },
/* 41*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "1A\\^1123456", -1, "1A123456", -1, "1A\035123456", -1, 0, 1, "BWIPP: as above" },
/* 42*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1", -1, "", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords) - see below (forced mode)" },
/* 43*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1", -1, "", -1, "\035", -1, 0, 1, "BWIPP - see below (forced mode)" },
/* 44*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^B\\^1\\^1", -1, "", -1, "", -1, 1, 1, "" },
/* 45*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^B\\^1\\^1", -1, "", -1, "\035", -1, 1, 1, "" },
/* 46*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, -1, "\\^1\\^1\\^1", -1, "", -1, "", -1, 0, 1, "BWIPP: different encodation (same no. of codewords)" },
/* 47*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1\\^1\\^1", -1, "", -1, "\035\035", -1, 0, 1, "BWIPP: as above" },
/* 48*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, -1, "abcdé", -1, "abcdé", -1, "", -1, 1, 1, "" },
/* 49*/ { BARCODE_CODE128AB, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "abcdé", -1, "abcdé", -1, "abcdé", -1, 1, 1, "" },
/* 50*/ { BARCODE_CODE128AB, DATA_MODE, -1, -1, "abcd\351", -1, "abcdé", -1, "", -1, 1, 899, "" },
/* 51*/ { BARCODE_CODE128AB, DATA_MODE, -1, BARCODE_CONTENT_SEGS, "abcd\351", -1, "abcdé", -1, "abcd\351", -1, 1, 899, "" },
/* 52*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "1234567890", -1, "*+12345678900*", -1, "", -1, 1, 1, "" },
/* 53*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "1234567890", -1, "*+12345678900*", -1, "+12345678900", -1, 1, 1, "" },
/* 54*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, -1, "a99912345", -1, "*+A999123457*", -1, "", -1, 1, 1, "Converts to upper" },
/* 55*/ { BARCODE_HIBC_128, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "a99912345", -1, "*+A999123457*", -1, "+A999123457", -1, 1, 1, "" },
/* 56*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "", -1, 1, 1, "DPDAPPD 4.0.2 - Illustration 7" },
/* 57*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "000393206219912345678101040", -1, "0003 932 0621 9912 3456 78 101 040 9", -1, "%000393206219912345678101040", -1, 1, 1, "Includes '%', no spaces, no check digit" },
/* 58*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "", -1, 1, 1, "DPDAPPD 4.0.2 - Illustration 6, figure's HRT seems incorrect" },
/* 59*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601782532948375101276", -1, "0071 106 0178 2532 9483 75 101 276 X", -1, "%007110601782532948375101276", -1, 1, 1, "" },
/* 60*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "", -1, 1, 1, "DPDPLS Section 4" },
/* 61*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020028101276", -1, "0081 827 0998 0000 0200 28 101 276 B", -1, "%008182709980000020028101276", -1, 1, 1, "" },
/* 62*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "", -1, 1, 1, "DPDPLS Section 4.6" },
/* 63*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "007110601632532948375179276", -1, "0071 106 0163 2532 9483 75 179 276 A", -1, "%007110601632532948375179276", -1, 1, 1, "" },
/* 64*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "", -1, 1, 1, "DPDPLS Section 5.1" },
/* 65*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "001990009980000020084109203", -1, "0019 900 0998 0000 0200 84 109 203 1", -1, "%001990009980000020084109203", -1, 1, 1, "" },
/* 66*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "", -1, 1, 1, "DPDPLS Section 6.1.2 relabel, figure is actually 8.7.2 with mislabelled HRT" },
/* 67*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "007110601632532948375101276", -1, "0071 106 0163 2532 9483 75 101 276 O", -1, "007110601632532948375101276", -1, 1, 1, "No '%'" },
/* 68*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020029136276", -1, "0081 827 0998 0000 0200 29 136 276 3", -1, "", -1, 1, 1, "DPDPLS Section 8.1" },
/* 69*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "001234509980000020031105276", -1, "0012 345 0998 0000 0200 31 105 276 L", -1, "", -1, 1, 1, "DPDPLS Section 8.2" },
/* 70*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020032154276", -1, "0081 827 0998 0000 0200 32 154 276 J", -1, "", -1, 1, 1, "DPDPLS Section 8.3" },
/* 71*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020030109276", -1, "0081 827 0998 0000 0200 30 109 276 W", -1, "", -1, 1, 1, "DPDPLS Section 8.4" },
/* 72*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020033350276", -1, "0081 827 0998 0000 0200 33 350 276 C", -1, "", -1, 1, 1, "DPDPLS Section 8.5.1" },
/* 73*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020034179276", -1, "0081 827 0998 0000 0200 34 179 276 I", -1, "", -1, 1, 1, "DPDPLS Section 8.5.2" },
/* 74*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020035225276", -1, "0081 827 0998 0000 0200 35 225 276 H", -1, "", -1, 1, 1, "DPDPLS Section 8.5.3" },
/* 75*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020036155276", -1, "0081 827 0998 0000 0200 36 155 276 5", -1, "", -1, 1, 1, "DPDPLS Section 8.5.4" },
/* 76*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "000280009980000020037155056", -1, "0002 800 0998 0000 0200 37 155 056 6", -1, "", -1, 1, 1, "DPDPLS Section 8.5.5" },
/* 77*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007855009980000020041302840", -1, "0078 550 0998 0000 0200 41 302 840 U", -1, "", -1, 1, 1, "DPDPLS Section 8.5.6" },
/* 78*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020042102276", -1, "0081 827 0998 0000 0200 42 102 276 R", -1, "", -1, 1, 1, "DPDPLS Section 8.6.1" },
/* 79*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "", -1, 1, 1, "DPDPLS Section 8.7.1" },
/* 80*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020043113276", -1, "0081 827 0998 0000 0200 43 113 276 Y", -1, "%008182709980000020043113276", -1, 1, 1, "" },
/* 81*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "", -1, 1, 1, "DPDPLS Section 8.7.2 relabel" },
/* 82*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006376209980000020044118276", -1, "0063 762 0998 0000 0200 44 118 276 I", -1, "006376209980000020044118276", -1, 1, 1, "" },
/* 83*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "007160009980000020050294276", -1, "0071 600 0998 0000 0200 50 294 276 C", -1, "", -1, 1, 1, "DPDPLS Section 8.8" },
/* 84*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020045327276", -1, "0081 827 0998 0000 0200 45 327 276 N", -1, "", -1, 1, 1, "DPDPLS Section 8.9.1" },
/* 85*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "", -1, 1, 1, "DPDPLS Section 8.9.2" },
/* 86*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "006374309980000020047337276", -1, "0063 743 0998 0000 0200 47 337 276 O", -1, "%006374309980000020047337276", -1, 1, 1, "" },
/* 87*/ { BARCODE_DPD, UNICODE_MODE, 1, -1, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "", -1, 1, 1, "DPDPLS Section 8.9.3 relabel, figure's HRT seems incorrect" },
/* 88*/ { BARCODE_DPD, UNICODE_MODE, 1, BARCODE_CONTENT_SEGS, "006374109980978004757332276", -1, "0063 741 0998 0978 0047 57 332 276 M", -1, "006374109980978004757332276", -1, 1, 1, "" },
/* 89*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020051106276", -1, "0081 827 0998 0000 0200 51 106 276 M", -1, "", -1, 1, 1, "DPDPLS Section 9.1" },
/* 90*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020052110276", -1, "0081 827 0998 0000 0200 52 110 276 W", -1, "", -1, 1, 1, "DPDPLS Section 9.2" },
/* 91*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020053161276", -1, "0081 827 0998 0000 0200 53 161 276 O", -1, "", -1, 1, 1, "DPDPLS Section 9.3" },
/* 92*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020054352276", -1, "0081 827 0998 0000 0200 54 352 276 B", -1, "", -1, 1, 1, "DPDPLS Section 9.4" },
/* 93*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020055191276", -1, "0081 827 0998 0000 0200 55 191 276 A", -1, "", -1, 1, 1, "DPDPLS Section 9.5" },
/* 94*/ { BARCODE_DPD, UNICODE_MODE, -1, -1, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "", -1, 1, 1, "DPDPLS Section 9.6" },
/* 95*/ { BARCODE_DPD, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "008182709980000020056237276", -1, "0081 827 0998 0000 0200 56 237 276 K", -1, "%008182709980000020056237276", -1, 1, 1, "" },
/* 96*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, -1, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "", -1, 1, 1, "UPU S10 Annex A" },
/* 97*/ { BARCODE_UPU_S10, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "EE876543216CA", -1, "EE 876 543 216 CA", -1, "EE876543216CA", -1, 1, 1, "No spaces" },
/* BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 hrt tested in test_gs1.c */
};
const int data_size = ARRAY_SIZE(data);
@@ -319,9 +349,9 @@ static void test_hrt(const testCtx *const p_ctx) {
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
assert_zero(ret, "i:%d ZBarcode_Encode ret %d != 0 %s\n", i, ret, symbol->errtxt);
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d\n",
i, symbol->text_length, expected_length);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d memcmp(%s, %s, %d) != 0\n",
assert_equal(symbol->text_length, expected_length, "i:%d text_length %d != expected_length %d (%s, %s)\n",
i, symbol->text_length, expected_length, symbol->text, data[i].expected);
assert_zero(memcmp(symbol->text, data[i].expected, expected_length), "i:%d text memcmp(%s, %s, %d) != 0\n",
i, symbol->text, data[i].expected, expected_length);
if (ret < ZINT_ERROR) {
@@ -329,10 +359,11 @@ static void test_hrt(const testCtx *const p_ctx) {
assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i);
assert_nonnull(symbol->content_segs[0].source, "i:%d content_segs[0].source NULL\n", i);
assert_equal(symbol->content_segs[0].length, expected_content_length,
"i:%d content_segs[0].length %d != expected_content_length %d\n",
i, symbol->content_segs[0].length, expected_content_length);
"i:%d content_segs[0].length %d != expected_content_length %d (%.*s, %s)\n",
i, symbol->content_segs[0].length, expected_content_length,
symbol->content_segs[0].length, symbol->content_segs[0].source, data[i].expected_content);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected_content, expected_content_length),
"i:%d memcmp(%.*s, %s, %d) != 0\n",
"i:%d content_segs memcmp(%.*s, %s, %d) != 0\n",
i, symbol->content_segs[0].length, symbol->content_segs[0].source,
data[i].expected_content, expected_content_length);
} else {
@@ -340,7 +371,12 @@ static void test_hrt(const testCtx *const p_ctx) {
}
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, data[i].option_2, -1, debug)) {
if (data[i].symbology == BARCODE_HIBC_128
if (!data[i].bwipp_cmp) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
i, testUtilBarcodeName(symbol->symbology), data[i].comment);
}
} else if (data[i].symbology == BARCODE_HIBC_128
&& z_not_sane(IS_NUM_F | IS_UPR_F | IS_SPC_F | IS_PLS_F | IS_MNS_F | IS_SIL_F, ZCUCP(data[i].data), length)) {
if (debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d %s not BWIPP compatible (%s)\n",
@@ -363,6 +399,7 @@ static void test_hrt(const testCtx *const p_ctx) {
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
int cmp_len, ret_len;
char modules_dump[4096];
assert_nonzero(data[i].zxingcpp_cmp, "i:%d data[i].zxingcpp_cmp == 0", i);
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
"i:%d testUtilModulesDump == -1\n", i);
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, data[i].zxingcpp_cmp, cmp_buf,
@@ -512,8 +549,8 @@ static void test_input(const testCtx *const p_ctx) {
/* 2*/ { UNICODE_MODE, "AIM1234", -1, 0, 101, 1, 1, "(9) 104 33 41 45 99 12 34 87 106", "Example from Annex A.1, check char value 87" },
/* 3*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "123456789", -1, 0, 101, 1, 1, "(9) 105 12 34 56 78 100 25 79 106", "Ticket #204 ZPL example" },
/* 4*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^C6789", -1, 0, 123, 0, 1, "(11) 104 17 18 19 20 21 99 67 89 11 106", "Ticket #204 ZPL example; BWIPP as above" },
/* 5*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, 1, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" },
/* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, 0, 167, 0, 1, "(15) 104 17 18 19 20 21 60 62 36 22 23 24 25 1 106", "Unrecognized extra escape passed thru; BWIPP different encodation" },
/* 5*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^D6789", -1, ZINT_ERROR_INVALID_DATA, 0, 1, 1, "Error 348: Unrecognized extra escape \"\\^D\"", "" },
/* 6*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^B12345\\^\0016789", -1, ZINT_ERROR_INVALID_DATA, 0, 1, 1, "Error 348: Unrecognized extra escape \"\\^?\"", "" },
/* 7*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^C", -1, ZINT_ERROR_INVALID_DATA, 0, 1, 1, "Error 842: No input data", "" },
/* 8*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^^B\\^C", -1, 0, 68, 0, 1, "(6) 103 60 62 34 80 106", "BWIPP different encodation" },
/* 9*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^B\\^^C", -1, 0, 68, 1, 1, "(6) 104 60 62 35 84 106", "" },
@@ -649,10 +686,10 @@ static void test_input(const testCtx *const p_ctx) {
/*139*/ { UNICODE_MODE, "12é12é", -1, 0, 123, 0, 1, "(11) 105 12 100 100 73 17 18 100 73 17 106", "StartC 12 CodeB FNC4 é 1 2 FNC4 é; BWIPP different encodation (StartB)" },
/*140*/ { UNICODE_MODE, "1234é123456é", -1, 0, 167, 1, 1, "(15) 105 12 34 100 100 73 99 12 34 56 100 100 73 15 106", "StartC 12 34 CodeB FNC4 é CodeC 12 34 56 CodeB FNC4 é" },
/*141*/ { DATA_MODE, "\256^a\357\033\270\017,\274u$B\305\311\006\011]\273\025u\315\2638\263\333", -1, 0, 453, 1, 899, "(41) 104 100 14 62 65 100 79 101 91 101 24 79 12 101 28 98 85 4 34 101 37 101 41 70 73 61", "" },
/*142*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^C\\^1", -1, 0, 46, 0, 0, "(4) 105 102 1 106", "StartC FNC1; From fuzz 2026-01-12; BWIPP see below; zxing-cpp empty text" },
/*143*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^1", -1, 0, 46, 0, 0, "(4) 103 102 102 106", "StartA FNC1; From fuzz 2026-01-12; BWIPP see below; zxing-cpp empty text" },
/*144*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1", -1, 0, 46, 1, 0, "(4) 104 102 0 106", "StartB FNC1; From fuzz 2026-01-12; zxing-cpp empty text" },
/*145*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^1", -1, 0, 46, 0, 0, "(4) 105 102 1 106", "StartC FNC1; BWIPP see above; zxing-cpp empty text" },
/*142*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^C\\^1", -1, 0, 46, 0, 1, "(4) 105 102 1 106", "StartC FNC1; From fuzz 2026-01-12; BWIPP see below" },
/*143*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^1", -1, 0, 46, 0, 1, "(4) 103 102 102 106", "StartA FNC1; From fuzz 2026-01-12; BWIPP see below" },
/*144*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1", -1, 0, 46, 1, 1, "(4) 104 102 0 106", "StartB FNC1; From fuzz 2026-01-12" },
/*145*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^1", -1, 0, 46, 0, 1, "(4) 105 102 1 106", "StartC FNC1; BWIPP see above" },
/*146*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^C\\^1A", -1, 0, 68, 0, 3, "(6) 105 102 100 33 94 106", "StartC CodeB FNC1 A; BWIPP see below" },
/*147*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^A\\^1A", -1, 0, 57, 0, 3, "(5) 103 102 33 65 106", "StartA FNC1 A; BWIPP see below" },
/*148*/ { DATA_MODE | EXTRA_ESCAPE_MODE, "\\^B\\^1A", -1, 0, 57, 1, 3, "(5) 104 102 33 66 106", "StartB FNC1 A" },
+147 -7
View File
@@ -155,8 +155,7 @@ static void test_to_upper(const testCtx *const p_ctx) {
buf[length] = '\0';
z_to_upper(buf, length);
assert_zero(strcmp((const char *) buf, data[i].expected), "i:%d strcmp(%s, %s) != 0\n",
i, buf, data[i].expected);
assert_zero(strcmp(ZCCP(buf), data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, buf, data[i].expected);
}
testFinish();
@@ -764,6 +763,70 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
testFinish();
}
static void test_extra_escapes(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int eci;
const char *data;
int length;
int ret;
const char *expected;
const char expected_fncs[32];
const char *comment;
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 0, "", -1, 0, "", {0}, "" },
/* 1*/ { 3, "ABC", -1, 0, "ABC", {0}, "" },
/* 2*/ { 4, "\\^1ABC", -1, 0, "\035ABC", {1}, "" },
/* 3*/ { 26, "\\^1\\^1A\\^1BC\\^1", -1, 0, "\035\035A\035BC\035", {1,1,0,1,0,0,1}, "" },
/* 4*/ { 27, "\\^^\\^1A\\^1BC\\^^1", -1, 0, "\\^\035A\035BC\\^1", {0,0,1,0,1}, "" },
/* 5*/ { 20, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 6*/ { 25, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 7*/ { 28, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 8*/ { 29, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
/* 9*/ { 899, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, "" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;
int expected_length;
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int len = 0;
unsigned char dest[32] = {0};
char fncs[32] = {0};
if (testContinue(p_ctx, i)) continue;
memset(symbol, 0, sizeof(*symbol));
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
expected_length = (int) strlen(data[i].expected);
assert_nonzero(expected_length < (int) sizeof(dest), "i:%d expected_length %d >= sizeof(dest) %d\n",
i, expected_length, (int) sizeof(dest));
ret = z_extra_escapes(symbol, ZCUCP(data[i].data), length, data[i].eci, dest, fncs, &len);
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
if (ret < ZINT_ERROR) {
assert_equal(len, expected_length, "i:%d len %d != expected_length %d (%s)\n",
i, len, expected_length, dest);
assert_zero(strcmp(ZCCP(dest), data[i].expected), "i:%d dest (%s) != expected (%s)\n",
i, dest, data[i].expected);
assert_zero(memcmp(fncs, data[i].expected_fncs, expected_length), "i:%d fncs != expected_fncs\n", i);
}
}
testFinish();
}
/* Note transferred from "test_code128.c" */
static void test_hrt_cpy_iso8859_1(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@@ -1033,7 +1096,7 @@ static void test_hrt_printf_nochk(const testCtx *const p_ctx) {
assert_zero(1, "i:%d, bad num_args\n", i);
}
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
assert_zero(strcmp(ZCCP(symbol->text), data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
i, symbol->text, data[i].expected);
}
@@ -1084,7 +1147,7 @@ static void test_hrt_conv_gs1_brackets_nochk(const testCtx *const p_ctx) {
z_hrt_conv_gs1_brackets_nochk(symbol, TCU(data[i].data), length);
assert_zero(strcmp((const char *) symbol->text, data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
assert_zero(strcmp(ZCCP(symbol->text), data[i].expected), "i:%d strcmp(\"%s\", \"%s\") != 0\n",
i, symbol->text, data[i].expected);
}
@@ -1223,7 +1286,7 @@ static void test_ct_cpy(const testCtx *const p_ctx) {
i, symbol->content_segs[0].length, expected_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length),
"i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length,
testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
@@ -1237,6 +1300,81 @@ static void test_ct_cpy(const testCtx *const p_ctx) {
testFinish();
}
static void test_ct_set_seg_extra_escapes_eci(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
struct item {
int seg_idx;
int seg_count;
int eci;
struct zint_seg segs[3];
struct zint_seg expected_content_segs[3];
};
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
static const struct item data[] = {
/* 0*/ { 0, 1, 3, { { TU("\\^1A"), 0, 0 } }, { { TU("\035A"), 2, 3 } } },
/* 1*/ { 0, 1, 0, { { TU("\\^1A"), 0, 0 } }, { { TU("A"), 1, 3 } } },
/* 2*/ { 0, 1, 4, { { TU("A\\^1"), 0, 0 } }, { { TU("A\035"), 2, 4 } } },
/* 3*/ { 0, 1, 0, { { TU("A\\^1"), 0, 0 } }, { { TU("A"), 1, 3 } } },
/* 4*/ { 0, 1, 0, { { TU("a\\^1"), 0, 0 } }, { { TU("a"), 1, 3 } } },
/* 5*/ { 0, 1, 0, { { TU("12\\^1"), 0, 0 } }, { { TU("12"), 2, 3 } } },
/* 6*/ { 0, 1, 0, { { TU("?\\^1"), 0, 0 } }, { { TU("?\035"), 2, 3 } } },
/* 7*/ { 0, 1, 0, { { TU("1A\\^1"), 0, 0 } }, { { TU("1A\035"), 3, 3 } } },
/* 8*/ { 0, 1, 0, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 3 } } },
/* 9*/ { 0, 1, 5, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\035\\^1A\035"), 6, 5 } } },
/* 10*/ { 1, 2, 27, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 27 } } },
/* 11*/ { 1, 2, 0, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 3 } } },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol s_symbol = {0};
struct zint_symbol *symbol = &s_symbol;
char escaped[4096];
char escaped2[4096];
testStart(p_ctx->func_name);
symbol->debug = debug;
for (i = 0; i < data_size; i++) {
int expected_length;
unsigned char *expected_source;
int expected_eci = data[i].eci ? data[i].eci : 3;
int seg_idx = data[i].seg_idx;
if (testContinue(p_ctx, i)) continue;
ret = z_ct_cpy_segs(symbol, data[i].segs, data[i].seg_count);
assert_zero(ret, "i:%d z_ct_cpy_segs %d != 0\n", i, ret);
assert_nonnull(symbol->content_segs, "i:%d content_segs NULL\n", i);
z_ct_set_seg_extra_escapes_eci(symbol, seg_idx, data[i].eci);
assert_nonnull(symbol->content_segs[seg_idx].source, "i:%d content_segs[%d].source NULL\n", i, seg_idx);
expected_length = data[i].expected_content_segs[seg_idx].length;
expected_source = data[i].expected_content_segs[seg_idx].source;
assert_equal(symbol->content_segs[seg_idx].length, expected_length,
"i:%d content_segs[%d].length %d != expected_length %d\n",
i, seg_idx, symbol->content_segs[seg_idx].length, expected_length);
assert_zero(memcmp(symbol->content_segs[seg_idx].source, expected_source, expected_length),
"i:%d content_segs[%d].source memcmp(%s, %s, %d) != 0\n", i, seg_idx,
testUtilEscape(ZCCP(symbol->content_segs[seg_idx].source), symbol->content_segs[seg_idx].length,
escaped, sizeof(escaped)),
testUtilEscape(ZCCP(expected_source), expected_length, escaped2, sizeof(escaped2)),
expected_length);
assert_equal(symbol->content_segs[seg_idx].eci, expected_eci, "i:%d content_segs[%d].eci %d != expected_eci %d\n",
i, seg_idx, symbol->content_segs[seg_idx].eci, expected_eci);
ZBarcode_Clear(symbol);
}
testFinish();
}
static void test_ct_cpy_iso8859_1(const testCtx *const p_ctx) {
int debug = p_ctx->debug;
@@ -1287,7 +1425,7 @@ static void test_ct_cpy_iso8859_1(const testCtx *const p_ctx) {
i, symbol->content_segs[0].length, expected_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length),
"i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length,
testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
@@ -1355,7 +1493,7 @@ static void test_ct_printf_256(const testCtx *const p_ctx) {
i, symbol->content_segs[0].length, expected_length);
assert_zero(memcmp(symbol->content_segs[0].source, data[i].expected, expected_length),
"i:%d content_segs[0].source memcmp(%s, %s, %d) != 0\n", i,
testUtilEscape((const char *) symbol->content_segs[0].source, symbol->content_segs[0].length,
testUtilEscape(ZCCP(symbol->content_segs[0].source), symbol->content_segs[0].length,
escaped, sizeof(escaped)),
testUtilEscape(data[i].expected, expected_length, escaped2, sizeof(escaped2)),
expected_length);
@@ -1489,12 +1627,14 @@ int main(int argc, char *argv[]) {
{ "test_cnt_digits", test_cnt_digits },
{ "test_is_valid_utf8", test_is_valid_utf8 },
{ "test_utf8_to_unicode", test_utf8_to_unicode },
{ "test_extra_escapes", test_extra_escapes },
{ "test_hrt_cpy_iso8859_1", test_hrt_cpy_iso8859_1 },
{ "test_hrt_cpy_nochk", test_hrt_cpy_nochk },
{ "test_hrt_cpy_cat_nochk", test_hrt_cpy_cat_nochk },
{ "test_hrt_printf_nochk", test_hrt_printf_nochk },
{ "test_hrt_conv_gs1_brackets_nochk", test_hrt_conv_gs1_brackets_nochk },
{ "test_ct_cpy_segs", test_ct_cpy_segs },
{ "test_ct_set_seg_extra_escapes_eci", test_ct_set_seg_extra_escapes_eci },
{ "test_ct_cpy", test_ct_cpy },
{ "test_ct_cpy_iso8859_1", test_ct_cpy_iso8859_1 },
{ "test_ct_printf_256", test_ct_printf_256 },
File diff suppressed because it is too large Load Diff
+30 -15
View File
@@ -191,10 +191,10 @@ static void test_checks(const testCtx *const p_ctx) {
/*127*/ { 150, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
/*128*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_INVALID_OPTION, "Warning 206: Symbology out of range", BARCODE_CODE128 },
/*129*/ { BARCODE_LAST + 1, -1, "1", -1, -1, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_INVALID_OPTION, "Error 206: Symbology out of range", -1 },
/*130*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*132*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input", -1 },
/*130*/ { BARCODE_CODE128, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*131*/ { BARCODE_CODE128, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*132*/ { BARCODE_MAXICODE, -1, "\200", -1, UNICODE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*133*/ { BARCODE_MAXICODE, -1, "\\o200", -1, UNICODE_MODE | ESCAPE_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input", -1 },
/*134*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, -1, ZINT_WARN_NONCOMPLIANT, "Warning 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 },
/*135*/ { BARCODE_GS1_128, -1, "[01]12345678901234", -1, GS1_MODE, -1, 0, 0, 0, 0, -1, -1, 0, -1, WARN_FAIL_ALL, ZINT_ERROR_NONCOMPLIANT, "Error 261: AI (01) data position 14: Bad checksum '4', expected '1'", -1 },
/*136*/ { BARCODE_QRCODE, -1, "", -1, UNICODE_MODE, 13, 0, 0, 0, 0, -1, -1, 0, -1, -1, 0, "", -1 },
@@ -306,10 +306,10 @@ static void test_checks_segs(const testCtx *const p_ctx) {
/* 8*/ { BARCODE_CODE128, -1, { { TU("A"), 0, 3 }, { NULL, 0, 0 } }, 1, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 217: Symbology does not support ECI switching" },
/* 9*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 1 } }, 2, -1, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 218: ECI code '1' out of range (0 to 999999, excluding 1, 2, 14 and 19)" },
/* 10*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, GS1_MODE, -1, -1, ZINT_ERROR_INVALID_OPTION, "Error 776: GS1 mode not supported for multiple segments" },
/* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 245: Invalid UTF-8 in input" },
/* 11*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("\200"), 0, 4 } }, 2, UNICODE_MODE, -1, -1, ZINT_ERROR_INVALID_DATA, "Error 215: Invalid UTF-8 in input" },
/* 12*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 3 }, { TU("B"), 0, 4 } }, 2, -1, -1, -1, 0, "" },
/* 13*/ { BARCODE_AZTEC, -1, { { TU("A"), 0, 0 }, { TU("B"), 0, 4 } }, 2, -1, 3, -1, 0, "" },
/* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 243: Input too long" },
/* 14*/ { BARCODE_AZTEC, -1, { { TU("A"), ZINT_MAX_DATA_LEN, 3 }, { TU("B"), 1, 4 } }, 2, -1, -1, -1, ZINT_ERROR_TOO_LONG, "Error 214: Input too long" },
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
@@ -731,9 +731,9 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 44*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uFG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 45*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\u' escape sequence in input", 0, "" },
/* 46*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\u00FG", "", ZINT_ERROR_INVALID_DATA, 0, "Error 211: Invalid character for '\\u' escape sequence in input (hexadecimal only)", 0, "" },
/* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" },
/* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" },
/* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" },
/* 47*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ufffe", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ufffe' in input out of range", 0, "Reversed BOM" },
/* 48*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\ud800", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\ud800' in input out of range", 0, "Surrogate" },
/* 49*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\udfff' in input out of range", 0, "Surrogate" },
/* 50*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\uffff", "", 0, 12, "E7 2C B0 16 AB A1 1F 85 EB 50 A1 4C", 0, "" },
/* 51*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\xE2\\x82\\xAC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 0, "Zint manual 4.10 Ex1" },
/* 52*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 17, "\\u20AC", "", 0, 12, "F1 12 EB 25 81 4A 0A 8C 31 AC E3 2E", 1, "" },
@@ -755,7 +755,7 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 68*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\Udfff", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "Surrogate" },
/* 69*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 70*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U0000F", "", ZINT_ERROR_INVALID_DATA, 0, "Error 209: Incomplete '\\U' escape sequence in input", 0, "" },
/* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 246: Value of escape sequence '\\U110000' in input out of range", 0, "" },
/* 71*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\U110000", "", ZINT_ERROR_INVALID_DATA, 0, "Error 216: Value of escape sequence '\\U110000' in input out of range", 0, "" },
/* 72*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 25, "\\U10FFFF", "", 0, 14, "F1 1A E7 57 C7 81 F7 AC 09 06 28 51 F3 00 E1 8C 2A 1C", 0, "" },
/* 73*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, "\\U10FFFF", "", 0, 14, "F1 1B E7 57 E0 11 D7 6C 4F 45 E2 B3 FF F1 72 AB 54 9F", 0, "" },
/* 74*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 32, "\\U10FFFF", "", 0, 14, "F1 21 EB 64 33 EB 1B 36 1D F7 B1 6D 8C A6 34 64 19 3A", 0, "" },
@@ -764,11 +764,25 @@ static void test_escape_char_process(const testCtx *const p_ctx) {
/* 77*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 35, "\\U10FFFF", "", 0, 14, "F1 24 EB 80 EB 80 11 01 17 BA C6 05 9F 4C EA E5 18 31", 0, "" },
/* 78*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[20]10", "[10]A", 0, 99, "(7) 105 102 20 10 100 59 106", 0, "" },
/* 79*/ { BARCODE_GS1_128_CC, GS1_MODE, -1, "[2\\x30]1\\d048", "[\\x310]\\x41", 0, 99, "(7) 105 102 20 10 100 59 106", 1, "" },
/* 80*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid for Code 128 in extra escape mode", 0, "" },
/* 81*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" },
/* 82*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" },
/* 83*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", 0, 79, "(7) 104 60 62 36 17 52 106", 0, "Unknown special escapes passed straight thu" },
/* 84*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" },
/* 80*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 81*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "" },
/* 82*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 83*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 84*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" },
/* 85*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" },
/* 86*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 213: Extra escape '\\^' not valid for this symbology and/or input mode", 0, "Not allowed of DATAMATRIX in GS1_MODE" },
/* 87*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "F1 13 42 E8 43 C3 1B 02 5A 6B 37 CC", 0, "" },
/* 88*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 89*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, "\\^1ーコ\\^1ード\\^1東京\\^1都", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 90*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 25, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 91*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 33, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 92*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 170, "A\\^1B", "", ZINT_ERROR_INVALID_DATA, 0, "Error 244: Invalid character in input for ECI '170'", 0, "" },
/* 93*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, "A\\^1B", "", ZINT_ERROR_INVALID_OPTION, 0, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, "" },
/* 94*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in extra escape mode", 0, "" },
/* 95*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" },
/* 96*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" },
/* 97*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" },
/* 98*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
@@ -891,6 +905,7 @@ static void test_escape_char_process_test(const testCtx *const p_ctx) {
/* 2*/ { 0, 0, "\\U010283", 0, "\360\220\212\203", 4 },
/* 3*/ { 0, 0, "\\u007F\\u0080\\u011E\\u13C9\\U010283", 0, "\177\302\200\304\236\341\217\211\360\220\212\203", 12 },
/* 4*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, "\\^A\\^^\\^B", 0, "\\^A\\^^\\^B", 9 },
/* 5*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, "\\^1\\^^\\^1", 0, "\\^1\\^^\\^1", 9 },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
+106 -54
View File
@@ -2665,29 +2665,77 @@ static char *testUtilBwippCvtGS1Data(char *bwipp_data, const int bwipp_data_size
return bwipp_data;
}
/* Copied from "library.c" */
/* Returns 1 if `symbol` can process EXTRA_ESCAPE_MODE */
static int supports_extra_escape_mode(const struct zint_symbol *const symbol) {
return symbol->symbology == BARCODE_CODE128
|| (symbol->symbology == BARCODE_DATAMATRIX && (symbol->input_mode & 0x07) != GS1_MODE);
}
#define z_isxdigit(c) (z_isdigit(c) || ((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
#define z_isodigit(c) ((c) <= '7' && (c) >= '0')
/* Convert data to Ghostscript format for passing to bwipp_dump.ps */
static char *testUtilBwippEscape(char *bwipp_data, const int bwipp_data_size, const char *data, const int length,
const int zint_escape_mode, const int eci, int *parse, int *parsefnc) {
static char *testUtilBwippEscape(const struct zint_symbol *const symbol, char *bwipp_data, const int bwipp_data_size,
const char *data, const int length, const int eci, int *parse, int *parsefnc) {
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && supports_extra_escape_mode(symbol);
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
const int is_c128 = symbol->symbology == BARCODE_CODE128;
char *b = bwipp_data;
char *be = b + bwipp_data_size;
unsigned char *d = (unsigned char *) data;
unsigned char *de = (unsigned char *) data + length;
int have_done_single_caret = 0; /* Flag to help debug escaping of carets */
if (eci && !*parsefnc) {
if (eci) {
sprintf(bwipp_data, "^ECI%06d", eci);
*parsefnc = 1;
b = bwipp_data + 10;
}
while (b < be && d < de) {
/* Deal with extra escape sequences first */
if (is_extra_escaped && *d == '\\' && d + 1 < de && d[1] == '^'
&& (d + 2 == de || ((d[2] == '1' || d[2] == '^' || (is_c128 && d[2] >= '@' && d[2] <= 'C'))))) {
if (d + 2 == de || d[2] == '^') {
/* Literal "\^^" */
if (*parsefnc) {
if (b + 6 >= be) {
fprintf(stderr, "testUtilBwippEscape: extra escape double caret bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL;
}
strcpy(b, "^092^^");
b += 6;
*parse = 1;
} else {
if (b + 8 >= be) {
fprintf(stderr, "testUtilBwippEscape: extra escape 094 caret bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL;
}
strcpy(b, "^092^094");
b += 8;
*parse = 1;
}
} else if (d[2] == '1') {
if (b + 5 >= be) {
fprintf(stderr, "testUtilBwippEscape: extra escape FNC1 bwipp_data buffer full (%d)\n",
bwipp_data_size);
return NULL;
}
strcpy(b, "^FNC1");
b += 5;
*parsefnc = 1;
} else {
assert(d + 2 < de && is_c128 && d[2] >= '@' && d[2] <= 'C');
}
d += 2 + (d + 2 != de);
/* Have to escape double quote otherwise Ghostscript gives "Unterminated quote in @-file" for some reason */
/* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */
if (*d < 0x20 || *d >= 0x7F || (*d == '^' && !*parsefnc) || *d == '"' || *d == '\''
|| *d == '(' || (*d == '\\' && !zint_escape_mode)) {
} else if (*d < 0x20 || *d >= 0x7F || (*d == '^' && !*parsefnc) || *d == '"' || *d == '\''
|| *d == '(' || (*d == '\\' && !is_escaped)) {
if (b + 4 >= be) {
fprintf(stderr, "testUtilBwippEscape: double quote bwipp_data buffer full (%d)\n", bwipp_data_size);
return NULL;
@@ -2710,7 +2758,7 @@ static char *testUtilBwippEscape(char *bwipp_data, const int bwipp_data_size, co
/* `parsefnc` changed while escaping (see FNC1 processing below) - may cause test to fail */
fprintf(stderr, "testUtilBwippEscape: WARNING: already escaped caret singularly\n");
}
} else if (zint_escape_mode && *d == '\\' && d + 1 < de) {
} else if (is_escaped && *d == '\\' && d + 1 < de) {
int val;
switch (*++d) {
case '0': val = 0x00; /* Null */ break;
@@ -2883,6 +2931,7 @@ static char *testUtilBwippUtf8Convert(const int index, const int symbology, cons
/* Create bwipp_dump.ps command and run */
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
const char *data, int length, const char *primary, char *buffer, int buffer_size, int *p_parsefnc) {
static const char fn[] = "testUtilBwipp";
static const char cmd_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s'"
" backend/tests/tools/bwipp_dump.ps";
static const char cmd_opts_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' -so='%s'"
@@ -2924,10 +2973,11 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
FILE *fp = NULL;
int cnt;
int exit_status;
char *b = buffer;
char *be = buffer + buffer_size;
int r, h;
int r;
int parse = 0, parsefnc = p_parsefnc ? *p_parsefnc : 0;
const int upcean = (ZBarcode_Cap(symbology, ZINT_CAP_EANUPC) & ZINT_CAP_EANUPC) == ZINT_CAP_EANUPC;
@@ -2944,8 +2994,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
bwipp_barcode = testUtilBwippName(index, symbol, option_1, option_2, option_3, 0, &linear_row_height, &gs1_cvt);
if (!bwipp_barcode) {
fprintf(stderr, "i:%d testUtilBwipp: no mapping for %s, option_1 %d, option_2 %d, option_3 %d\n",
index, testUtilBarcodeName(symbology), option_1, option_2, option_3);
fprintf(stderr, "i:%d %s:%d no mapping for %s, option_1 %d, option_2 %d, option_3 %d\n",
index, fn, __LINE__, testUtilBarcodeName(symbology), option_1, option_2, option_3);
return -1;
}
@@ -2956,8 +3006,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
bwipp_row_height[r] = symbol->row_height[r] ? symbol->row_height[r] : linear_row_height;
}
if ((symbol->debug & ZINT_DEBUG_TEST_PRINT) && !(symbol->debug & ZINT_DEBUG_TEST_LESS_NOISY)) {
fprintf(stderr, "bwipp_row_height[%d] %d, symbol->row_height[%d] %g\n",
r, bwipp_row_height[r], r, symbol->row_height[r]);
fprintf(stderr, "i:%d %s:%d bwipp_row_height[%d] %d, symbol->row_height[%d] %g\n",
index, fn, __LINE__, r, bwipp_row_height[r], r, symbol->row_height[r]);
}
}
@@ -2966,14 +3016,15 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
if ((symbol->input_mode & 0x07) == UNICODE_MODE && zint_is_eci_convertible(eci)
&& (data = testUtilBwippUtf8Convert(index, symbology, 1 /*try_sjis*/, &eci, (const unsigned char *) data,
&data_len, (unsigned char *) converted)) == NULL) {
fprintf(stderr, "i:%d testUtilBwipp: failed to convert UTF-8 data for %s\n",
index, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d %s:%d failed to convert UTF-8 data for %s\n",
index, fn, __LINE__, testUtilBarcodeName(symbology));
return -1;
}
if (z_is_composite(symbology)) {
if (!primary) {
fprintf(stderr, "i:%d testUtilBwipp: no primary data given %s\n", index, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d %s:%d no primary data given %s\n",
index, fn, __LINE__, testUtilBarcodeName(symbology));
return -1;
}
if (*primary != obracket && !upcean) {
@@ -3072,10 +3123,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
#endif
} else {
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE)
&& symbol->symbology == BARCODE_CODE128;
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
if (testUtilBwippEscape(bwipp_data, bwipp_data_size, data, data_len, is_escaped, eci, &parse, &parsefnc)
if (testUtilBwippEscape(symbol, bwipp_data, bwipp_data_size, data, data_len, eci, &parse, &parsefnc)
== NULL) {
return -1;
}
@@ -3560,9 +3608,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
if ((option_1 != -1 || option_2 != -1 || option_3 != -1) && !bwipp_opts) {
fprintf(stderr,
"i:%d testUtilBwipp: no BWIPP options set option_1 %d, option_2 %d, option_3 %d for symbology %s\n",
index, option_1, option_2, option_3, testUtilBarcodeName(symbology));
fprintf(stderr, "i:%d %s:%d no BWIPP options set option_1 %d, option_2 %d, option_3 %d for symbology %s\n",
index, fn, __LINE__, option_1, option_2, option_3, testUtilBarcodeName(symbology));
return -1;
}
@@ -3607,7 +3654,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
memcpy(cmd + GS_INITIAL_LEN, adj, sizeof(adj) - 1);
}
if (symbology == BARCODE_CODE11 || symbology == BARCODE_CODE39 || symbology == BARCODE_EXCODE39
|| symbology == BARCODE_CODABAR || symbology == BARCODE_PHARMA || symbology == BARCODE_PZN
|| symbology == BARCODE_CODABAR || symbology == BARCODE_PZN
|| symbology == BARCODE_CODE32 || symbology == BARCODE_VIN) {
/* Ratio 3 width bar/space -> 2 width */
char adj[] = " -sr=0.6";
@@ -3664,12 +3711,12 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
if (symbol->debug & ZINT_DEBUG_TEST_PRINT) {
printf("i:%d testUtilBwipp: cmd %s\n", index, cmd);
printf("i:%d %s cmd %s\n", index, fn, cmd);
}
fp = testutil_popen(cmd, "r");
if (!fp) {
fprintf(stderr, "i:%d testUtilBwipp: failed to run '%s'\n", index, cmd);
fprintf(stderr, "i:%d %s:%d failed to run '%s'\n", index, fn, __LINE__, cmd);
return -1;
}
@@ -3679,45 +3726,38 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
} else {
for (r = 0; r < symbol->rows; r++) {
if (b + symbol->width > be) {
fprintf(stderr, "i:%d testUtilBwipp: row %d, width %d, row width iteration overrun (%s)\n",
index, r, symbol->width, cmd);
testutil_pclose(fp);
fprintf(stderr, "i:%d %s:%d row %d, width %d, row width iteration overrun (%s)\n",
index, fn, __LINE__, r, symbol->width, cmd);
(void) testutil_pclose(fp);
return -1;
}
cnt = (int) fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) {
fprintf(stderr,
"i:%d testUtilBwipp: failed to read row %d of %d, symbol->width %d bytes, cnt %d (%s)\n",
index, r + 1, symbol->rows, symbol->width, cnt, cmd);
testutil_pclose(fp);
fprintf(stderr, "i:%d %s:%d failed to read row %d of %d, symbol->width %d bytes, cnt %d (%s)\n",
index, fn, __LINE__, r + 1, symbol->rows, symbol->width, cnt, cmd);
(void) testutil_pclose(fp);
return -1;
}
b += cnt;
for (h = bwipp_row_height[r]; h > 1; h--) { /* Ignore row copies if any */
cnt = (int) fread(b, 1, symbol->width, fp);
if (cnt != symbol->width) {
fprintf(stderr,
"i:%d testUtilBwipp: failed to read/ignore symbol->width %d bytes, cnt %d, h %d"
", bwipp_row_height[%d] %d, symbol->row_height[%d] %g (%s)\n",
index, symbol->width, cnt, h, r, bwipp_row_height[r], r, symbol->row_height[r], cmd);
testutil_pclose(fp);
return -1;
}
if (h * 2 == bwipp_row_height[r]) { /* Hack to use middle row (avoids add-on text offsets) */
memcpy(b - cnt, b, cnt);
}
}
}
}
*b = '\0';
if (fgetc(fp) != EOF) {
fprintf(stderr, "i:%d testUtilBwipp: failed to read full stream (%s)\n", index, cmd);
testutil_pclose(fp);
fprintf(stderr, "i:%d %s:%d failed to read full stream (%s)\n", index, fn, __LINE__, cmd);
(void) testutil_pclose(fp);
return -1;
}
testutil_pclose(fp);
if ((exit_status = testutil_pclose(fp))) {
#ifndef _WIN32
if (WIFEXITED(exit_status)) {
exit_status = WEXITSTATUS(exit_status);
}
#endif
fprintf(stderr, "i:%d %s:%d pclose returned exit status %d (%s)\n", index, fn, __LINE__, exit_status, cmd);
return -1;
}
return 0;
}
@@ -3797,7 +3837,7 @@ int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int o
total_len = (int) (d - data);
if (unicode_mode) {
symbol->input_mode = DATA_MODE;
symbol->input_mode = DATA_MODE | (symbol->input_mode & ~0x07);
}
symbol->eci = 0;
@@ -4147,6 +4187,7 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
FILE *fp = NULL;
int cnt;
int exit_status;
buffer[0] = '\0';
@@ -4192,17 +4233,25 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
if (cnt == buffer_size) {
fprintf(stderr, "i:%d testUtilZXingCPP: buffer too small, %d bytes, cnt %d (%s)\n",
index, buffer_size, cnt, cmd);
testutil_pclose(fp);
(void) testutil_pclose(fp);
return -1;
}
if (fgetc(fp) != EOF) {
fprintf(stderr, "i:%d testUtilZXingCPP: failed to read full stream (%s)\n", index, cmd);
testutil_pclose(fp);
(void) testutil_pclose(fp);
return -1;
}
testutil_pclose(fp);
if ((exit_status = testutil_pclose(fp))) {
#ifndef _WIN32
if (WIFEXITED(exit_status)) {
exit_status = WEXITSTATUS(exit_status);
}
#endif
fprintf(stderr, "i:%d testUtilZXingCPP: pclose returned exit status %d (%s)\n", index, exit_status, cmd);
return -1;
}
if ((data_mode && zxingcpp_cmp > 1 && (zxingcpp_cmp == 899 || zint_is_eci_convertible(zxingcpp_cmp)))
|| symbol->eci >= 899) {
@@ -4311,7 +4360,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
const int is_dbar_nonexp = symbology == BARCODE_DBAR_OMN || symbology == BARCODE_DBAR_LTD
|| symbology == BARCODE_DBAR_OMNSTK || symbology == BARCODE_DBAR_STK;
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE || is_gs1_128_dbar_exp;
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && symbol->symbology == BARCODE_CODE128;
const int is_extra_escaped = (symbol->input_mode & EXTRA_ESCAPE_MODE) && supports_extra_escape_mode(symbol);
const int is_escaped = (symbol->input_mode & ESCAPE_MODE) || is_extra_escaped;
const int is_hibc = symbology >= BARCODE_HIBC_128 && symbology <= BARCODE_HIBC_AZTEC;
const int have_ccheckdigit = symbol->option_2 == 1 || symbol->option_2 == 2; /* Good for C25, CODE39, CODABAR */
@@ -4360,6 +4409,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
/* Remove any Code 128 special escapes */
int j = 0;
int have_manual_ab = 0;
int have_position_fnc1 = 0;
for (i = 0; i < expected_len; i++) {
if (escaped[i] == '\\' && i + 2 < expected_len && escaped[i + 1] == '^'
&& ((escaped[i + 2] >= '@' && escaped[i + 2] <= 'C') || escaped[i + 2] == '1'
@@ -4372,11 +4422,13 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
/* FNC1 in 1st position treated as GS1 and in 2nd position AIM, neither transmitted -
need to skip AIM (single alphabetic or Code Set C double digit)
TODO: guessing about whether in Code Set C for double digit */
if (j > 2 || (j == 1 && !(z_isupper(escaped[0]) || z_islower(escaped[0])))
if (symbol->eci || have_position_fnc1 || j > 2 || (j == 1 && !z_isalpha(escaped[0]))
|| (j == 2 && !(z_isdigit(escaped[0]) && z_isdigit(escaped[1])
&& !have_manual_ab))) {
/* Probably not AIM */
escaped[j++] = 29; /* GS */
} else {
have_position_fnc1 = 1;
}
}
} else {
@@ -98,6 +98,32 @@ ret /pixs known {
pixs 0 tmppixs 0 j getinterval putinterval
} if
b (databarlimitedcomposite) eq {
% Add RHS 5-space quiet zone
/cpypixs pixs length array def
cpypixs 0 pixs 0 pixs length getinterval putinterval
/pixw pixs length pixx idiv def
/pixs [
0 pixx cpypixs length 1 sub {
/i exch def
cpypixs i pixx getinterval aload pop 0 0 0 0 0
} for
] def
/pixx pixx 5 add def
} if
b (ean13composite) eq b (ean8composite) eq or b (upcacomposite) eq or b (upcecomposite) eq or {
d (|) search {
/linear exch def
pop pop
linear ( ) search { % Have add-on?
pop pop pop
% Remove last row from pixs array which just contains add-on overhang
/pixs [ pixs 0 pixs length pixx sub getinterval aload pop ] def
} { pop } ifelse
} { pop } ifelse
} if
/xs systemdict /xs known { systemdict /xs get cvi } { 0 } ifelse def
/xe systemdict /xe known { systemdict /xe get cvi } { 0 } ifelse def
Binary file not shown.
+1 -1
View File
@@ -324,7 +324,7 @@ extern "C" {
#define FAST_MODE 0x0080 /* Use faster if less optimal encodation or other shortcuts if available */
/* (affects AZTEC, 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 */
/* Note: currently Code 128 and Data Matrix only */
#define GS1SYNTAXENGINE_MODE 0x0200 /* Use the GS1 Syntax Engine (if available) to strictly validate GS1 input */
#define GS1RAW_MODE 0x0400 /* Process GS1 data literally (no AI delimiters), parsing GSs as FNC1s */