mirror of
https://git.code.sf.net/p/zint/code
synced 2026-06-15 10:03:36 +00:00
AZTEC: add manual FNC1 support:
improve P/S vs P/L choice when have ECI; add ZINT_DEBUG_TEST dump AUSPOST: allow variable length data input DATAMATRIX: do `EXTRA_ESCAPE_MODE` processing up front & check have non-zero length afterwards; disallow `READER_INIT` and `EXTRA_ESCAPE_MODE`; general: add new `z_zero_fill()` func & use; add new `z_extra_escape_position_fnc1()` helper; in `z_ct_set_seg_extra_escapes_eci` check position FNC1 whether or not have ECI library: escape_char_process: note escaped backslash followed by caret by passes `EXTRA_ESCAPE_MODE` check test suite: BWIPP: update to latest; support AUSPOST variants; process `EXTRA_ESCAPE_MODE` escaping up front
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
Version 2.16.0.9 (dev) not released yet (2026-04-22)
|
||||
Version 2.16.0.9 (dev) not released yet (2026-04-27)
|
||||
====================================================
|
||||
|
||||
**Incompatible changes**
|
||||
@@ -34,8 +34,9 @@ Changes
|
||||
- DATAMATRIX: new options "--dmb256=" (`option_3 = DM_B256_START`) & "--dmc40="
|
||||
(`option_3 = DM_C40_START`) to allow forcing of initial encodation for given
|
||||
no. (`option_1`) of initial characters, with 0 meaning all
|
||||
- DATAMATRIX: add manual FNC1 support
|
||||
- AUSPOST: support Null FCC (DPID all zeroes)
|
||||
- AZTEC/DATAMATRIX: add manual FNC1 support
|
||||
- AUSPOST: support FCC 00 Null (DPID all zeroes) and allow variable length data
|
||||
input
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
@@ -41,7 +41,7 @@ INTERNAL int zint_c25_inter_common(struct zint_symbol *symbol, unsigned char sou
|
||||
|
||||
/* Interleaved 2-of-5 (ITF-14) */
|
||||
INTERNAL int zint_itf14(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number, zeroes;
|
||||
int i, error_number;
|
||||
unsigned char local_source[14];
|
||||
unsigned char have_check_digit = '\0';
|
||||
unsigned char check_digit;
|
||||
@@ -70,11 +70,7 @@ INTERNAL int zint_itf14(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
|
||||
/* Add leading zeros as required */
|
||||
zeroes = 13 - length;
|
||||
for (i = 0; i < zeroes; i++) {
|
||||
local_source[i] = '0';
|
||||
}
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
z_zero_fill(source, length, local_source, 13);
|
||||
|
||||
/* Calculate the check digit - the same method used for EAN-13 */
|
||||
check_digit = (unsigned char) zint_gs1_check_digit(local_source, 13);
|
||||
@@ -128,7 +124,6 @@ INTERNAL int zint_dpleit(struct zint_symbol *symbol, unsigned char source[], int
|
||||
unsigned int count;
|
||||
int factor;
|
||||
unsigned char local_source[14];
|
||||
int zeroes;
|
||||
|
||||
count = 0;
|
||||
if (length > 13) {
|
||||
@@ -139,10 +134,7 @@ INTERNAL int zint_dpleit(struct zint_symbol *symbol, unsigned char source[], int
|
||||
"Invalid character at position %d in input (digits only)", i);
|
||||
}
|
||||
|
||||
zeroes = 13 - length;
|
||||
for (i = 0; i < zeroes; i++)
|
||||
local_source[i] = '0';
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
z_zero_fill(source, length, local_source, 13);
|
||||
|
||||
factor = 4;
|
||||
for (i = 12; i >= 0; i--) {
|
||||
@@ -169,7 +161,7 @@ INTERNAL int zint_dpleit(struct zint_symbol *symbol, unsigned char source[], int
|
||||
/* Deutsche Post Identcode */
|
||||
/* See dpleit() for (sort of) documentation reference */
|
||||
INTERNAL int zint_dpident(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int i, error_number, zeroes;
|
||||
int i, error_number;
|
||||
unsigned int count;
|
||||
int factor;
|
||||
unsigned char local_source[12];
|
||||
@@ -183,10 +175,7 @@ INTERNAL int zint_dpident(struct zint_symbol *symbol, unsigned char source[], in
|
||||
"Invalid character at position %d in input (digits only)", i);
|
||||
}
|
||||
|
||||
zeroes = 11 - length;
|
||||
for (i = 0; i < zeroes; i++)
|
||||
local_source[i] = '0';
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
z_zero_fill(source, length, local_source, 11);
|
||||
|
||||
factor = 4;
|
||||
for (i = 10; i >= 0; i--) {
|
||||
|
||||
+101
-116
@@ -30,10 +30,15 @@
|
||||
*/
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "reedsol.h"
|
||||
|
||||
static const char AusGDSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #";
|
||||
#define AUS_GDSET_F (IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F)
|
||||
|
||||
/* The contents of data_pattern conform to the following standard:
|
||||
/* The contents of encoding tables and data pattern `dest[]` conform to the following standard:
|
||||
0 = Tracker, Ascender and Descender
|
||||
1 = Tracker and Ascender
|
||||
2 = Tracker and Descender
|
||||
@@ -46,55 +51,38 @@ static const char AusNTable[10][2] = {
|
||||
|
||||
/* C Encoding Table (GDSET) */
|
||||
static const char AusCTable[64][3] = {
|
||||
{ 2,2,2 }, { 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,1,0 }, {3,1,1 },
|
||||
{ 3,1,2 }, { 3,2,0 }, { 3,2,1 }, { 3,2,2 }, { 0,0,0 }, {0,0,1 },
|
||||
{ 0,0,2 }, { 0,1,0 }, { 0,1,1 }, { 0,1,2 }, { 0,2,0 }, {0,2,1 },
|
||||
{ 0,2,2 }, { 1,0,0 }, { 1,0,1 }, { 1,0,2 }, { 1,1,0 }, {1,1,1 },
|
||||
{ 1,1,2 }, { 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 2,0,0 }, {2,0,1 },
|
||||
{ 2,0,2 }, { 2,1,0 }, { 2,1,1 }, { 2,1,2 }, { 2,2,0 }, {2,2,1 },
|
||||
{ 0,2,3 }, { 0,3,0 }, { 0,3,1 }, { 0,3,2 }, { 0,3,3 }, {1,0,3 },
|
||||
{ 1,1,3 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, { 1,3,2 }, {1,3,3 },
|
||||
{ 2,0,3 }, { 2,1,3 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, {2,3,2 },
|
||||
{ 2,3,3 }, { 3,0,3 }, { 3,1,3 }, { 3,2,3 }, { 3,3,0 }, {3,3,1 },
|
||||
{ 3,3,2 }, { 3,3,3 }, { 0,0,3 }, { 0,1,3 }
|
||||
{ 2,2,2 }, { 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,1,0 }, { 3,1,1 }, { 3,1,2 }, { 3,2,0 },
|
||||
{ 3,2,1 }, { 3,2,2 }, { 0,0,0 }, { 0,0,1 }, { 0,0,2 }, { 0,1,0 }, { 0,1,1 }, { 0,1,2 },
|
||||
{ 0,2,0 }, { 0,2,1 }, { 0,2,2 }, { 1,0,0 }, { 1,0,1 }, { 1,0,2 }, { 1,1,0 }, { 1,1,1 },
|
||||
{ 1,1,2 }, { 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 2,0,0 }, { 2,0,1 }, { 2,0,2 }, { 2,1,0 },
|
||||
{ 2,1,1 }, { 2,1,2 }, { 2,2,0 }, { 2,2,1 }, { 0,2,3 }, { 0,3,0 }, { 0,3,1 }, { 0,3,2 },
|
||||
{ 0,3,3 }, { 1,0,3 }, { 1,1,3 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, { 1,3,2 }, { 1,3,3 },
|
||||
{ 2,0,3 }, { 2,1,3 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, { 2,3,2 }, { 2,3,3 }, { 3,0,3 },
|
||||
{ 3,1,3 }, { 3,2,3 }, { 3,3,0 }, { 3,3,1 }, { 3,3,2 }, { 3,3,3 }, { 0,0,3 }, { 0,1,3 }
|
||||
};
|
||||
|
||||
/* Bar to Decimal Conversion Table (Reed-Solomon) */
|
||||
static const char AusBarTable[64][3] = {
|
||||
{ 0,0,0 }, { 0,0,1 }, { 0,0,2 }, { 0,0,3 }, { 0,1,0 }, { 0,1,1 },
|
||||
{ 0,1,2 }, { 0,1,3 }, { 0,2,0 }, { 0,2,1 }, { 0,2,2 }, { 0,2,3 },
|
||||
{ 0,3,0 }, { 0,3,1 }, { 0,3,2 }, { 0,3,3 }, { 1,0,0 }, { 1,0,1 },
|
||||
{ 1,0,2 }, { 1,0,3 }, { 1,1,0 }, { 1,1,1 }, { 1,1,2 }, { 1,1,3 },
|
||||
{ 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 },
|
||||
{ 1,3,2 }, { 1,3,3 }, { 2,0,0 }, { 2,0,1 }, { 2,0,2 }, { 2,0,3 },
|
||||
{ 2,1,0 }, { 2,1,1 }, { 2,1,2 }, { 2,1,3 }, { 2,2,0 }, { 2,2,1 },
|
||||
{ 2,2,2 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, { 2,3,2 }, { 2,3,3 },
|
||||
{ 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,0,3 }, { 3,1,0 }, { 3,1,1 },
|
||||
{ 3,1,2 }, { 3,1,3 }, { 3,2,0 }, { 3,2,1 }, { 3,2,2 }, { 3,2,3 },
|
||||
{ 3,3,0 }, { 3,3,1 }, { 3,3,2 }, { 3,3,3 }
|
||||
{ 0,0,0 }, { 0,0,1 }, { 0,0,2 }, { 0,0,3 }, { 0,1,0 }, { 0,1,1 }, { 0,1,2 }, { 0,1,3 },
|
||||
{ 0,2,0 }, { 0,2,1 }, { 0,2,2 }, { 0,2,3 }, { 0,3,0 }, { 0,3,1 }, { 0,3,2 }, { 0,3,3 },
|
||||
{ 1,0,0 }, { 1,0,1 }, { 1,0,2 }, { 1,0,3 }, { 1,1,0 }, { 1,1,1 }, { 1,1,2 }, { 1,1,3 },
|
||||
{ 1,2,0 }, { 1,2,1 }, { 1,2,2 }, { 1,2,3 }, { 1,3,0 }, { 1,3,1 }, { 1,3,2 }, { 1,3,3 },
|
||||
{ 2,0,0 }, { 2,0,1 }, { 2,0,2 }, { 2,0,3 }, { 2,1,0 }, { 2,1,1 }, { 2,1,2 }, { 2,1,3 },
|
||||
{ 2,2,0 }, { 2,2,1 }, { 2,2,2 }, { 2,2,3 }, { 2,3,0 }, { 2,3,1 }, { 2,3,2 }, { 2,3,3 },
|
||||
{ 3,0,0 }, { 3,0,1 }, { 3,0,2 }, { 3,0,3 }, { 3,1,0 }, { 3,1,1 }, { 3,1,2 }, { 3,1,3 },
|
||||
{ 3,2,0 }, { 3,2,1 }, { 3,2,2 }, { 3,2,3 }, { 3,3,0 }, { 3,3,1 }, { 3,3,2 }, { 3,3,3 }
|
||||
};
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include "common.h"
|
||||
#include "reedsol.h"
|
||||
|
||||
static unsigned char aus_convert_pattern(const char data, const int shift) {
|
||||
return data << shift;
|
||||
}
|
||||
|
||||
/* Adds Reed-Solomon error correction to auspost */
|
||||
static char *aus_rs_error(const char data_pattern[], char *d) {
|
||||
const int length = (int) (d - data_pattern);
|
||||
static char *aus_rs_error(const char dest[], char *d) {
|
||||
const int length = (int) (d - dest);
|
||||
int reader, triple_writer;
|
||||
unsigned char triple[31];
|
||||
unsigned char triple[17]; /* Max bars 67 - 12 (ECC) - 4 (start/stop) = 51 / 3 */
|
||||
unsigned char result[5];
|
||||
rs_t rs;
|
||||
|
||||
for (reader = 2, triple_writer = 0; reader < length; reader += 3, triple_writer++) {
|
||||
triple[triple_writer] = aus_convert_pattern(data_pattern[reader], 4)
|
||||
| aus_convert_pattern(data_pattern[reader + 1], 2)
|
||||
| aus_convert_pattern(data_pattern[reader + 2], 0);
|
||||
triple[triple_writer] = (dest[reader] << 4) | (dest[reader + 1] << 2) | dest[reader + 2];
|
||||
}
|
||||
|
||||
zint_rs_init_gf(&rs, 0x43);
|
||||
@@ -120,7 +108,7 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in
|
||||
/* Null Standard Barcode 2 Barcode 3 Reply Route Redirect */
|
||||
{ '0','0' }, { '1','1' }, { '5','9' }, { '6','2' }, { '4','5' }, { '8','7' }, { '9','2' }
|
||||
};
|
||||
static const char start_stop[2] = { 1,3 };
|
||||
static const char start_stop[2] = { 1,3 }; /* Full,tracker */
|
||||
|
||||
int i;
|
||||
int error_number;
|
||||
@@ -128,88 +116,87 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in
|
||||
int loopey, reader;
|
||||
int h;
|
||||
|
||||
char data_pattern[200];
|
||||
char *d = data_pattern;
|
||||
char dest[67]; /* Max bars (Customer Barcode 3) */
|
||||
char *d = dest;
|
||||
int fcc_idx; /* Index into `fccs[]` */
|
||||
unsigned char local_source[30];
|
||||
int zeroes = 0;
|
||||
unsigned char src_buf[8]; /* For zero-padded DPID */
|
||||
int not_all_digits = 0;
|
||||
const int content_segs = symbol->output_options & BARCODE_CONTENT_SEGS;
|
||||
|
||||
/* Suppress clang-tidy-21 clang-analyzer-security.ArrayBound */
|
||||
assert(symbol->symbology == BARCODE_AUSPOST || symbol->symbology == BARCODE_AUSREPLY
|
||||
|| symbol->symbology == BARCODE_AUSROUTE || symbol->symbology == BARCODE_AUSREDIRECT);
|
||||
|
||||
/* Do all of the length checking first to avoid stack smashing */
|
||||
if (symbol->symbology == BARCODE_AUSPOST) {
|
||||
if (length != 8 && length != 13 && length != 16 && length != 18 && length != 23) {
|
||||
if (length > 23) {
|
||||
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 401,
|
||||
"Input length %d wrong (8, 13, 16, 18 or 23 characters required)", length);
|
||||
"Input length %d too long (maximum 23)", length);
|
||||
}
|
||||
} else if (length > 8) {
|
||||
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 403, "Input length %d too long (maximum 8)", length);
|
||||
}
|
||||
|
||||
/* Check input immediately to catch invalid chars */
|
||||
if ((i = z_not_sane(AUS_GDSET_F, source, length))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 404,
|
||||
"Invalid character at position %d in input (alphanumerics, space and \"#\" only)", i);
|
||||
}
|
||||
|
||||
if (symbol->symbology == BARCODE_AUSPOST) {
|
||||
/* Format control code (FCC) */
|
||||
switch (length) {
|
||||
case 8:
|
||||
fcc_idx = 1; /* FCC 11 Standard Customer */
|
||||
break;
|
||||
case 13:
|
||||
fcc_idx = 2; /* FCC 59 Customer 2 */
|
||||
break;
|
||||
case 16:
|
||||
fcc_idx = 2; /* FCC 59 Customer 2 */
|
||||
if ((i = z_not_sane(NEON_F, source, length))) {
|
||||
not_all_digits = z_not_sane(NEON_F, source, length);
|
||||
if (length <= 8) {
|
||||
if (not_all_digits) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 405,
|
||||
"Invalid character at position %d in DPID (digits only for Standard Customer Barcode)",
|
||||
not_all_digits);
|
||||
}
|
||||
if (z_zero_fill(source, length, src_buf, 8)) {
|
||||
source = src_buf;
|
||||
length = 8;
|
||||
}
|
||||
fcc_idx = 1; /* FCC 11 Standard Customer */
|
||||
} else {
|
||||
if (not_all_digits) {
|
||||
if ((i = z_not_sane(NEON_F, source, 8))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 402,
|
||||
"Invalid character at position %d in input (digits only for FCC 59 length 16)",
|
||||
i);
|
||||
"Invalid character at position %d in DPID (digits only)", i);
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
fcc_idx = 3; /* FCC 62 Customer 3 */
|
||||
break;
|
||||
case 23:
|
||||
fcc_idx = 3; /* FCC 62 Customer 3 */
|
||||
if ((i = z_not_sane(NEON_F, source, length))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 406,
|
||||
"Invalid character at position %d in input (digits only for FCC 62 length 23)",
|
||||
i);
|
||||
if ((i = z_not_sane(AUS_GDSET_F, source + 8, length - 8))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 404,
|
||||
"Invalid character at position %d in input (alphanumerics, space and \"#\" only)",
|
||||
i + 8);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (length > 18) {
|
||||
if (not_all_digits) {
|
||||
return ZEXT z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 407,
|
||||
"Invalid character at position %1$d in input (digits only for Customer Barcode 3"
|
||||
" length %2$d)", not_all_digits, length);
|
||||
}
|
||||
fcc_idx = 3; /* FCC 62 Customer Barcode 3 all-digits */
|
||||
} else if (length > 16 || (length > 13 && not_all_digits)) {
|
||||
fcc_idx = 3; /* FCC 62 Customer Barcode 3 */
|
||||
} else {
|
||||
fcc_idx = 2; /* FCC 59 Customer Barcode 2 */
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if DPID all zeros (Null) */
|
||||
for (i = 0; i < 8 && source[i] == '0'; i++);
|
||||
if (i == 8) {
|
||||
fcc_idx = 0; /* Null */
|
||||
if (z_chr_cnt(source, 8, '0') == 8) {
|
||||
fcc_idx = 0; /* FCC 00 Null */
|
||||
}
|
||||
} else {
|
||||
fcc_idx = symbol->symbology - BARCODE_AUSREPLY + 4; /* 4 (FCC 45), 5 (FCC 87) or 6 (FCC 92) */
|
||||
if (length > 8) {
|
||||
return z_errtxtf(ZINT_ERROR_TOO_LONG, symbol, 403, "Input length %d too long (maximum 8)", length);
|
||||
}
|
||||
|
||||
if ((i = z_not_sane(NEON_F, source, length))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 406,
|
||||
"Invalid character at position %d in DPID (digits only)", i);
|
||||
}
|
||||
/* Add leading zeros as required */
|
||||
zeroes = 8 - length;
|
||||
memset(local_source, '0', zeroes);
|
||||
if (z_zero_fill(source, length, src_buf, 8)) {
|
||||
source = src_buf;
|
||||
length = 8;
|
||||
}
|
||||
|
||||
/* Format control code (FCC) */
|
||||
fcc_idx = symbol->symbology - BARCODE_AUSREPLY + 4; /* 4 (FCC 45), 5 (FCC 87) or 6 (FCC 92) */
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("AUSPOST FCC: %.2s\n", fccs[fcc_idx]);
|
||||
}
|
||||
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
length += zeroes;
|
||||
|
||||
/* Verify that the first 8 characters are numbers */
|
||||
if ((i = z_not_sane(NEON_F, local_source, 8))) {
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 405,
|
||||
"Invalid character at position %d in DPID (first 8 characters) (digits only)", i);
|
||||
}
|
||||
|
||||
/* Start character */
|
||||
memcpy(d, start_stop, 2);
|
||||
d += 2;
|
||||
@@ -221,49 +208,47 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in
|
||||
|
||||
/* Delivery Point Identifier (DPID) */
|
||||
for (reader = 0; reader < 8; reader++, d += 2) {
|
||||
memcpy(d, AusNTable[local_source[reader] - '0'], 2);
|
||||
memcpy(d, AusNTable[source[reader] - '0'], 2);
|
||||
}
|
||||
|
||||
/* Customer Information */
|
||||
if (length > 8) {
|
||||
if (length == 13 || length == 18) {
|
||||
if (not_all_digits) {
|
||||
for (reader = 8; reader < length; reader++, d += 3) {
|
||||
memcpy(d, AusCTable[z_posn(AusGDSET, local_source[reader])], 3);
|
||||
memcpy(d, AusCTable[z_posn(AusGDSET, source[reader])], 3);
|
||||
}
|
||||
} else if (length == 16 || length == 23) {
|
||||
} else {
|
||||
for (reader = 8; reader < length; reader++, d += 2) {
|
||||
memcpy(d, AusNTable[local_source[reader] - '0'], 2);
|
||||
memcpy(d, AusNTable[source[reader] - '0'], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Filler bar */
|
||||
h = (int) (d - data_pattern);
|
||||
switch (h) {
|
||||
case 22:
|
||||
case 37:
|
||||
case 52:
|
||||
*d++ = 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
/* Filler bar(s) */
|
||||
h = (int) (d - dest);
|
||||
assert(h < 53);
|
||||
for (i = h; i != 23 && i != 38 && i != 53; i++) {
|
||||
*d++ = 3; /* Tracker */
|
||||
}
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Filler: %d\n", i - h);
|
||||
}
|
||||
|
||||
/* Reed Solomon error correction */
|
||||
d = aus_rs_error(data_pattern, d);
|
||||
d = aus_rs_error(dest, d);
|
||||
|
||||
/* Stop character */
|
||||
memcpy(d, start_stop, 2);
|
||||
d += 2;
|
||||
|
||||
/* Turn the symbol into a bar pattern ready for plotting */
|
||||
h = (int) (d - data_pattern);
|
||||
h = (int) (d - dest);
|
||||
for (loopey = 0, writer = 0; loopey < h; loopey++, writer += 2) {
|
||||
if (data_pattern[loopey] == 1 || data_pattern[loopey] == 0) {
|
||||
if (dest[loopey] == 1 || dest[loopey] == 0) {
|
||||
z_set_module(symbol, 0, writer);
|
||||
}
|
||||
z_set_module(symbol, 1, writer);
|
||||
if (data_pattern[loopey] == 2 || data_pattern[loopey] == 0) {
|
||||
if (dest[loopey] == 2 || dest[loopey] == 0) {
|
||||
z_set_module(symbol, 2, writer);
|
||||
}
|
||||
}
|
||||
@@ -289,7 +274,7 @@ INTERNAL int zint_auspost(struct zint_symbol *symbol, unsigned char source[], in
|
||||
error_number = zint_daft_set_height(symbol, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (content_segs && z_ct_cpy_cat(symbol, fccs[fcc_idx], 2, '\xFF' /*separator (none)*/, local_source, length)) {
|
||||
if (content_segs && z_ct_cpy_cat(symbol, fccs[fcc_idx], 2, '\xFF' /*separator (none)*/, source, length)) {
|
||||
return ZINT_ERROR_MEMORY; /* `z_ct_cpy_cat()` only fails with OOM */
|
||||
}
|
||||
|
||||
|
||||
+131
-86
@@ -146,8 +146,8 @@ static void az_print_modes(const char *modes, const int length) {
|
||||
}
|
||||
|
||||
/* Determine encoding modes using modified Annex H algorithm (`FAST_MODE`) */
|
||||
static int az_text_modes(char modes[], unsigned char source[], int length, const int gs1, const char initial_mode,
|
||||
const int debug_print) {
|
||||
static int az_text_modes(char modes[], unsigned char source[], const int length, const char *fncs,
|
||||
const char initial_mode, const int debug_print) {
|
||||
int i;
|
||||
char current_mode;
|
||||
int count;
|
||||
@@ -157,7 +157,7 @@ static int az_text_modes(char modes[], unsigned char source[], int length, const
|
||||
for (i = 0; i < length; i++) {
|
||||
if (!z_isascii(source[i]) || !AztecFlags[source[i]]) {
|
||||
modes[i] = AZ_B;
|
||||
} else if (gs1 && source[i] == '\x1D') {
|
||||
} else if (fncs[i] && source[i] == '\x1D') {
|
||||
modes[i] = AZ_P; /* For FLG(0) = FNC1 */
|
||||
} else {
|
||||
modes[i] = AztecModes[source[i]];
|
||||
@@ -774,8 +774,8 @@ static void az_dump_list(const struct az_state_list *list, const char *prefix) {
|
||||
fprintf(stderr, "%sSize %d\n", prefix, (int) list->used);
|
||||
for (i = 0; i < list->used; i++) {
|
||||
const struct az_state *state = list->states + i;
|
||||
fprintf(stderr, "%.*s %d: mode %d, Size(tokens) %d\n", pl, spaces, (int) i, state->mode,
|
||||
(int) state->tokens.used);
|
||||
fprintf(stderr, "%.*s %d: mode %d, Size(tokens) %d, bitCount %d, byteCount %d\n",
|
||||
pl, spaces, i, state->mode, state->tokens.used, state->bitCount, state->byteCount);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -859,15 +859,14 @@ static int az_UpdateStateForPair(const struct az_state *state, const int from, c
|
||||
/* Return a set of states that represent the possible ways of updating this state for the next character.
|
||||
The resulting set of states are added to `ret_list` */
|
||||
static int az_UpdateStateForChar(const struct az_state *state, const unsigned char *source, const int from,
|
||||
const int gs1, struct az_state_list *ret_list) {
|
||||
const int fnc1_if_gs, struct az_state_list *ret_list) {
|
||||
unsigned char ch = source[from];
|
||||
const int fnc1 = gs1 && ch == '\x1D';
|
||||
const int charInCurrentTable = (fnc1 && state->mode == AZ_P)
|
||||
|| (z_isascii(ch) && (AztecFlags[ch] & (1 << state->mode)));
|
||||
const int fnc1 = fnc1_if_gs && ch == '\x1D';
|
||||
if (z_isascii(ch)) {
|
||||
const int charInCurrentTable = fnc1 ? state->mode == AZ_P : AztecFlags[ch] & (1 << state->mode);
|
||||
int mode;
|
||||
for (mode = 0; mode < AZ_NUM_MODES; mode++) {
|
||||
const int charInModeTable = (fnc1 && mode == AZ_P) || (AztecFlags[ch] & (1 << mode));
|
||||
const int charInModeTable = fnc1 ? mode == AZ_P : AztecFlags[ch] & (1 << mode);
|
||||
if (charInModeTable) {
|
||||
/* Try generating the char by latching to its mode */
|
||||
if (!charInCurrentTable || mode == state->mode || (mode == AZ_D && !fnc1)) {
|
||||
@@ -900,7 +899,7 @@ static int az_UpdateStateForChar(const struct az_state *state, const unsigned ch
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!fnc1 && (state->byteCount > 0 || !charInCurrentTable)) {
|
||||
if (!fnc1 && (state->byteCount > 0 || !z_isascii(ch) || !(AztecFlags[ch] & (1 << state->mode)))) {
|
||||
/* It's never worthwhile to go into B/S mode if not already in B/S mode, and the char exists in current mode.
|
||||
That can never save bits over just outputting the char in the current mode */
|
||||
if (!az_AddByteShiftChar(state, from, -1 /*from2*/, ret_list)) {
|
||||
@@ -937,7 +936,7 @@ static int az_UpdateStateListForPair(struct az_state_list *list, const int from,
|
||||
/* Update a set of states for a new character by updating each state for the new character, merging the results,
|
||||
and then removing the non-optimal states */
|
||||
static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned char *source, const int from,
|
||||
const int gs1) {
|
||||
const int fnc1_if_gs) {
|
||||
int i;
|
||||
struct az_state_list s_ret_list;
|
||||
struct az_state_list *ret_list = &s_ret_list;
|
||||
@@ -945,7 +944,7 @@ static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < list->used; i++) {
|
||||
if (!az_UpdateStateForChar(list->states + i, source, from, gs1, ret_list)) {
|
||||
if (!az_UpdateStateForChar(list->states + i, source, from, fnc1_if_gs, ret_list)) {
|
||||
az_state_list_free(ret_list);
|
||||
return 0;
|
||||
}
|
||||
@@ -968,8 +967,8 @@ static int az_UpdateStateListForChar(struct az_state_list *list, const unsigned
|
||||
/* Copyright 2016 Huy Cuong Nguyen */ /* zxing-cpp */
|
||||
/* SPDX-License-Identifier: Apache-2.0 */
|
||||
/* Note that a bitstream that is encoded to be shortest based on mode choices may not be so after bit-stuffing */
|
||||
static int az_binary_string(unsigned char source[], const int length, int bp,
|
||||
char binary_string[AZTEC_MAP_POSN_MAX + 1], const int gs1, const char initial_mode,
|
||||
static int az_binary_string(const unsigned char source[], const int length, int bp,
|
||||
char binary_string[AZTEC_MAP_POSN_MAX + 1], const char *fncs, const char initial_mode,
|
||||
char *p_current_mode) {
|
||||
struct az_state_list s_state_list;
|
||||
struct az_state_list *list = &s_state_list;
|
||||
@@ -1000,7 +999,7 @@ static int az_binary_string(unsigned char source[], const int length, int bp,
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
if (!az_UpdateStateListForChar(list, source, i, gs1)) {
|
||||
if (!az_UpdateStateListForChar(list, source, i, fncs[i])) {
|
||||
az_state_list_free(list);
|
||||
return 0;
|
||||
}
|
||||
@@ -1061,37 +1060,23 @@ static int az_binary_string(unsigned char source[], const int length, int bp,
|
||||
}
|
||||
|
||||
/* Calculate the binary size */
|
||||
static int az_text_size(const char *modes, const unsigned char *source, int length, const int gs1, const int set_gs1,
|
||||
static int az_text_size(const char *modes, const unsigned char *source, const int length, const char* fncs,
|
||||
const int eci, const char initial_mode, const int eci_latch, int *byte_counts) {
|
||||
int i;
|
||||
int byte_i = 0;
|
||||
char current_mode = initial_mode;
|
||||
int size = 0;
|
||||
|
||||
if (set_gs1 && gs1) {
|
||||
if (eci == 0) {
|
||||
current_mode = AZ_D;
|
||||
size += 5 + 4 + 5 + 3;
|
||||
} else {
|
||||
size += 5 + 5 + 3;
|
||||
}
|
||||
}
|
||||
if (eci != 0) {
|
||||
if (eci) {
|
||||
if (initial_mode != AZ_P) {
|
||||
if (eci_latch) {
|
||||
if (initial_mode != AZ_M) {
|
||||
if (initial_mode == AZ_D) {
|
||||
size += 4;
|
||||
}
|
||||
size += 5;
|
||||
}
|
||||
size += 5;
|
||||
size += AztecLatchNum[(int) initial_mode][AZ_P];
|
||||
current_mode = AZ_P;
|
||||
} else {
|
||||
size += initial_mode == AZ_D ? 4 : 5;
|
||||
}
|
||||
}
|
||||
size += 5 + 3 + 4 + 4 * ((eci > 9) + (eci > 99) + (eci > 999) + (eci > 9999) + (eci > 99999));
|
||||
size += 5 + 3 + 4 + 4 * ((eci >= 10) + (eci >= 100) + (eci >= 1000) + (eci >= 10000) + (eci >= 100000));
|
||||
}
|
||||
for (i = 0; i < length; i++) {
|
||||
if (modes[i] != current_mode) {
|
||||
@@ -1154,7 +1139,7 @@ static int az_text_size(const char *modes, const unsigned char *source, int leng
|
||||
|
||||
if (modes[i] == AZ_P || (modes[i] & AZ_PS)) {
|
||||
size += 5;
|
||||
if (gs1 && source[i] == '\x1D') {
|
||||
if (fncs[i] && source[i] == '\x1D') {
|
||||
size += 3;
|
||||
}
|
||||
} else if (modes[i] == AZ_D && !(modes[i] & AZ_US)) {
|
||||
@@ -1168,9 +1153,8 @@ static int az_text_size(const char *modes, const unsigned char *source, int leng
|
||||
}
|
||||
|
||||
/* Determine encoding modes and encode */
|
||||
static int az_text_process(unsigned char *source, int length, int bp, char *binary_string, const int gs1,
|
||||
const int gs1_bp, const int eci, const int fast_encode, char *p_current_mode, int *data_length,
|
||||
const int debug) {
|
||||
static int az_text_process(unsigned char *source, const int length, int bp, char *binary_string, const char *fncs,
|
||||
const int eci, const int fast_encode, char *p_current_mode, int *data_length, const int debug) {
|
||||
int i, j;
|
||||
int reduced_length = 0; /* Suppress gcc-14 warning -Wmaybe-uninitialized */
|
||||
char *modes = (char *) z_alloca(length + 1);
|
||||
@@ -1180,7 +1164,6 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina
|
||||
int eci_latch = 0;
|
||||
char current_mode = p_current_mode ? *p_current_mode : AZ_U;
|
||||
const char initial_mode = current_mode;
|
||||
const int set_gs1 = bp == gs1_bp;
|
||||
const int initial_bp = bp;
|
||||
const int all_byte_only_or_uld = az_all_byte_only_or_uld(source, length); /* -1 if not */
|
||||
const int debug_print = debug & ZINT_DEBUG_PRINT;
|
||||
@@ -1190,35 +1173,14 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina
|
||||
const int debug_skip_all = 0;
|
||||
#endif
|
||||
|
||||
if (set_gs1 && gs1) {
|
||||
assert(initial_mode == AZ_U);
|
||||
if (eci == 0) {
|
||||
/* Latch to D/L to save a bit */
|
||||
current_mode = AZ_D;
|
||||
bp = z_bin_append_posn(30, 5, binary_string, bp); /* D/L */
|
||||
bp = z_bin_append_posn(0, 4 + 5 + 3, binary_string, bp); /* P/S FLG(0) = FNC1 */
|
||||
} else {
|
||||
bp = z_bin_append_posn(0, 5 + 5 + 3, binary_string, bp); /* P/S FLG(0) = FNC1 */
|
||||
}
|
||||
/* See if it's worthwhile latching to AZ_P when have ECI */
|
||||
} else if ((debug_skip_all || all_byte_only_or_uld == -1) && eci && initial_mode != AZ_P
|
||||
&& az_count_initial_puncts(source, length) > 2 + (initial_mode == AZ_D)) {
|
||||
assert(!gs1);
|
||||
eci_latch = 1;
|
||||
current_mode = AZ_P;
|
||||
}
|
||||
|
||||
if (eci != 0) {
|
||||
const int flg = 1 + (eci > 9) + (eci > 99) + (eci > 999) + (eci > 9999) + (eci > 99999);
|
||||
if (eci) {
|
||||
const int flg = 1 + (eci >= 10) + (eci >= 100) + (eci >= 1000) + (eci >= 10000) + (eci >= 100000);
|
||||
if (initial_mode != AZ_P) {
|
||||
if (eci_latch) {
|
||||
if (initial_mode != AZ_M) {
|
||||
if (initial_mode == AZ_D) {
|
||||
bp = z_bin_append_posn(14, 4, binary_string, bp); /* U/L */
|
||||
}
|
||||
bp = z_bin_append_posn(29, 5, binary_string, bp); /* M/L */
|
||||
}
|
||||
bp = z_bin_append_posn(30, 5, binary_string, bp); /* P/L */
|
||||
/* See if it's worthwhile latching to AZ_P */
|
||||
if ((eci_latch = az_count_initial_puncts(source, length) >= flg + (initial_mode == AZ_D))) {
|
||||
bp = z_bin_append_posn(AztecLatch[(int) initial_mode][AZ_P], AztecLatchNum[(int) initial_mode][AZ_P],
|
||||
binary_string, bp);
|
||||
current_mode = AZ_P;
|
||||
} else {
|
||||
bp = z_bin_append_posn(0, initial_mode == AZ_D ? 4 : 5, binary_string, bp); /* P/S */
|
||||
}
|
||||
@@ -1249,9 +1211,9 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina
|
||||
memset(modes, all_byte_only_or_uld, length);
|
||||
reduced_length = length;
|
||||
} else if (fast_encode) {
|
||||
reduced_length = az_text_modes(modes, source, length, gs1, current_mode, debug_print);
|
||||
reduced_length = az_text_modes(modes, source, length, fncs, current_mode, debug_print);
|
||||
} else {
|
||||
bp = az_binary_string(source, length, bp, binary_string, gs1, current_mode, ¤t_mode);
|
||||
bp = az_binary_string(source, length, bp, binary_string, fncs, current_mode, ¤t_mode);
|
||||
if (bp == 0 || bp > AZTEC_BIN_CAPACITY) {
|
||||
return bp == 0 ? ZINT_ERROR_MEMORY : ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
@@ -1260,7 +1222,7 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina
|
||||
}
|
||||
|
||||
if (!size) {
|
||||
size = az_text_size(modes, source, reduced_length, gs1, set_gs1, eci, initial_mode, eci_latch, byte_counts);
|
||||
size = az_text_size(modes, source, reduced_length, fncs, eci, initial_mode, eci_latch, byte_counts);
|
||||
if (size == 0 || bp + size > AZTEC_BIN_CAPACITY) {
|
||||
return ZINT_ERROR_TOO_LONG;
|
||||
}
|
||||
@@ -1342,7 +1304,7 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina
|
||||
}
|
||||
|
||||
if (modes[i] == AZ_P || (modes[i] & AZ_PS)) {
|
||||
if (gs1 && source[i] == '\x1D') {
|
||||
if (fncs[i] && source[i] == '\x1D') {
|
||||
bp = z_bin_append_posn(0, 5 + 3, binary_string, bp); /* FLG(0) = FNC1 */
|
||||
} else {
|
||||
bp = z_bin_append_posn(AztecChar[AZ_P][source[i]], 5, binary_string, bp);
|
||||
@@ -1371,23 +1333,85 @@ static int az_text_process(unsigned char *source, int length, int bp, char *bina
|
||||
|
||||
/* Call `az_text_process()` for each segment */
|
||||
static int az_text_process_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count, int bp,
|
||||
char binary_string[], const int gs1, const int gs1_bp, int *data_length) {
|
||||
char binary_string[], const int gs1, int *data_length) {
|
||||
int i;
|
||||
char current_mode = AZ_U;
|
||||
int have_extra_escapes = 0;
|
||||
int position_fnc1 = 0;
|
||||
const int fast_encode = symbol->input_mode & FAST_MODE;
|
||||
const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE;
|
||||
/* Raw text dealt with by `ZBarcode_Encode_Segs()`, except for `eci` feedback.
|
||||
Note not updating `eci` for GS1 mode as not converted */
|
||||
const int content_segs = !gs1 && (symbol->output_options & BARCODE_CONTENT_SEGS);
|
||||
|
||||
if (gs1 || (extra_escape_mode
|
||||
&& (position_fnc1 = z_extra_escape_position_fnc1(segs[0].source, segs[0].length)))) {
|
||||
unsigned char *source = segs[0].source;
|
||||
const int length = segs[0].length;
|
||||
if (position_fnc1) {
|
||||
if (position_fnc1 == 4) {
|
||||
bp = z_bin_append_posn(AztecChar[AZ_U][source[0]], 5, binary_string, bp);
|
||||
} else if (position_fnc1 == 5) {
|
||||
current_mode = AZ_D;
|
||||
bp = z_bin_append_posn(30, 5, binary_string, bp); /* D/L */
|
||||
bp = z_bin_append_posn(AztecChar[AZ_D][source[0]], 4, binary_string, bp);
|
||||
bp = z_bin_append_posn(AztecChar[AZ_D][source[1]], 4, binary_string, bp);
|
||||
}
|
||||
have_extra_escapes = 1;
|
||||
}
|
||||
if (gs1 || (position_fnc1 <= 4 && length > position_fnc1 && z_isdigit(source[position_fnc1]))) {
|
||||
assert(current_mode == AZ_U);
|
||||
/* Latch to D/L to save a bit */
|
||||
current_mode = AZ_D;
|
||||
bp = z_bin_append_posn(30, 5, binary_string, bp); /* D/L */
|
||||
}
|
||||
/* See if it's worthwhile latching to AZ_P */
|
||||
if (az_count_initial_puncts(source + position_fnc1, length - position_fnc1) >= 1 + !segs[0].eci) {
|
||||
bp = z_bin_append_posn(AztecLatch[(int) current_mode][AZ_P], AztecLatchNum[(int) current_mode][AZ_P],
|
||||
binary_string, bp);
|
||||
bp = z_bin_append_posn(0, 5 + 3, binary_string, bp); /* FLG(0) = FNC1 */
|
||||
current_mode = AZ_P;
|
||||
} else {
|
||||
bp = z_bin_append_posn(0, 4 + (current_mode != AZ_D) + 5 + 3, binary_string, bp); /* P/S FLG(0) = FNC1 */
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < seg_count; i++) {
|
||||
int error_number;
|
||||
if ((error_number = az_text_process(segs[i].source, segs[i].length, bp, binary_string, gs1, gs1_bp,
|
||||
segs[i].eci, fast_encode, ¤t_mode, &bp, symbol->debug))) {
|
||||
return error_number;
|
||||
unsigned char *source = segs[i].source + position_fnc1;
|
||||
int length = segs[i].length - position_fnc1;
|
||||
if (length) {
|
||||
unsigned char *src_buf = (unsigned char *) z_alloca(length + 1);
|
||||
char *fncs = (char *) z_alloca(length);
|
||||
|
||||
if (gs1) {
|
||||
memset(fncs, 1, length);
|
||||
} else {
|
||||
memset(fncs, 0, length);
|
||||
if (extra_escape_mode) {
|
||||
if ((error_number = z_extra_escapes(symbol, source, &length, segs[i].eci, src_buf, fncs,
|
||||
&have_extra_escapes))) {
|
||||
return error_number;
|
||||
}
|
||||
if (have_extra_escapes) {
|
||||
source = src_buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((error_number = az_text_process(source, length, bp, binary_string, fncs, segs[i].eci, fast_encode,
|
||||
¤t_mode, &bp, symbol->debug))) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
position_fnc1 = 0;
|
||||
}
|
||||
|
||||
*data_length = bp;
|
||||
@@ -1568,8 +1592,8 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
int error_number;
|
||||
int compact, data_length, data_maxsize, codeword_size, adjusted_length;
|
||||
int bp = 0;
|
||||
int gs1_bp = 0;
|
||||
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
|
||||
const int extra_escape_mode = symbol->input_mode & EXTRA_ESCAPE_MODE;
|
||||
const int reader_init = symbol->output_options & READER_INIT;
|
||||
const int compact_loop_start = reader_init ? 1 : 4; /* Compact 2-4 excluded from Reader Initialisation */
|
||||
const int debug_print = symbol->debug & ZINT_DEBUG_PRINT;
|
||||
@@ -1587,10 +1611,23 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
if (gs1 && reader_init) {
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 501, "Cannot use Reader Initialisation in GS1 mode");
|
||||
}
|
||||
if (extra_escape_mode) {
|
||||
if (symbol->symbology != BARCODE_AZTEC) {
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 805,
|
||||
"Can only use Extra Escape mode with non-variant Aztec Code");
|
||||
}
|
||||
if (gs1) {
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 806, "Cannot use Extra Escape mode in GS1 mode");
|
||||
}
|
||||
if (reader_init) {
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 807, "Cannot use Reader Initialisation in Extra Escape mode");
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol->structapp.count) {
|
||||
/* Structured Append info as string <SP> + ID + <SP> + index + count + NUL */
|
||||
unsigned char sa_src[1 + sizeof(symbol->structapp.id) + 1 + 1 + 1 + 1] = {0};
|
||||
char fncs[36] = {0}; /* ' ' + ID (32) + ' ' + 1 + 1 = 36 */
|
||||
int sa_len;
|
||||
int id_len;
|
||||
|
||||
@@ -1611,6 +1648,7 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 703, "Structured Append ID cannot contain spaces");
|
||||
}
|
||||
|
||||
/* Starting with M/L U/L signals Structured Append */
|
||||
bp = z_bin_append_posn(29, 5, binary_string, bp); /* M/L */
|
||||
bp = z_bin_append_posn(29, 5, binary_string, bp); /* U/L */
|
||||
|
||||
@@ -1628,20 +1666,22 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
symbol->structapp.count, symbol->structapp.index, symbol->structapp.id, sa_src);
|
||||
}
|
||||
|
||||
(void) az_text_process(sa_src, sa_len, bp, binary_string, 0 /*gs1*/, 0 /*gs1_bp*/, 0 /*eci*/,
|
||||
0 /*fast_encode*/, NULL /*p_current_mode*/, &bp, symbol->debug);
|
||||
(void) az_text_process(sa_src, sa_len, bp, binary_string, fncs, 0 /*eci*/, 0 /*fast_encode*/,
|
||||
NULL /*p_current_mode*/, &bp, symbol->debug);
|
||||
/* Will be in U/L due to uppercase A-Z index/count indicators at end */
|
||||
gs1_bp = bp; /* Initial FNC1 (FLG0) position */
|
||||
}
|
||||
|
||||
if ((error_number = az_text_process_segs(symbol, segs, seg_count, bp, binary_string, gs1, gs1_bp,
|
||||
&data_length))) {
|
||||
assert(error_number == ZINT_ERROR_TOO_LONG || error_number == ZINT_ERROR_MEMORY);
|
||||
if ((error_number = az_text_process_segs(symbol, segs, seg_count, bp, binary_string, gs1, &data_length))) {
|
||||
assert(error_number == ZINT_ERROR_TOO_LONG || error_number == ZINT_ERROR_MEMORY
|
||||
|| error_number == ZINT_ERROR_INVALID_DATA || error_number == ZINT_ERROR_INVALID_OPTION);
|
||||
if (error_number == ZINT_ERROR_TOO_LONG) {
|
||||
return z_errtxt(error_number, symbol, 502,
|
||||
"Input too long, requires too many codewords (maximum " AZ_BIN_CAP_CWDS_S ")");
|
||||
}
|
||||
return z_errtxt(error_number, symbol, 804, "Insufficient memory for optimized encodation");
|
||||
if (error_number == ZINT_ERROR_MEMORY) {
|
||||
return z_errtxt(error_number, symbol, 804, "Insufficient memory for optimized encodation");
|
||||
}
|
||||
return error_number; /* EXTRA_ESCAPE_MODE errors, `errtxt` set */
|
||||
}
|
||||
assert(data_length > 0); /* Suppress clang-tidy warning: clang-analyzer-core.UndefinedBinaryOperatorResult */
|
||||
|
||||
@@ -1859,7 +1899,6 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
break;
|
||||
case 12:
|
||||
if (!zint_rs_uint_init_gf(&rs_uint, 0x1069, 4095)) { /* Can fail on malloc() */
|
||||
/* Note using AUSPOST error nos range as out of 50x ones & 51x taken by CODEONE */
|
||||
return z_errtxt(ZINT_ERROR_MEMORY, symbol, 700, "Insufficient memory for Reed-Solomon log tables");
|
||||
}
|
||||
zint_rs_uint_init_code(&rs_uint, ecc_blocks, 1);
|
||||
@@ -1880,6 +1919,12 @@ INTERNAL int zint_aztec(struct zint_symbol *symbol, struct zint_seg segs[], cons
|
||||
bit_pattern[i] = adjusted_string[total_bits - i - 1];
|
||||
}
|
||||
|
||||
#ifdef ZINT_TEST
|
||||
if (symbol->debug & ZINT_DEBUG_TEST) {
|
||||
z_debug_test_codeword_dump(symbol, ZCUCP(bit_pattern), total_bits);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now add the symbol descriptor */
|
||||
memset(desc_data, 0, 4);
|
||||
memset(desc_ecc, 0, 6);
|
||||
|
||||
@@ -49,7 +49,7 @@ static int nve18_or_ean14(struct zint_symbol *symbol, const unsigned char source
|
||||
};
|
||||
const int idx = data_len == 17;
|
||||
unsigned char ean128_equiv[23];
|
||||
int i, zeroes;
|
||||
int i;
|
||||
unsigned char have_check_digit = '\0';
|
||||
unsigned char check_digit;
|
||||
int error_number;
|
||||
@@ -79,10 +79,8 @@ static int nve18_or_ean14(struct zint_symbol *symbol, const unsigned char source
|
||||
length--;
|
||||
}
|
||||
|
||||
zeroes = data_len - length;
|
||||
memcpy(ean128_equiv, prefix[idx][!(symbol->input_mode & GS1PARENS_MODE)], 4);
|
||||
memset(ean128_equiv + 4, '0', zeroes);
|
||||
memcpy(ean128_equiv + 4 + zeroes, source, length);
|
||||
z_zero_fill(source, length, ean128_equiv + 4, data_len);
|
||||
|
||||
check_digit = (unsigned char) zint_gs1_check_digit(ean128_equiv + 4, data_len);
|
||||
if (have_check_digit && have_check_digit != check_digit) {
|
||||
|
||||
+51
-9
@@ -81,6 +81,20 @@ INTERNAL int z_chr_cnt(const unsigned char source[], const int length, const uns
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Zero-fill `dest` buffer, appending `source'. Returns no. of zeroes added */
|
||||
INTERNAL int z_zero_fill(const unsigned char source[], const int length, unsigned char *dest, const int dest_length) {
|
||||
const int zeroes = dest_length - length;
|
||||
if (zeroes >= 0) {
|
||||
if (zeroes > 0) {
|
||||
memset(dest, '0', zeroes);
|
||||
}
|
||||
memcpy(dest + zeroes, source, length);
|
||||
} else {
|
||||
memcpy(dest, source, length);
|
||||
}
|
||||
return zeroes;
|
||||
}
|
||||
|
||||
/* Flag table for `is_chr()` and `z_not_sane()` */
|
||||
#define IS_CLS_F (IS_CLI_F | IS_SIL_F)
|
||||
static const unsigned short flags[256] = {
|
||||
@@ -776,14 +790,38 @@ 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) {
|
||||
/* Check if `source` starts with manual FNC1 in 1st or 2nd position, returning length of extra escape sequence if so,
|
||||
else 0 */
|
||||
INTERNAL int z_extra_escape_position_fnc1(const unsigned char source[], const int length) {
|
||||
if (length >= 3) {
|
||||
if (source[0] == '\\' && source[1] == '^' && source[2] == '1') {
|
||||
return 3;
|
||||
}
|
||||
if (length >= 4) {
|
||||
if (z_isalpha(source[0]) && source[1] == '\\' && source[2] == '^' && source[3] == '1') {
|
||||
return 4;
|
||||
}
|
||||
if (length >= 5) {
|
||||
if (z_isdigit(source[0]) && z_isdigit(source[1]) && source[2] == '\\' && source[3] == '^'
|
||||
&& source[4] == '1') {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Process `source` for extra escape sequences, placing result in `dest`, updating `p_length`, and setting `fncs` with
|
||||
any found FNC1s. Sets `p_have_extra_escapes` if any sequences found. `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[], int *p_length, const int eci,
|
||||
unsigned char *dest, char *fncs, int *p_have_extra_escapes) {
|
||||
const int length = *p_length;
|
||||
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");
|
||||
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] == '^') {
|
||||
@@ -806,7 +844,12 @@ INTERNAL int z_extra_escapes(struct zint_symbol *symbol, const unsigned char sou
|
||||
dest[j++] = source[i];
|
||||
}
|
||||
}
|
||||
*p_len = j;
|
||||
if (j != length) {
|
||||
assert(j > 0 && j < length);
|
||||
dest[j] = '\0';
|
||||
*p_length = j;
|
||||
*p_have_extra_escapes = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1029,7 +1072,6 @@ INTERNAL void z_ct_set_seg_extra_escapes_eci(struct zint_symbol *symbol, const i
|
||||
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);
|
||||
@@ -1047,7 +1089,7 @@ INTERNAL void z_ct_set_seg_extra_escapes_eci(struct zint_symbol *symbol, const 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]))
|
||||
if (seg_idx != 0 || j > 2 || (j == 1 && !z_isalpha(source[0]))
|
||||
|| (j == 2 && (!z_isdigit(source[0]) || !z_isdigit(source[1]))) ) {
|
||||
source[j++] = '\x1D'; /* GS */
|
||||
}
|
||||
|
||||
+12
-5
@@ -167,6 +167,9 @@ INTERNAL void z_to_upper(unsigned char source[], const int length);
|
||||
/* Returns the number of times a character `ch` occurs in `source` */
|
||||
INTERNAL int z_chr_cnt(const unsigned char source[], const int length, const unsigned char ch);
|
||||
|
||||
/* Zero-fill `dest` buffer, appending `source'. Returns no. of zeroes added */
|
||||
INTERNAL int z_zero_fill(const unsigned char source[], const int length, unsigned char *dest, const int dest_length);
|
||||
|
||||
/* `z_is_chr()` & `z_not_sane()` flags */
|
||||
#define IS_SPC_F 0x0001 /* Space */
|
||||
#define IS_HSH_F 0x0002 /* Hash sign # */
|
||||
@@ -308,11 +311,15 @@ 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);
|
||||
/* Check if `source` starts with manual FNC1 in 1st or 2nd position, returning length of extra escape sequence if so,
|
||||
else 0 */
|
||||
INTERNAL int z_extra_escape_position_fnc1(const unsigned char source[], const int length);
|
||||
|
||||
/* Process `source` for extra escape sequences, placing result in `dest`, updating `p_length`, and setting `fncs` with
|
||||
any found FNC1s. Sets `p_have_extra_escapes` if any sequences found. `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[], int *p_length, const int eci,
|
||||
unsigned char *dest, char *fncs, int *p_have_extra_escapes);
|
||||
|
||||
|
||||
/* Treats source as ISO/IEC 8859-1 and copies into `symbol->text`, converting to UTF-8. Control chars (incl. DEL) and
|
||||
|
||||
+83
-70
@@ -1662,6 +1662,7 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
int tp = 0;
|
||||
int in_macro = 0;
|
||||
int have_extra_escapes = 0;
|
||||
int position_fnc1 = 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 */
|
||||
@@ -1737,16 +1738,29 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
|
||||
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, 846,
|
||||
"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");
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 844, "Cannot use Extra Escape mode in GS1 mode");
|
||||
}
|
||||
|
||||
if (gs1) {
|
||||
target[tp++] = 232;
|
||||
target[tp++] = 232; /* FNC1 */
|
||||
if (debug_print) fputs("FN1 ", stdout);
|
||||
} /* FNC1 */
|
||||
} else if (extra_escape_mode) {
|
||||
if ((position_fnc1 = z_extra_escape_position_fnc1(segs[0].source, segs[0].length))) {
|
||||
if (position_fnc1 == 4) {
|
||||
target[tp++] = segs[0].source[0] + 1;
|
||||
if (debug_print) fputs("EEA ", stdout);
|
||||
} else if (position_fnc1 == 5) {
|
||||
target[tp++] = z_to_int(segs[0].source, 2) + 130;
|
||||
if (debug_print) fputs("EED ", stdout);
|
||||
}
|
||||
target[tp++] = 232; /* FNC1 */
|
||||
if (debug_print) fputs("FN1 ", stdout);
|
||||
have_extra_escapes = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (symbol->output_options & READER_INIT) {
|
||||
if (gs1) {
|
||||
@@ -1756,6 +1770,9 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 727,
|
||||
"Cannot have Structured Append and Reader Initialisation at the same time");
|
||||
}
|
||||
if (extra_escape_mode) {
|
||||
return z_errtxt(ZINT_ERROR_INVALID_OPTION, symbol, 847, "Cannot use Reader Initialisation in Extra Escape mode");
|
||||
}
|
||||
target[tp++] = 234; /* Reader Programming */
|
||||
if (debug_print) fputs("RP ", stdout);
|
||||
}
|
||||
@@ -1785,8 +1802,6 @@ 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;
|
||||
@@ -1798,75 +1813,72 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
len_dec += 2; /* Remove RS + EOT from end */
|
||||
}
|
||||
}
|
||||
source = segs[i].source + src_inc;
|
||||
length = segs[i].length - len_dec;
|
||||
source = segs[i].source + src_inc + position_fnc1;
|
||||
length = segs[i].length - len_dec - position_fnc1;
|
||||
|
||||
src_buf = (unsigned char *) z_alloca(length + 1);
|
||||
fncs = (char *) z_alloca(length);
|
||||
if (length) {
|
||||
unsigned char *src_buf = (unsigned char *) z_alloca(length + 1);
|
||||
char *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);
|
||||
c40_end = 45; /* Min */
|
||||
/* Allow specifying greater than 45 */
|
||||
if (have_c40 && (symbol->option_1 == 0 || symbol->option_1 > 45)) {
|
||||
c40_end = symbol->option_1 > 0 && symbol->option_1 < length ? symbol->option_1 : length;
|
||||
}
|
||||
/* `DM_C40_START` trumps `DM_B256_START` */
|
||||
} else if (have_c40) {
|
||||
if (symbol->option_1 == 0) {
|
||||
c40_end = length;
|
||||
} else if (symbol->option_1 < tot_length) {
|
||||
c40_end = 0;
|
||||
if (gs1) {
|
||||
memset(fncs, gs1 == 1, length);
|
||||
} else {
|
||||
c40_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length;
|
||||
}
|
||||
} else if (have_b256) {
|
||||
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) {
|
||||
b256_end = 0;
|
||||
} else {
|
||||
b256_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length;
|
||||
}
|
||||
/* 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;
|
||||
memset(fncs, 0, length);
|
||||
if (extra_escape_mode) {
|
||||
if ((error_number = z_extra_escapes(symbol, source, &length, segs[i].eci, src_buf, fncs,
|
||||
&have_extra_escapes))) {
|
||||
return error_number;
|
||||
}
|
||||
if (have_extra_escapes) {
|
||||
source = src_buf;
|
||||
}
|
||||
}
|
||||
b256_have_fnc1 = b256_end != b256_len;
|
||||
}
|
||||
}
|
||||
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 (mailmark) {
|
||||
assert(seg_count == 1);
|
||||
assert(length >= 45);
|
||||
c40_end = 45; /* Min */
|
||||
/* Allow specifying greater than 45 */
|
||||
if (have_c40 && (symbol->option_1 == 0 || symbol->option_1 > 45)) {
|
||||
c40_end = symbol->option_1 > 0 && symbol->option_1 < length ? symbol->option_1 : length;
|
||||
}
|
||||
/* `DM_C40_START` trumps `DM_B256_START` */
|
||||
} else if (have_c40) {
|
||||
if (symbol->option_1 == 0) {
|
||||
c40_end = length;
|
||||
} else if (symbol->option_1 < tot_length) {
|
||||
c40_end = 0;
|
||||
} else {
|
||||
c40_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length;
|
||||
}
|
||||
} else if (have_b256) {
|
||||
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) {
|
||||
b256_end = 0;
|
||||
} else {
|
||||
b256_end = symbol->option_1 - tot_length < length ? symbol->option_1 - tot_length : length;
|
||||
}
|
||||
/* 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, fncs, b256_end,
|
||||
c40_end, target, &tp))) {
|
||||
assert(error_number >= ZINT_ERROR);
|
||||
return error_number;
|
||||
}
|
||||
}
|
||||
if (content_segs) {
|
||||
if (have_extra_escapes) {
|
||||
@@ -1876,6 +1888,7 @@ static int dm_encode_segs(struct zint_symbol *symbol, struct zint_seg segs[], co
|
||||
}
|
||||
}
|
||||
tot_length += length;
|
||||
position_fnc1 = 0;
|
||||
}
|
||||
|
||||
*p_binlen = tp;
|
||||
|
||||
+6
-2
@@ -367,7 +367,8 @@ static int supports_non_iso8859_1(const int symbology) {
|
||||
/* 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);
|
||||
|| ((symbol->symbology == BARCODE_AZTEC || symbol->symbology == BARCODE_DATAMATRIX)
|
||||
&& (symbol->input_mode & 0x07) != GS1_MODE);
|
||||
}
|
||||
|
||||
/* Returns 1 if symbology supports HRT */
|
||||
@@ -752,12 +753,15 @@ static int escape_char_process(struct zint_symbol *symbol, const unsigned char *
|
||||
case '\\':
|
||||
if (escaped_string) escaped_string[out_posn] = vals[z_posn(escs, ch)];
|
||||
in_posn += 2;
|
||||
/* Note: if given double backslash following by caret "\\^" then will be passed through as "\^",
|
||||
i.e. the start of an extra escape sequence, avoiding the check below, so each symbology needs
|
||||
to also check themselves */
|
||||
break;
|
||||
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");
|
||||
"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");
|
||||
|
||||
+4
-9
@@ -200,7 +200,7 @@ INTERNAL int zint_pharma_two(struct zint_symbol *symbol, unsigned char source[],
|
||||
/* Italian Pharmacode */
|
||||
INTERNAL int zint_code32(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
static const unsigned char TABELLA[] = "0123456789BCDFGHJKLMNPQRSTUVWXYZ";
|
||||
int i, zeroes, checksum, checkpart, checkdigit;
|
||||
int i, checksum, checkpart, checkdigit;
|
||||
unsigned char local_source[10], risultante[7];
|
||||
unsigned int pharmacode, devisor;
|
||||
int codeword[6];
|
||||
@@ -217,9 +217,7 @@ INTERNAL int zint_code32(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
|
||||
/* Add leading zeros as required */
|
||||
zeroes = 8 - length;
|
||||
memset(local_source, '0', zeroes);
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
z_zero_fill(source, length, local_source, 8);
|
||||
|
||||
/* Calculate the check digit */
|
||||
checksum = 0;
|
||||
@@ -297,7 +295,7 @@ INTERNAL int zint_code32(struct zint_symbol *symbol, unsigned char source[], int
|
||||
IFA-Info_Check_Digit_Calculations_PZN_PPN_UDI_EN.pdf */
|
||||
INTERNAL int zint_pzn(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
||||
int i, error_number, zeroes;
|
||||
int i, error_number;
|
||||
int count, check_digit;
|
||||
unsigned char have_check_digit = '\0';
|
||||
unsigned char local_source[1 + 8]; /* '-' prefix + 8 digits */
|
||||
@@ -318,10 +316,7 @@ INTERNAL int zint_pzn(struct zint_symbol *symbol, unsigned char source[], int le
|
||||
}
|
||||
|
||||
local_source[0] = '-';
|
||||
zeroes = 7 - pzn7 - length + 1;
|
||||
for (i = 1; i < zeroes; i++)
|
||||
local_source[i] = '0';
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
z_zero_fill(source, length, local_source + 1, 7 - pzn7);
|
||||
|
||||
count = 0;
|
||||
for (i = 1; i < 8 - pzn7; i++) {
|
||||
|
||||
+2
-4
@@ -181,7 +181,7 @@ INTERNAL int zint_koreapost(struct zint_symbol *symbol, unsigned char source[],
|
||||
{'1','3','1','5','0','6','1','3','1','3'}, {'0','4','1','3','1','3','1','7','1','3'},
|
||||
{ "17131713" }, { "13171713" }
|
||||
};
|
||||
int total, i, check, zeroes, error_number = 0;
|
||||
int total, i, check, error_number = 0;
|
||||
unsigned char local_source[8];
|
||||
char dest[80];
|
||||
char *d = dest;
|
||||
@@ -195,9 +195,7 @@ INTERNAL int zint_koreapost(struct zint_symbol *symbol, unsigned char source[],
|
||||
return z_errtxtf(ZINT_ERROR_INVALID_DATA, symbol, 485,
|
||||
"Invalid character at position %d in input (digits only)", i);
|
||||
}
|
||||
zeroes = 6 - length;
|
||||
memset(local_source, '0', zeroes);
|
||||
memcpy(local_source + zeroes, source, length);
|
||||
z_zero_fill(source, length, local_source, 6);
|
||||
|
||||
total = 0;
|
||||
for (i = 0; i < 6; i++) {
|
||||
|
||||
+1
-4
@@ -181,11 +181,8 @@ static uint64_t dbar_to_uint64(const unsigned char source[], const int length) {
|
||||
|
||||
/* Helper to construct zero-padded GTIN14 with check digit, returning `buf` for convenience */
|
||||
static unsigned char *dbar_gtin14(const unsigned char *source, const int length, unsigned char buf[14]) {
|
||||
const int zeroes = 13 - length;
|
||||
const int zeroes = z_zero_fill(source, length, buf, 13);
|
||||
|
||||
assert(zeroes >= 0);
|
||||
memset(buf, '0', zeroes);
|
||||
memcpy(buf + zeroes, source, length);
|
||||
buf[zeroes + length] = zint_gs1_check_digit(buf, 13);
|
||||
|
||||
return buf;
|
||||
|
||||
+131
-79
@@ -41,25 +41,25 @@ static void test_large(const testCtx *const p_ctx) {
|
||||
int ret;
|
||||
int expected_rows;
|
||||
int expected_width;
|
||||
const char *expected_errtxt;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_AUSPOST, "1", 23, 0, 3, 133 },
|
||||
/* 1*/ { BARCODE_AUSPOST, "1", 24, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 2*/ { BARCODE_AUSPOST, "1", 18, 0, 3, 133 },
|
||||
/* 3*/ { BARCODE_AUSPOST, "1", 19, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 4*/ { BARCODE_AUSPOST, "1", 16, 0, 3, 103 },
|
||||
/* 5*/ { BARCODE_AUSPOST, "1", 17, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 6*/ { BARCODE_AUSPOST, "1", 13, 0, 3, 103 },
|
||||
/* 7*/ { BARCODE_AUSPOST, "1", 14, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 8*/ { BARCODE_AUSPOST, "1", 8, 0, 3, 73 },
|
||||
/* 9*/ { BARCODE_AUSPOST, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 10*/ { BARCODE_AUSREPLY, "1", 8, 0, 3, 73 },
|
||||
/* 11*/ { BARCODE_AUSREPLY, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 12*/ { BARCODE_AUSROUTE, "1", 8, 0, 3, 73 },
|
||||
/* 13*/ { BARCODE_AUSROUTE, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 14*/ { BARCODE_AUSREDIRECT, "1", 8, 0, 3, 73 },
|
||||
/* 15*/ { BARCODE_AUSREDIRECT, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1 },
|
||||
/* 0*/ { BARCODE_AUSPOST, "1", 23, 0, 3, 133, "" },
|
||||
/* 1*/ { BARCODE_AUSPOST, "1", 24, ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input length 24 too long (maximum 23)" },
|
||||
/* 2*/ { BARCODE_AUSPOST, "1", 8, 0, 3, 73, "" },
|
||||
/* 3*/ { BARCODE_AUSPOST, "1", 9, 0, 3, 103, "" },
|
||||
/* 4*/ { BARCODE_AUSPOST, "1", 13, 0, 3, 103, "" },
|
||||
/* 5*/ { BARCODE_AUSPOST, "1", 16, 0, 3, 103, "" },
|
||||
/* 6*/ { BARCODE_AUSPOST, "1", 17, 0, 3, 133, "" },
|
||||
/* 7*/ { BARCODE_AUSPOST, "1", 18, 0, 3, 133, "" },
|
||||
/* 8*/ { BARCODE_AUSPOST, "1", 22, 0, 3, 133, "" },
|
||||
/* 9*/ { BARCODE_AUSREPLY, "1", 8, 0, 3, 73, "" },
|
||||
/* 10*/ { BARCODE_AUSREPLY, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 11*/ { BARCODE_AUSROUTE, "1", 8, 0, 3, 73, "" },
|
||||
/* 12*/ { BARCODE_AUSROUTE, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 13*/ { BARCODE_AUSREDIRECT, "1", 8, 0, 3, 73, "" },
|
||||
/* 14*/ { BARCODE_AUSREDIRECT, "1", 9, ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -77,17 +77,25 @@ static void test_large(const testCtx *const p_ctx) {
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
testUtilStrCpyRepeat(data_buf, data[i].pattern, data[i].length);
|
||||
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n", i, data[i].length, (int) strlen(data_buf));
|
||||
assert_equal(data[i].length, (int) strlen(data_buf), "i:%d length %d != strlen(data_buf) %d\n",
|
||||
i, data[i].length, (int) strlen(data_buf));
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data_buf, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1, -1, -1 /*output_options*/,
|
||||
data_buf, data[i].length, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data_buf), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n",
|
||||
i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
|
||||
i, symbol->width, data[i].expected_width);
|
||||
}
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
ZBarcode_Delete(symbol);
|
||||
}
|
||||
@@ -108,30 +116,54 @@ static void test_hrt(const testCtx *const p_ctx) {
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_AUSPOST, -1, "12345678", "", "" }, /* None */
|
||||
/* 0*/ { BARCODE_AUSPOST, -1, "12345678", "", "" },
|
||||
/* 1*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678", "", "1112345678" },
|
||||
/* 2*/ { BARCODE_AUSPOST, -1, "1234567890123", "", "" }, /* None */
|
||||
/* 3*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123", "", "591234567890123" },
|
||||
/* 4*/ { BARCODE_AUSPOST, -1, "1234567890123456", "", "" }, /* None */
|
||||
/* 5*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123456", "", "591234567890123456" },
|
||||
/* 6*/ { BARCODE_AUSPOST, -1, "123456789012345678", "", "" }, /* None */
|
||||
/* 7*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "123456789012345678", "", "62123456789012345678" },
|
||||
/* 8*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", "" }, /* None */
|
||||
/* 9*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678901234567890123", "", "6212345678901234567890123" },
|
||||
/* 10*/ { BARCODE_AUSREPLY, -1, "1234567", "", "" }, /* None */
|
||||
/* 11*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "1234567", "", "4501234567" },
|
||||
/* 12*/ { BARCODE_AUSREPLY, -1, "12345678", "", "" }, /* None */
|
||||
/* 13*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "12345678", "", "4512345678" },
|
||||
/* 14*/ { BARCODE_AUSROUTE, -1, "123456", "", "" }, /* None */
|
||||
/* 15*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "123456", "", "8700123456" },
|
||||
/* 16*/ { BARCODE_AUSROUTE, -1, "12345678", "", "" }, /* None */
|
||||
/* 17*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345678", "", "8712345678" },
|
||||
/* 18*/ { BARCODE_AUSROUTE, -1, "12345", "", "" }, /* None */
|
||||
/* 19*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345", "", "8700012345" },
|
||||
/* 20*/ { BARCODE_AUSREDIRECT, -1, "12345678", "", "" }, /* None */
|
||||
/* 21*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "12345678", "", "9212345678" },
|
||||
/* 22*/ { BARCODE_AUSREDIRECT, -1, "1234", "", "" }, /* None */
|
||||
/* 23*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "1234", "", "9200001234" },
|
||||
/* 2*/ { BARCODE_AUSPOST, -1, "1", "", "" },
|
||||
/* 3*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1", "", "1100000001" },
|
||||
/* 4*/ { BARCODE_AUSPOST, -1, "12", "", "" },
|
||||
/* 5*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12", "", "1100000012" },
|
||||
/* 6*/ { BARCODE_AUSPOST, -1, "1234567", "", "" },
|
||||
/* 7*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567", "", "1101234567" },
|
||||
/* 8*/ { BARCODE_AUSPOST, -1, "0", "", "" },
|
||||
/* 9*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "0", "", "0000000000" },
|
||||
/* 10*/ { BARCODE_AUSPOST, -1, "123456789", "", "" },
|
||||
/* 11*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "123456789", "", "59123456789" },
|
||||
/* 12*/ { BARCODE_AUSPOST, -1, "1234567890123", "", "" },
|
||||
/* 13*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123", "", "591234567890123" },
|
||||
/* 14*/ { BARCODE_AUSPOST, -1, "12345678D0123", "", "" },
|
||||
/* 15*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678D0123", "", "5912345678D0123" },
|
||||
/* 16*/ { BARCODE_AUSPOST, -1, "00000000D0123", "", "" },
|
||||
/* 17*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "00000000D0123", "", "0000000000D0123" },
|
||||
/* 18*/ { BARCODE_AUSPOST, -1, "1234567890123456", "", "" },
|
||||
/* 19*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "1234567890123456", "", "591234567890123456" },
|
||||
/* 20*/ { BARCODE_AUSPOST, -1, "0000000090123456", "", "" },
|
||||
/* 21*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "0000000090123456", "", "000000000090123456" },
|
||||
/* 22*/ { BARCODE_AUSPOST, -1, "123456789012345678", "", "" },
|
||||
/* 23*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "123456789012345678", "", "62123456789012345678" },
|
||||
/* 24*/ { BARCODE_AUSPOST, -1, "12345678901234567D", "", "" },
|
||||
/* 25*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678901234567D", "", "6212345678901234567D" },
|
||||
/* 26*/ { BARCODE_AUSPOST, -1, "12345678901234567890123", "", "" },
|
||||
/* 27*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "12345678901234567890123", "", "6212345678901234567890123" },
|
||||
/* 28*/ { BARCODE_AUSPOST, -1, "00000000901234567890123", "", "" },
|
||||
/* 29*/ { BARCODE_AUSPOST, BARCODE_CONTENT_SEGS, "00000000901234567890123", "", "0000000000901234567890123" },
|
||||
/* 30*/ { BARCODE_AUSREPLY, -1, "1234567", "", "" },
|
||||
/* 31*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "1234567", "", "4501234567" },
|
||||
/* 32*/ { BARCODE_AUSREPLY, -1, "12345678", "", "" },
|
||||
/* 33*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "12345678", "", "4512345678" },
|
||||
/* 34*/ { BARCODE_AUSREPLY, -1, "00000", "", "" },
|
||||
/* 35*/ { BARCODE_AUSREPLY, BARCODE_CONTENT_SEGS, "00000", "", "4500000000" },
|
||||
/* 36*/ { BARCODE_AUSROUTE, -1, "123456", "", "" },
|
||||
/* 37*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "123456", "", "8700123456" },
|
||||
/* 38*/ { BARCODE_AUSROUTE, -1, "12345678", "", "" },
|
||||
/* 39*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345678", "", "8712345678" },
|
||||
/* 40*/ { BARCODE_AUSROUTE, -1, "12345", "", "" },
|
||||
/* 41*/ { BARCODE_AUSROUTE, BARCODE_CONTENT_SEGS, "12345", "", "8700012345" },
|
||||
/* 42*/ { BARCODE_AUSREDIRECT, -1, "12345678", "", "" },
|
||||
/* 43*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "12345678", "", "9212345678" },
|
||||
/* 44*/ { BARCODE_AUSREDIRECT, -1, "1234", "", "" },
|
||||
/* 45*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "1234", "", "9200001234" },
|
||||
/* 46*/ { BARCODE_AUSREDIRECT, -1, "0", "", "" },
|
||||
/* 47*/ { BARCODE_AUSREDIRECT, BARCODE_CONTENT_SEGS, "0", "", "9200000000" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -193,31 +225,39 @@ static void test_input(const testCtx *const p_ctx) {
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73, "" },
|
||||
/* 1*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (first 8 characters) (digits only)" },
|
||||
/* 2*/ { BARCODE_AUSPOST, "0000000A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (first 8 characters) (digits only)" },
|
||||
/* 3*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
|
||||
/* 4*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" },
|
||||
/* 5*/ { BARCODE_AUSPOST, "00000000ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" },
|
||||
/* 6*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
|
||||
/* 7*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" },
|
||||
/* 8*/ { BARCODE_AUSPOST, "123456789012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 16 in input (digits only for FCC 59 length 16)" },
|
||||
/* 9*/ { BARCODE_AUSPOST, "000000009012345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 16 in input (digits only for FCC 59 length 16)" },
|
||||
/* 10*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133, "" }, /* Length 18 */
|
||||
/* 11*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" },
|
||||
/* 12*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 23 in input (digits only for FCC 62 length 23)" },
|
||||
/* 13*/ { BARCODE_AUSPOST, "0000000090123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 23 in input (digits only for FCC 62 length 23)" },
|
||||
/* 14*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input length 7 wrong (8, 13, 16, 18 or 23 characters required)" }, /* No leading zeroes added */
|
||||
/* 15*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" },
|
||||
/* 16*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, /* Leading zeroes added */
|
||||
/* 17*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 18*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" },
|
||||
/* 19*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" },
|
||||
/* 20*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 21*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" },
|
||||
/* 22*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" },
|
||||
/* 23*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" },
|
||||
/* 24*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 0*/ { BARCODE_AUSPOST, "1", 0, 3, 73, "" }, /* Leading zeroes added */
|
||||
/* 1*/ { BARCODE_AUSPOST, "1234567", 0, 3, 73, "" },
|
||||
/* 2*/ { BARCODE_AUSPOST, "12345678", 0, 3, 73, "" },
|
||||
/* 3*/ { BARCODE_AUSPOST, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 405: Invalid character at position 8 in DPID (digits only for Standard Customer Barcode)" },
|
||||
/* 4*/ { BARCODE_AUSPOST, "123456789", 0, 3, 103, "" },
|
||||
/* 5*/ { BARCODE_AUSPOST, "1234567A9", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 402: Invalid character at position 8 in DPID (digits only)" },
|
||||
/* 6*/ { BARCODE_AUSPOST, "12345678A", 0, 3, 103, "" },
|
||||
/* 7*/ { BARCODE_AUSPOST, "12345678AB", 0, 3, 103, "" },
|
||||
/* 8*/ { BARCODE_AUSPOST, "12345678ABc", 0, 3, 103, "" },
|
||||
/* 9*/ { BARCODE_AUSPOST, "12345678ABcd", 0, 3, 103, "" },
|
||||
/* 10*/ { BARCODE_AUSPOST, "12345678ABcd#", 0, 3, 103, "" },
|
||||
/* 11*/ { BARCODE_AUSPOST, "12345678ABcd!", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 404: Invalid character at position 13 in input (alphanumerics, space and \"#\" only)" },
|
||||
/* 12*/ { BARCODE_AUSPOST, "1234567890123456", 0, 3, 103, "" }, /* Barcode 2 all-digits */
|
||||
/* 13*/ { BARCODE_AUSPOST, "12345678ABcd #", 0, 3, 133, "" }, /* Barcode 3 */
|
||||
/* 14*/ { BARCODE_AUSPOST, "123456789012345A", 0, 3, 133, "" }, /* Barcode 3 */
|
||||
/* 15*/ { BARCODE_AUSPOST, "12345678901234567", 0, 3, 133, "" },
|
||||
/* 16*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" },
|
||||
/* 17*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 407: Invalid character at position 23 in input (digits only for Customer Barcode 3 length 23)" },
|
||||
/* 18*/ { BARCODE_AUSPOST, "123456789012345678A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 407: Invalid character at position 19 in input (digits only for Customer Barcode 3 length 19)" },
|
||||
/* 19*/ { BARCODE_AUSPOST, "12345678A0123456789012", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 407: Invalid character at position 9 in input (digits only for Customer Barcode 3 length 22)" },
|
||||
/* 20*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" },
|
||||
/* 21*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, /* Leading zeroes added */
|
||||
/* 22*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 23*/ { BARCODE_AUSREPLY, "12345A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 6 in DPID (digits only)" },
|
||||
/* 24*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" },
|
||||
/* 25*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" },
|
||||
/* 26*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 27*/ { BARCODE_AUSROUTE, "1234567A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 8 in DPID (digits only)" },
|
||||
/* 28*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" },
|
||||
/* 29*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" },
|
||||
/* 30*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" },
|
||||
/* 31*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input length 9 too long (maximum 8)" },
|
||||
/* 32*/ { BARCODE_AUSREDIRECT, "A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character at position 1 in DPID (digits only)" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -237,22 +277,32 @@ static void test_input(const testCtx *const p_ctx) {
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1, -1, -1 /*output_options*/,
|
||||
data[i].data, -1, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n", i, ret ? "set" : "empty", symbol->errtxt);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected_errtxt);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n",
|
||||
i, ret, data[i].ret, symbol->errtxt);
|
||||
assert_equal(symbol->errtxt[0] == '\0', ret == 0, "i:%d symbol->errtxt not %s (%s)\n",
|
||||
i, ret ? "set" : "empty", symbol->errtxt);
|
||||
assert_zero(strcmp(symbol->errtxt, data[i].expected_errtxt), "i:%d strcmp(%s, %s) != 0\n",
|
||||
i, symbol->errtxt, data[i].expected_errtxt);
|
||||
|
||||
if (ret < ZINT_ERROR) {
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
|
||||
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n",
|
||||
i, symbol->rows, data[i].expected_rows);
|
||||
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n",
|
||||
i, symbol->width, data[i].expected_width);
|
||||
|
||||
if (do_bwipp && testUtilCanBwipp(i, symbol, -1, -1, -1, debug)) {
|
||||
char modules_dump[4096];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf), NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1,
|
||||
"i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilBwipp(i, symbol, -1, -1, -1, data[i].data, length, NULL, cmp_buf, sizeof(cmp_buf),
|
||||
NULL);
|
||||
assert_zero(ret, "i:%d %s testUtilBwipp ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology),
|
||||
ret);
|
||||
|
||||
ret = testUtilBwippCmp(symbol, cmp_msg, cmp_buf, modules_dump);
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
@@ -494,7 +544,9 @@ static void test_fuzz(const testCtx *const p_ctx) {
|
||||
symbol = ZBarcode_Create();
|
||||
assert_nonnull(symbol, "Symbol not created\n");
|
||||
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, data[i].length, debug);
|
||||
length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/,
|
||||
-1 /*option_1*/, -1, -1, -1 /*output_options*/,
|
||||
data[i].data, data[i].length, debug);
|
||||
|
||||
ret = ZBarcode_Encode(symbol, TCU(data[i].data), length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
|
||||
|
||||
+1058
-253
File diff suppressed because it is too large
Load Diff
+68
-23
@@ -173,7 +173,7 @@ static void test_chr_cnt(const testCtx *const p_ctx) {
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", -1, 'a', 0 },
|
||||
/* 1*/ { "BDAaED", -1, 'a', 1 },
|
||||
/* 1*/ { "aBDAaaaEaDa", -1, 'a', 6 },
|
||||
/* 2*/ { "aBDAaaaEaDa", -1, 'a', 6 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -193,6 +193,44 @@ static void test_chr_cnt(const testCtx *const p_ctx) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_zero_fill(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
const char *data;
|
||||
int length;
|
||||
int dest_length;
|
||||
int ret;
|
||||
const char *expected;
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { "", -1, 0, 0, "" },
|
||||
/* 1*/ { "1", -1, 10, 9, "0000000001" },
|
||||
/* 2*/ { "123456789", -1, 10, 1, "0123456789" },
|
||||
/* 3*/ { "1234567890", -1, 10, 0, "1234567890" },
|
||||
/* 4*/ { "12345678901", -1, 10, -1, "12345678901" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
||||
testStart(p_ctx->func_name);
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
unsigned char dest[200];
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
length = data[i].length == -1 ? (int) strlen(data[i].data) : data[i].length;
|
||||
|
||||
ret = z_zero_fill(ZCUCP(data[i].data), length, dest, data[i].dest_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d ret %d != %d\n", i, ret, data[i].ret);
|
||||
assert_zero(strcmp(ZCCP(dest), data[i].expected), "i:%d dest (%s) != expected (%s)\n",
|
||||
i, dest, data[i].expected);
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
static void test_is_chr(const testCtx *const p_ctx) {
|
||||
|
||||
struct item {
|
||||
@@ -773,20 +811,21 @@ static void test_extra_escapes(const testCtx *const p_ctx) {
|
||||
int ret;
|
||||
const char *expected;
|
||||
const char expected_fncs[32];
|
||||
int expected_extra_escapes;
|
||||
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}, "" },
|
||||
/* 0*/ { 0, "", -1, 0, "", {0}, 0, "" },
|
||||
/* 1*/ { 3, "ABC", -1, 0, "ABC", {0}, 0, "" },
|
||||
/* 2*/ { 4, "\\^1ABC", -1, 0, "\035ABC", {1}, 1, "" },
|
||||
/* 3*/ { 26, "\\^1\\^1A\\^1BC\\^1", -1, 0, "\035\035A\035BC\035", {1,1,0,1,0,0,1}, 1, "" },
|
||||
/* 4*/ { 27, "\\^^\\^1A\\^1BC\\^^1", -1, 0, "\\^\035A\035BC\\^1", {0,0,1,0,1}, 1, "" },
|
||||
/* 5*/ { 20, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" },
|
||||
/* 6*/ { 25, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" },
|
||||
/* 7*/ { 28, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" },
|
||||
/* 8*/ { 29, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" },
|
||||
/* 9*/ { 899, "ABC", -1, ZINT_ERROR_INVALID_OPTION, "", {0}, 0, "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -800,9 +839,9 @@ static void test_extra_escapes(const testCtx *const p_ctx) {
|
||||
symbol->debug = debug;
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int len = 0;
|
||||
unsigned char dest[32] = {0};
|
||||
char fncs[32] = {0};
|
||||
int have_extra_escapes = 0;
|
||||
|
||||
if (testContinue(p_ctx, i)) continue;
|
||||
|
||||
@@ -813,14 +852,17 @@ static void test_extra_escapes(const testCtx *const p_ctx) {
|
||||
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);
|
||||
ret = z_extra_escapes(symbol, ZCUCP(data[i].data), &length, data[i].eci, dest, fncs, &have_extra_escapes);
|
||||
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_equal(length, expected_length, "i:%d length %d != expected_length %d (%s)\n",
|
||||
i, length, 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);
|
||||
assert_equal(have_extra_escapes, data[i].expected_extra_escapes,
|
||||
"i:%d have_extra_escapes %d != expected %d\n",
|
||||
i, have_extra_escapes, data[i].expected_extra_escapes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1313,18 +1355,20 @@ static void test_ct_set_seg_extra_escapes_eci(const testCtx *const p_ctx) {
|
||||
};
|
||||
/* s/\/\*[ 0-9]*\*\//\=printf("\/\*%3d*\/", line(".") - line("'<")): */
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { 0, 1, 3, { { TU("\\^1A"), 0, 0 } }, { { TU("\035A"), 2, 3 } } },
|
||||
/* 0*/ { 0, 1, 3, { { TU("\\^1A"), 0, 0 } }, { { TU("A"), 1, 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 } } },
|
||||
/* 2*/ { 0, 1, 4, { { TU("A\\^1"), 0, 0 } }, { { TU("A"), 1, 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 } } },
|
||||
/* 6*/ { 0, 1, 5, { { TU("12\\^1"), 0, 0 } }, { { TU("12"), 2, 5 } } },
|
||||
/* 7*/ { 0, 1, 0, { { TU("?\\^1"), 0, 0 } }, { { TU("?\035"), 2, 3 } } },
|
||||
/* 8*/ { 0, 1, 0, { { TU("1A\\^1"), 0, 0 } }, { { TU("1A\035"), 3, 3 } } },
|
||||
/* 9*/ { 0, 1, 0, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 3 } } },
|
||||
/* 10*/ { 0, 1, 5, { { TU("\\^1\\^^1A\\^1"), 0, 0 } }, { { TU("\\^1A\035"), 5, 5 } } },
|
||||
/* 11*/ { 1, 2, 27, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 27 } } },
|
||||
/* 12*/ { 1, 2, 0, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 3 } } },
|
||||
/* 13*/ { 1, 2, 6, { { TU("\\^^A"), 0, 0 }, { TU("\\^1A\\^^1\\^1B\\^"), 0, 0 } }, { { TU("\\^^A"), 0, 0 }, { TU("\035A\\^1\035B\\^"), 9, 6 } } },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, ret;
|
||||
@@ -1619,6 +1663,7 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_to_int", test_to_int },
|
||||
{ "test_to_upper", test_to_upper },
|
||||
{ "test_chr_cnt", test_chr_cnt },
|
||||
{ "test_zero_fill", test_zero_fill },
|
||||
{ "test_is_chr", test_is_chr },
|
||||
{ "test_not_sane", test_not_sane },
|
||||
{ "test_not_sane_lookup", test_not_sane_lookup },
|
||||
|
||||
@@ -654,9 +654,9 @@ static void test_options(const testCtx *const p_ctx) {
|
||||
/* 46*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "__________________________________________________", 0, 32, 32, "", 10, 1, "50 data" },
|
||||
/* 47*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "__________________________________________________", 0, 20, 44, "", 41, 1, "" },
|
||||
/* 48*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, DM_SQUARE, -1, { 0, 0, "" }, "__________________________________________________", 0, 32, 32, "", 10, 1, "" },
|
||||
/* 49*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "51 data; BWIPP different encodation" },
|
||||
/* 49*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "51 data; BWIPP different encodation, same no. of codewords (begins in C40, ends single ASCII, zint vice versa)" },
|
||||
/* 50*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 20, 44, "", 41, 0, "BWIPP DMRE requires dimensions" },
|
||||
/* 51*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, 9999, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "Ignored; BWIPP different encodation" },
|
||||
/* 51*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, 9999, -1, { 0, 0, "" }, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32, "", 10, 0, "Ignored; BWIPP different encodation, see 2 above" },
|
||||
/* 52*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "_____________________________________________________________", 0, 32, 32, "", 10, 1, "61 data" },
|
||||
/* 53*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "______________________________________________________________", 0, 32, 32, "", 10, 1, "62 data" },
|
||||
/* 54*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "_______________________________________________________________", 0, 36, 36, "", 11, 1, "63 data" },
|
||||
@@ -699,34 +699,35 @@ static void test_options(const testCtx *const p_ctx) {
|
||||
/* 91*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^^1\\^1", 0, 12, 12, "", 2, 1, "" },
|
||||
/* 92*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^^\\^", 0, 12, 12, "", 2, 1, "" },
|
||||
/* 93*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^^\\^2", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 717: Unrecognized extra escape \"\\^2\"", 0, 1, "" },
|
||||
/* 94*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[90]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 844: Cannot use extra escape mode in GS1 mode", 0, 1, "" },
|
||||
/* 94*/ { BARCODE_DATAMATRIX, GS1_MODE | EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[90]12", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 844: Cannot use Extra Escape mode in GS1 mode", 0, 1, "" },
|
||||
/* 95*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 9, -1, -1, -1, -1, { 0, 0, "" }, "α\\^1β", 0, 14, 14, "", 3, 1, "ECI ISO/IEC 8859-7 Greek" },
|
||||
/* 96*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, -1, -1, -1, -1, { 0, 0, "" }, "あ\\^1ば", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, 1, "ECI Shift JIS" },
|
||||
/* 97*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra escape mode requires ASCII-compatible ECI", 0, 1, "ECI 8-bit binary" },
|
||||
/* 98*/ { BARCODE_HIBC_DM, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 843: Can only use extra escape mode with non-variant Data Matrix", 0, 1, "" },
|
||||
/* 99*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "", 2, 1, "" },
|
||||
/*100*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "", 2, 1, "" },
|
||||
/*101*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 1, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '1' out of range (2 to 16)", 0, 1, "" },
|
||||
/*102*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 17, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '17' out of range (2 to 16)", 0, 1, "" },
|
||||
/*103*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '0' out of range (1 to count 16)", 0, 1, "" },
|
||||
/*104*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 17, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '17' out of range (1 to count 16)", 0, 1, "" },
|
||||
/*105*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "1", 0, 12, 12, "", 2, 1, "" },
|
||||
/*106*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "A" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 723: Invalid Structured Append ID (digits only)", 0, 1, "" },
|
||||
/*107*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "0" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '000' and ID2 '000' out of range (001 to 254) (ID \"000000\")", 0, 1, "" },
|
||||
/*108*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '000' out of range (001 to 254) (ID \"000001\")", 0, 1, "" },
|
||||
/*109*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1000" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '000' out of range (001 to 254) (ID \"001000\")", 0, 1, "" },
|
||||
/*110*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "001255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '255' out of range (001 to 254) (ID \"001255\")", 0, 1, "" },
|
||||
/*111*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '255' out of range (001 to 254) (ID \"255001\")", 0, 1, "" },
|
||||
/*112*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '255' and ID2 '255' out of range (001 to 254) (ID \"255255\")", 0, 1, "" },
|
||||
/*113*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1234567" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 722: Structured Append ID length 7 too long (6 digit maximum)", 0, 1, "" },
|
||||
/*114*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, READER_INIT, { 2, 3, "1001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 727: Cannot have Structured Append and Reader Initialisation at the same time", 0, 1, "" },
|
||||
/*115*/ { BARCODE_DATAMATRIX, ESCAPE_MODE, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "[)>\\R05\\GA\\R\\E", 0, 12, 26, "", 27, 1, "Macro05/06 ignored if have Structured Append TODO: error/warning " },
|
||||
/*116*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234,67", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 5 in input (alphanumerics, space and \"-.$/+%\" only)", 0, 1, "" },
|
||||
/*117*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" },
|
||||
/*118*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" },
|
||||
/*119*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 18, 18, "", 5, 1, "" },
|
||||
/*120*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_B256_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 20, 20, "", 6, 0, "BWIPP: same as above" },
|
||||
/*121*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_C40_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" },
|
||||
/* 96*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 20, -1, -1, -1, -1, { 0, 0, "" }, "あ\\^1ば", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, 1, "ECI Shift JIS" },
|
||||
/* 97*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 899, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 716: Extra Escape mode requires ASCII-compatible ECI", 0, 1, "ECI 8-bit binary" },
|
||||
/* 98*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "\\^1", 0, 10, 10, "", 1, 1, "" },
|
||||
/* 99*/ { BARCODE_HIBC_DM, EXTRA_ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "A", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 846: Can only use Extra Escape mode with non-variant Data Matrix", 0, 1, "" },
|
||||
/*100*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 2, "" }, "1", 0, 12, 12, "", 2, 1, "" },
|
||||
/*101*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 16, 16, "" }, "1", 0, 12, 12, "", 2, 1, "" },
|
||||
/*102*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 1, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '1' out of range (2 to 16)", 0, 1, "" },
|
||||
/*103*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 1, 17, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 720: Structured Append count '17' out of range (2 to 16)", 0, 1, "" },
|
||||
/*104*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 0, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '0' out of range (1 to count 16)", 0, 1, "" },
|
||||
/*105*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 17, 16, "" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 721: Structured Append index '17' out of range (1 to count 16)", 0, 1, "" },
|
||||
/*106*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "1", 0, 12, 12, "", 2, 1, "" },
|
||||
/*107*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "A" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 723: Invalid Structured Append ID (digits only)", 0, 1, "" },
|
||||
/*108*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "0" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '000' and ID2 '000' out of range (001 to 254) (ID \"000000\")", 0, 1, "" },
|
||||
/*109*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '000' out of range (001 to 254) (ID \"000001\")", 0, 1, "" },
|
||||
/*110*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1000" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '000' out of range (001 to 254) (ID \"001000\")", 0, 1, "" },
|
||||
/*111*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "001255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 726: Structured Append ID2 '255' out of range (001 to 254) (ID \"001255\")", 0, 1, "" },
|
||||
/*112*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 725: Structured Append ID1 '255' out of range (001 to 254) (ID \"255001\")", 0, 1, "" },
|
||||
/*113*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "255255" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 724: Structured Append ID1 '255' and ID2 '255' out of range (001 to 254) (ID \"255255\")", 0, 1, "" },
|
||||
/*114*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, -1, { 2, 3, "1234567" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 722: Structured Append ID length 7 too long (6 digit maximum)", 0, 1, "" },
|
||||
/*115*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, -1, READER_INIT, { 2, 3, "1001" }, "1", ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 727: Cannot have Structured Append and Reader Initialisation at the same time", 0, 1, "" },
|
||||
/*116*/ { BARCODE_DATAMATRIX, ESCAPE_MODE, -1, -1, -1, -1, -1, { 2, 3, "1001" }, "[)>\\R05\\GA\\R\\E", 0, 12, 26, "", 27, 1, "Macro05/06 ignored if have Structured Append TODO: error/warning " },
|
||||
/*117*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "1234,67", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 203: Invalid character at position 5 in input (alphanumerics, space and \"-.$/+%\" only)", 0, 1, "" },
|
||||
/*118*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, -1, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" },
|
||||
/*119*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_DMRE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" },
|
||||
/*120*/ { BARCODE_HIBC_DM, -1, -1, -1, -1, DM_SQUARE, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 18, 18, "", 5, 1, "" },
|
||||
/*121*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_B256_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 20, 20, "", 6, 0, "BWIPP: same as above" },
|
||||
/*122*/ { BARCODE_HIBC_DM, -1, -1, 0, -1, DM_C40_START, -1, { 0, 0, "" }, "H123ABC01234567890", 0, 12, 26, "", 27, 1, "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -861,6 +862,7 @@ static void test_reader_init(const testCtx *const p_ctx) {
|
||||
static const struct item data[] = {
|
||||
/* 0*/ { BARCODE_DATAMATRIX, UNICODE_MODE, READER_INIT, "A", 0, 10, 10, "EA 42 81 19 A4 53 21 DF", "" },
|
||||
/* 1*/ { BARCODE_DATAMATRIX, GS1_MODE, READER_INIT, "[91]A", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 521: Cannot use Reader Initialisation in GS1 mode", "" },
|
||||
/* 2*/ { BARCODE_DATAMATRIX, EXTRA_ESCAPE_MODE, READER_INIT, "\\^112", ZINT_ERROR_INVALID_OPTION, 0, 0, "Error 847: Cannot use Reader Initialisation in Extra Escape mode", "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -1215,7 +1217,7 @@ static void test_input(const testCtx *const p_ctx) {
|
||||
/*232*/ { UNICODE_MODE, 16382, -1, -1, -1, -1, { 0, 0, "" }, "A", 0, 16382, 12, 12, 1, 1, "F1 BF FE 42 81 29 57 AA A0 92 B2 45", "ECI 16383 A41", 0 },
|
||||
/*233*/ { UNICODE_MODE | FAST_MODE, 810899, -1, -1, -1, -1, { 0, 0, "" }, "A", 0, 810899, 12, 12, 1, 1, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41", 0 },
|
||||
/*234*/ { UNICODE_MODE, 810899, -1, -1, -1, -1, { 0, 0, "" }, "A", 0, 810899, 12, 12, 1, 1, "F1 CC 51 05 42 BB A5 A7 8A C6 6E 0F", "ECI 810900 A41", 0 },
|
||||
/*235*/ { UNICODE_MODE | ESCAPE_MODE | FAST_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, 1, 1, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41", 0 },
|
||||
/*235*/ { UNICODE_MODE | FAST_MODE | ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, 1, 1, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41", 0 },
|
||||
/*236*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, -1, -1, -1, { 0, 0, "" }, "[)>\\R05\\GA\\R\\E", 0, 0, 10, 10, 1, 1, "EC 42 81 5D 17 49 F6 B6", "Macro05 A41", 0 },
|
||||
/*237*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLM*", 0, 0, 16, 16, 1, 1, "EE 59 E9 6D 24 80 5F 93 9A FE 4E 2B 09 FF 50 A2 83 BE 32 E1 2F 17 1E F3", "C40 == X12, p_r_6_2_1 true", 0 },
|
||||
/*238*/ { UNICODE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEFGHIJKLM*", 0, 0, 16, 16, 0, 1, "42 F0 08 31 05 18 72 09 28 B3 0D 2B 63 64 96 E4 6C CE D3 47 9A 5F E8 70", "AEEEEEEEEEEEEA; BWIPP same as FAST_MODE", 0 },
|
||||
@@ -1264,15 +1266,32 @@ static void test_input(const testCtx *const p_ctx) {
|
||||
/*281*/ { UNICODE_MODE | FAST_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A*B>C 1A*B>C 1*\013B>C 1A*B>C 1A*", 0, 0, 22, 22, 1, 1, "(50) EE 57 B8 0F 04 21 72 5E 21 13 8A FE 0C EE 5E 21 13 97 08 9B 64 7E FE 42 2B 81 68 FE", "process_p 0", 1 },
|
||||
/*282*/ { GS1_MODE, 0, -1, -1, -1, -1, { 1, 2, "" }, "[20]01", 0, 0, 14, 14, 1, 1, "E9 0F 01 01 E8 96 83 81 DE 06 E8 61 E2 B5 19 CE A3 F8", "", 0 },
|
||||
/*283*/ { GS1_MODE, 3, -1, -1, -1, -1, { 1, 2, "123234" }, "[20]01", 0, 3, 8, 32, 1, 1, "E9 0F 7B EA E8 F1 04 96 83 81 47 4D F5 6F E8 62 DA 1C 06 7F 03", "", 0 },
|
||||
/*284*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", 0, 0, 10, 10, 1, 1, "42 E8 43 E5 E2 F8 F5 E5", "", 1 },
|
||||
/*285*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "a\\^1B", 0, 0, 10, 10, 1, 1, "62 E8 43 52 07 83 91 CF", "", 1 },
|
||||
/*286*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "9\\^1A", 0, 0, 10, 10, 1, 1, "3A E8 42 12 19 12 42 F6", "", 1 },
|
||||
/*287*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "99\\^1A", 0, 0, 10, 10, 1, 1, "E5 E8 42 B0 7D B7 7B 6F", "", 1 },
|
||||
/*288*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1A", 0, 0, 10, 10, 1, 1, "40 E8 42 E7 07 1A 88 26", "", 1 },
|
||||
/*289*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 1, 2, "" }, "A\\^1B", 0, 0, 14, 14, 1, 1, "E9 0F 01 01 42 E8 43 81 F4 7B DC 13 EA 49 14 75 EA 25", "", 1 },
|
||||
/*290*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^1\\^1", 0, 0, 10, 10, 1, 1, "E8 E8 E8 88 6E 8B A4 5E", "", 1 },
|
||||
/*291*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 1, 1, "E6 59 E9 6D 24 0A 8D 86 C8 96 44 FE 4D 4E E8 81 33 8F 19 0F D7 59 96 B4 D8 43 49 D7 F3 B6", "BWIPP: different encodation", 0 },
|
||||
/*292*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 0, 1, "E6 59 E9 6D 24 0A 8D 86 C8 FE 4C E8 4D 4E E8 81 49 98 C6 DD DA A6 89 B1 83 08 56 71 C1 51", "BWIPP: same as FAST_MODE", 0 },
|
||||
/*284*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1", 0, 0, 10, 10, 1, 1, "E8 81 46 77 14 C6 DF 66", "", 0 },
|
||||
/*285*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1", 0, 0, 10, 10, 1, 1, "E8 81 46 77 14 C6 DF 66", "", 0 },
|
||||
/*286*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^112", 0, 0, 10, 10, 1, 1, "E8 8E 81 57 8D 75 FB 06", "", 0 },
|
||||
/*287*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1", 0, 0, 10, 10, 1, 1, "42 E8 81 93 B4 12 AB 40", "", 0 },
|
||||
/*288*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1", 0, 0, 10, 10, 1, 1, "42 E8 81 93 B4 12 AB 40", "", 0 },
|
||||
/*289*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "12\\^1", 0, 0, 10, 10, 1, 1, "8E E8 81 DE FB 11 5D 6E", "", 0 },
|
||||
/*290*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^1B", 0, 0, 10, 10, 1, 1, "42 E8 43 E5 E2 F8 F5 E5", "", 0 },
|
||||
/*291*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "A\\^11234", 0, 0, 12, 12, 1, 1, "42 E8 8E A4 81 89 64 EB FC D4 55 50", "", 0 },
|
||||
/*292*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "a\\^1B", 0, 0, 10, 10, 1, 1, "62 E8 43 52 07 83 91 CF", "", 0 },
|
||||
/*293*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "9\\^1A", 0, 0, 10, 10, 1, 1, "3A E8 42 12 19 12 42 F6", "", 0 },
|
||||
/*294*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "99\\^1A", 0, 0, 10, 10, 1, 1, "E5 E8 42 B0 7D B7 7B 6F", "", 0 },
|
||||
/*295*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1A", 0, 0, 10, 10, 1, 1, "40 E8 42 E7 07 1A 88 26", "", 0 },
|
||||
/*296*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 1, 2, "" }, "A\\^1B", 0, 0, 14, 14, 1, 1, "E9 0F 01 01 42 E8 43 81 F4 7B DC 13 EA 49 14 75 EA 25", "", 0 },
|
||||
/*297*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "\\^1\\^1\\^1", 0, 0, 10, 10, 1, 1, "E8 E8 E8 88 6E 8B A4 5E", "", 0 },
|
||||
/*298*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 1, 1, "E6 59 E9 6D 24 0A 8D 86 C8 96 44 FE 4D 4E E8 81 33 8F 19 0F D7 59 96 B4 D8 43 49 D7 F3 B6", "", 0 },
|
||||
/*299*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "ABCDEF\\^1GHIJK\\^1LM\\^1", 0, 0, 12, 26, 0, 1, "E6 59 E9 6D 24 0A 8D 86 C8 FE 4C E8 4D 4E E8 81 49 98 C6 DD DA A6 89 B1 83 08 56 71 C1 51", "BWIPP: same as FAST_MODE", 0 },
|
||||
/*300*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1123456ABC\\^1\\^^DEXY\\^11234\\^^\\^1", 0, 0, 20, 20, 1, 1, "(40) 40 E8 8E A4 BA 42 43 44 E8 5D 5F 45 46 59 5A E8 8E A4 5D 5F E8 81 F9 B4 2C 94 C0 29", "", 0 },
|
||||
/*301*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 0, -1, -1, -1, -1, { 0, 0, "" }, "?\\^1123456ABC\\^1\\^^DEXY\\^11234\\^^\\^1", 0, 0, 20, 20, 1, 1, "(40) 40 E8 8E A4 BA 42 43 44 E8 5D 5F 45 46 59 5A E8 8E A4 5D 5F E8 81 F9 B4 2C 94 C0 29", "", 0 },
|
||||
/*302*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 0, 0, "" }, "\\^1ABCD\\^1", 0, 4, 14, 14, 1, 1, "E8 F1 05 42 43 44 45 E8 B0 05 33 74 B3 6E 79 FB 4F D2", "", 0 },
|
||||
/*303*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 0, 0, "" }, "\\^1ABCD\\^1", 0, 4, 14, 14, 0, 1, "E8 F1 05 F0 04 20 C4 E8 C8 58 2A 5C 98 0A 7B C6 2B 65", "BWIPP: same as FAST_MODE", 1 },
|
||||
/*304*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 5, -1, -1, -1, -1, { 0, 0, "" }, "A\\^112\\^1Ħ", 0, 5, 14, 14, 1, 1, "42 E8 F1 06 8E E8 EB 22 94 9C C7 17 9E 51 80 CB 86 1A", "", 0 },
|
||||
/*305*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 5, -1, -1, -1, -1, { 0, 0, "" }, "A\\^112\\^1Ħ", 0, 5, 14, 14, 1, 1, "42 E8 F1 06 8E E8 EB 22 94 9C C7 17 9E 51 80 CB 86 1A", "", 0 },
|
||||
/*306*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "001001" }, "\\^11234\\^1", 0, 3, 8, 32, 1, 1, "E9 0F 01 01 E8 F1 04 8E A4 E8 C1 D2 2C 58 06 98 9E 54 39 C0 48", "", 0 },
|
||||
/*307*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, -1, -1, -1, { 1, 2, "001001" }, "\\^11234\\^1", 0, 3, 8, 32, 1, 1, "E9 0F 01 01 E8 F1 04 8E A4 E8 C1 D2 2C 58 06 98 9E 54 39 C0 48", "", 0 },
|
||||
/*308*/ { UNICODE_MODE | FAST_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 1, 2, "001001" }, "12\\^11234\\^1", 0, 4, 16, 16, 1, 1, "E9 0F 01 01 8E E8 F1 05 8E A4 E8 81 5B 4D 22 4E 82 0A 9C B4 32 CF 84 EB", "", 0 },
|
||||
/*309*/ { UNICODE_MODE | EXTRA_ESCAPE_MODE, 4, -1, -1, -1, -1, { 1, 2, "001001" }, "12\\^11234\\^1", 0, 4, 16, 16, 1, 1, "E9 0F 01 01 8E E8 F1 05 8E A4 E8 81 5B 4D 22 4E 82 0A 9C B4 32 CF 84 EB", "", 0 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
@@ -6781,20 +6800,28 @@ static void test_ct(const testCtx *const p_ctx) {
|
||||
/* 8*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, -1, "é", -1, 0, 26, "", -1, 0 },
|
||||
/* 9*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 26, BARCODE_CONTENT_SEGS, "é", -1, 0, 26, "é", -1, 26 },
|
||||
/* 10*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, -1, "é", -1, 0, 899, "", -1, 0 },
|
||||
/* 11*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, "\\^1é", -1, 0, 0, "", -1, 0 },
|
||||
/* 12*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 0, "é", -1, 3 },
|
||||
/* 13*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, BARCODE_CONTENT_SEGS, "é", -1, 0, 899, "é", -1, 899 },
|
||||
/* 14*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "é\\^1", -1, 0, 26, "", -1, 0 },
|
||||
/* 15*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "é\\^1", -1, 0, 26, "é\035", -1, 26 },
|
||||
/* 16*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "\\^^é\\^1\\^1\\^", -1, 0, 26, "", -1, 0 },
|
||||
/* 17*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "\\^^é\\^1\\^1\\^", -1, 0, 26, "\\^é\035\035\\^", -1, 26 },
|
||||
/* 18*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
|
||||
/* 19*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
|
||||
/* 20*/ { BARCODE_DATAMATRIX, GS1_MODE, 28, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 28, "01049123451234591597033130128\03510ABC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */
|
||||
/* 21*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "https://example.com/01/09506000134369", -1, 0, 0, "", -1, 0 },
|
||||
/* 22*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "https://example.com/01/09506000134369", -1, 0, 0, "https://example.com/01/09506000134369", -1, 3 },
|
||||
/* 23*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 },
|
||||
/* 24*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 },
|
||||
/* 11*/ { BARCODE_DATAMATRIX, UNICODE_MODE, 899, BARCODE_CONTENT_SEGS, "é", -1, 0, 899, "é", -1, 899 },
|
||||
/* 12*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, -1, "\\^1é", -1, 0, 0, "", -1, 0 },
|
||||
/* 13*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 0, "é", -1, 3 },
|
||||
/* 14*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, "\\^1é", -1, 0, 3, "", -1, 3 },
|
||||
/* 15*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, BARCODE_CONTENT_SEGS, "\\^1é", -1, 0, 3, "é", -1, 3 },
|
||||
/* 16*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, "A\\^1é", -1, 0, 3, "", -1, 3 },
|
||||
/* 17*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, BARCODE_CONTENT_SEGS, "A\\^1é", -1, 0, 3, "Aé", -1, 3 },
|
||||
/* 18*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 9, -1, "12\\^1α", -1, 0, 9, "", -1, 9 },
|
||||
/* 19*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 9, BARCODE_CONTENT_SEGS, "12\\^1α", -1, 0, 9, "12α", -1, 9 },
|
||||
/* 20*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, -1, "1\\^1é", -1, 0, 3, "", -1, 3 },
|
||||
/* 21*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 3, BARCODE_CONTENT_SEGS, "1\\^1é", -1, 0, 3, "1\035é", -1, 3 },
|
||||
/* 22*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "é\\^1", -1, 0, 26, "", -1, 0 },
|
||||
/* 23*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "é\\^1", -1, 0, 26, "é\035", -1, 26 },
|
||||
/* 24*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, -1, "\\^^é\\^1\\^1\\^", -1, 0, 26, "", -1, 0 },
|
||||
/* 25*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 26, BARCODE_CONTENT_SEGS, "\\^^é\\^1\\^1\\^", -1, 0, 26, "\\^é\035\035\\^", -1, 26 },
|
||||
/* 26*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "", -1, 0 },
|
||||
/* 27*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 0, "01049123451234591597033130128\03510ABC123", -1, 3 },
|
||||
/* 28*/ { BARCODE_DATAMATRIX, GS1_MODE, 28, BARCODE_CONTENT_SEGS, "[01]04912345123459[15]970331[30]128[10]ABC123", -1, 0, 28, "01049123451234591597033130128\03510ABC123", -1, 3 }, /* Note: content seg ECI remains at default 3 */
|
||||
/* 29*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, "https://example.com/01/09506000134369", -1, 0, 0, "", -1, 0 },
|
||||
/* 30*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, BARCODE_CONTENT_SEGS, "https://example.com/01/09506000134369", -1, 0, 0, "https://example.com/01/09506000134369", -1, 3 },
|
||||
/* 31*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, -1, "H123ABC01234567890", -1, 0, 0, "", -1, 0 },
|
||||
/* 32*/ { BARCODE_HIBC_DM, UNICODE_MODE, -1, BARCODE_CONTENT_SEGS, "H123ABC01234567890", -1, 0, 0, "+H123ABC01234567890D", -1, 3 },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
||||
@@ -764,25 +764,35 @@ 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_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, "" },
|
||||
/* 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, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" },
|
||||
/* 82*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "" },
|
||||
/* 83*/ { BARCODE_AZTEC, DATA_MODE, -1, "\\\\^11", "", 0, 15, "(102) 30 31 31 30 31 31 31 30 31 31 30 30 31 31 31 31 30 31 31 30 31 31 30 30 31 31 31 31", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" },
|
||||
/* 84*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 15, "(102) 31 31 30 30 31 31 30 31 31 31 30 30 31 31 30 30 31 31 30 31 30 30 31 30 30 30 30 30", 0, "Treated as backslash caret 1 (FNC1)" },
|
||||
/* 85*/ { BARCODE_AZTEC, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" },
|
||||
/* 86*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" },
|
||||
/* 87*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, "\\^11", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" },
|
||||
/* 88*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "" },
|
||||
/* 89*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^A\"", 0, "" },
|
||||
/* 90*/ { 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" },
|
||||
/* 91*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\\\^11", "", 0, 10, "5D 5F 8D 5C FB D1 69 3F", 0, "Note double-backslash caret passed thru as backslash caret but does not error in non-EXTRA_ESCAPE_MODE, treated literally" },
|
||||
/* 92*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^11", "", 0, 10, "E8 32 81 98 94 7B 7F 6D", 0, "Treated as backslash caret 1 (FNC1)" },
|
||||
/* 93*/ { BARCODE_DATAMATRIX, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^B2", "", ZINT_ERROR_INVALID_DATA, 0, "Error 717: Unrecognized extra escape \"\\^B\"", 0, "Passed thru as backslash caret B" },
|
||||
/* 94*/ { BARCODE_DATAMATRIX, UNICODE_MODE | EXTRA_ESCAPE_MODE, 18, "A\\^1B", "", 0, 12, "42 E8 F1 13 43 F5 A4 26 80 68 7A AD", 0, "" },
|
||||
/* 95*/ { 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, "" },
|
||||
/* 96*/ { 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, "" },
|
||||
/* 97*/ { 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, "" },
|
||||
/* 98*/ { 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, "" },
|
||||
/* 99*/ { 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, "" },
|
||||
/*100*/ { 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, "" },
|
||||
/*101*/ { BARCODE_DATAMATRIX, DATA_MODE, -1, "\\w", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\w' in input", 0, "" },
|
||||
/*102*/ { BARCODE_CODE128, DATA_MODE, -1, "\\^A1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 798: Escape '\\^' only valid in Extra Escape mode", 0, "" },
|
||||
/*103*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "" },
|
||||
/*104*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^", "", 0, 57, "(5) 104 60 62 82 106", 0, "Partial special escape '\\^' at end allowed" },
|
||||
/*105*/ { BARCODE_CODE128, EXTRA_ESCAPE_MODE, -1, "\\^D1", "", ZINT_ERROR_INVALID_DATA, 0, "Error 348: Unrecognized extra escape \"\\^D\"", 0, "" },
|
||||
/*106*/ { BARCODE_CODE128, DATA_MODE, -1, "\\\\^A1", "", 0, 79, "(7) 104 60 62 33 17 43 106", 0, "Treated as literal backslash caret A" },
|
||||
/*107*/ { BARCODE_CODE128, DATA_MODE | EXTRA_ESCAPE_MODE, -1, "\\\\^A1", "", 0, 46, "(4) 103 17 17 106", 0, "Treated as backslash caret A (manual Code Set A)" },
|
||||
/*108*/ { BARCODE_CODE128, DATA_MODE, -1, "\\c", "", ZINT_ERROR_INVALID_DATA, 0, "Error 234: Unrecognised escape character '\\c' in input", 0, "" },
|
||||
};
|
||||
const int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019-2025 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-2026 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
||||
+42
-43
@@ -2385,9 +2385,9 @@ static const char *testUtilBwippName(int index, const struct zint_symbol *symbol
|
||||
{ "auspost", BARCODE_AUSPOST, 63, 0, 0, 0, 0, 0, },
|
||||
{ "", -1, 64, 0, 0, 0, 0, 0, },
|
||||
{ "", -1, 65, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_AUSREPLY, 66, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_AUSROUTE, 67, 0, 0, 0, 0, 0, },
|
||||
{ "", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, },
|
||||
{ "auspost", BARCODE_AUSREPLY, 66, 0, 0, 0, 0, 0, },
|
||||
{ "auspost", BARCODE_AUSROUTE, 67, 0, 0, 0, 0, 0, },
|
||||
{ "auspost", BARCODE_AUSREDIRECT, 68, 0, 0, 0, 0, 0, },
|
||||
{ "isbn", BARCODE_ISBNX, 69, 0, 1, 0, 0, 1 /*gs1_cvt*/, },
|
||||
{ "royalmail", BARCODE_RM4SCC, 70, 0, 0, 0, 0, 0, },
|
||||
{ "datamatrix", BARCODE_DATAMATRIX, 71, 1, 1, 1, 1, 0, },
|
||||
@@ -2672,7 +2672,8 @@ static char *testUtilBwippCvtGS1Data(char *bwipp_data, const int bwipp_data_size
|
||||
/* 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);
|
||||
|| ((symbol->symbology == BARCODE_AZTEC || 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'))
|
||||
@@ -2691,9 +2692,24 @@ static char *testUtilBwippEscape(const struct zint_symbol *const symbol, char *b
|
||||
int have_done_single_caret = 0; /* Flag to help debug escaping of carets */
|
||||
|
||||
if (eci) {
|
||||
sprintf(bwipp_data, "^ECI%06d", eci);
|
||||
int position_fnc1;
|
||||
/* Check if have extra escape position FNC1s first, and put before ECI if so */
|
||||
if (is_extra_escaped && (position_fnc1 = z_extra_escape_position_fnc1(d, length))) {
|
||||
assert(b + 7 < be);
|
||||
if (position_fnc1 == 4) {
|
||||
*b++ = d[0];
|
||||
} else if (position_fnc1 == 5) {
|
||||
*b++ = d[0];
|
||||
*b++ = d[1];
|
||||
}
|
||||
strcpy(b, "^FNC1");
|
||||
b += 5;
|
||||
d += position_fnc1;
|
||||
}
|
||||
assert(b + 10 < be);
|
||||
sprintf(b, "^ECI%06d", eci);
|
||||
*parsefnc = 1;
|
||||
b = bwipp_data + 10;
|
||||
b += 10;
|
||||
}
|
||||
|
||||
while (b < be && d < de) {
|
||||
@@ -2933,7 +2949,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) {
|
||||
const char *data, int length, const char *primary, char *buffer, int buffer_size, const 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";
|
||||
@@ -3232,7 +3248,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
||||
}
|
||||
} else if (symbology == BARCODE_POSTNET || symbology == BARCODE_PLANET || symbology == BARCODE_RM4SCC
|
||||
|| symbology == BARCODE_JAPANPOST || symbology == BARCODE_KIX || symbology == BARCODE_DAFT
|
||||
|| symbology == BARCODE_USPS_IMAIL || symbology == BARCODE_AUSPOST
|
||||
|| symbology == BARCODE_USPS_IMAIL
|
||||
|| (symbology >= BARCODE_AUSPOST && symbology <= BARCODE_AUSREDIRECT)
|
||||
|| symbology == BARCODE_PHARMA_TWO) {
|
||||
for (r = 0; r < symbol->rows; r++) bwipp_row_height[r] = 1; /* Zap */
|
||||
if (symbology == BARCODE_RM4SCC || symbology == BARCODE_KIX || symbology == BARCODE_JAPANPOST
|
||||
@@ -3243,32 +3260,26 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
|
||||
if (dash) {
|
||||
memmove(dash, dash + 1, strlen(dash));
|
||||
}
|
||||
} else if (symbology == BARCODE_AUSPOST) {
|
||||
} else if (symbology >= BARCODE_AUSPOST && symbology <= BARCODE_AUSREDIRECT) {
|
||||
const char *prefix;
|
||||
if (data_len == 8) {
|
||||
prefix = "11";
|
||||
} else if (data_len == 13 || data_len == 16) {
|
||||
prefix = "59";
|
||||
if (data_len == 16) {
|
||||
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%scustinfoenc=numeric",
|
||||
strlen(bwipp_opts_buf) ? " " : "");
|
||||
bwipp_opts = bwipp_opts_buf;
|
||||
}
|
||||
if (symbology != BARCODE_AUSPOST || data_len <= 8) {
|
||||
static const char zeroes[] = "0000000";
|
||||
char buf[10 + 1];
|
||||
prefix = symbology == BARCODE_AUSREPLY ? "45" : symbology == BARCODE_AUSROUTE ? "87"
|
||||
: symbology == BARCODE_AUSREDIRECT ? "92" : "11";
|
||||
sprintf(buf, "%s%.*s%s", prefix, 8 - data_len, zeroes, bwipp_data);
|
||||
memcpy(bwipp_data, buf, 10 + 1);
|
||||
} else {
|
||||
prefix = "62";
|
||||
if (data_len == 23) {
|
||||
int not_all_digits = z_not_sane(NEON_F, ZCUCP(bwipp_data), data_len);
|
||||
prefix = data_len > 16 || (data_len > 13 && not_all_digits) ? "62" : "59";
|
||||
if (!not_all_digits) {
|
||||
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%scustinfoenc=numeric",
|
||||
strlen(bwipp_opts_buf) ? " " : "");
|
||||
bwipp_opts = bwipp_opts_buf;
|
||||
}
|
||||
memmove(bwipp_data + 2, bwipp_data, data_len + 1);
|
||||
memmove(bwipp_data, prefix, 2);
|
||||
}
|
||||
/* Check for Null - for when supported by BWIPP */
|
||||
for (i = 0; i < 8 && data[i] == '0'; i++);
|
||||
if (i == 8) {
|
||||
prefix = "00";
|
||||
}
|
||||
memmove(bwipp_data + 2, bwipp_data, data_len + 1);
|
||||
memmove(bwipp_data, prefix, 2);
|
||||
}
|
||||
} else if (symbology == BARCODE_CODE128AB) {
|
||||
sprintf(bwipp_opts_buf + strlen(bwipp_opts_buf), "%ssuppressc", strlen(bwipp_opts_buf) ? " " : "");
|
||||
@@ -4424,7 +4435,7 @@ 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 (symbol->eci || have_position_fnc1 || j > 2 || (j == 1 && !z_isalpha(escaped[0]))
|
||||
if (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 */
|
||||
@@ -4553,14 +4564,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
}
|
||||
} else if (symbology == BARCODE_DPLEIT || symbology == BARCODE_DPIDENT) {
|
||||
const int len = symbology == BARCODE_DPLEIT ? 13 : 11;
|
||||
int zeroes = len - expected_len;
|
||||
unsigned int count = 0;
|
||||
int factor = 4;
|
||||
for (i = 0; i < zeroes; i++) {
|
||||
c25inter[i] = '0';
|
||||
}
|
||||
memcpy(c25inter + zeroes, expected, expected_len);
|
||||
expected_len += zeroes;
|
||||
expected_len += z_zero_fill(ZCUCP(expected), expected_len, ZUCP(c25inter), len);
|
||||
for (i = len - 1; i >= 0; i--) {
|
||||
count += factor * z_ctoi(c25inter[i]);
|
||||
factor ^= 0x0D; /* Toggles 4 and 9 */
|
||||
@@ -4569,12 +4575,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
c25inter[++expected_len] = '\0';
|
||||
expected = c25inter;
|
||||
} else if (symbology == BARCODE_ITF14) {
|
||||
int zeroes = 13 - expected_len;
|
||||
for (i = 0; i < zeroes; i++) {
|
||||
c25inter[i] = '0';
|
||||
}
|
||||
memcpy(c25inter + zeroes, expected, expected_len);
|
||||
expected_len += zeroes;
|
||||
expected_len += z_zero_fill(ZCUCP(expected), expected_len, ZUCP(c25inter), 13);
|
||||
c25inter[expected_len] = zint_gs1_check_digit((const unsigned char *) c25inter, 13);
|
||||
c25inter[++expected_len] = '\0';
|
||||
expected = c25inter;
|
||||
@@ -4664,11 +4665,9 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
|
||||
} else if (symbology == BARCODE_EAN14 || symbology == BARCODE_NVE18) {
|
||||
int len = symbology == BARCODE_NVE18 ? 17 : 13;
|
||||
int zeroes = expected_len < len ? len - expected_len: 0;
|
||||
ean14_nve18[0] = '0';
|
||||
ean14_nve18[1] = symbology == BARCODE_NVE18 ? '0' : '1';
|
||||
memset(ean14_nve18 + 2, '0', zeroes);
|
||||
memcpy(ean14_nve18 + 2 + zeroes, expected, expected_len);
|
||||
z_zero_fill(ZCUCP(expected), expected_len, ZUCP(ean14_nve18 + 2), len);
|
||||
ean14_nve18[len + 2] = zint_gs1_check_digit((unsigned char *) (ean14_nve18 + 2), len);
|
||||
expected = ean14_nve18;
|
||||
expected_len = len + 3;
|
||||
|
||||
@@ -215,7 +215,7 @@ int testUtilVerifyTiffInfo(const char *filename, int debug);
|
||||
int testUtilCanBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||
int debug);
|
||||
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);
|
||||
const char *data, int length, const char *primary, char *buffer, int buffer_size, const int *p_parsefnc);
|
||||
int testUtilBwippSegs(int index, struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||
const struct zint_seg segs[], const int seg_count, const char *primary, char *buffer, int buffer_size);
|
||||
int testUtilBwippCmp(const struct zint_symbol *symbol, char *msg, char *cmp_buf, const char *expected);
|
||||
|
||||
Binary file not shown.
@@ -18,6 +18,7 @@ run_zxingcpp_test "test_2of5" "encode"
|
||||
run_zxingcpp_test "test_aztec" "large"
|
||||
run_zxingcpp_test "test_aztec" "bs"
|
||||
run_zxingcpp_test "test_aztec" "many_states"
|
||||
run_zxingcpp_test "test_aztec" "options"
|
||||
run_zxingcpp_test "test_aztec" "encode"
|
||||
run_zxingcpp_test "test_aztec" "encode_segs"
|
||||
run_zxingcpp_test "test_aztec" "fuzz"
|
||||
|
||||
+1
-1
@@ -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 and Data Matrix only */
|
||||
/* Note: currently Aztec Code, 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 */
|
||||
|
||||
|
||||
+1
-1
@@ -577,7 +577,7 @@ static const char help_message[] = "zint tcl(stub,obj) dll\n"
|
||||
" -eci choice: ECI to use\n"
|
||||
/* cli option --embedfont not supported (vector output only) */
|
||||
" -esc bool: process escape sequences in input data\n"
|
||||
" -extraesc bool: process symbology-specific escape sequences (Code 128 and Data Matrix only)\n"
|
||||
" -extraesc bool: process symbology-specific escape sequences (Aztec Code, Code 128, Data Matrix)\n"
|
||||
" -fast bool: use fast encodation (Aztec, Data Matrix, MicroPDF417, PDF417, QR, UPNQR)\n"
|
||||
" -fg color: set foreground color as 6 or 8 hex rrggbbaa\n"
|
||||
/* replaces cli options --binary and --gs1 */
|
||||
|
||||
+56
-41
@@ -1515,25 +1515,25 @@ Sequences</caption>
|
||||
<tr>
|
||||
<td style="text-align: left;"><code>\^1</code></td>
|
||||
<td style="text-align: left;">Insert <code>FNC1</code> character</td>
|
||||
<td>Code128, Data Matrix</td>
|
||||
<td>Aztec Code, Code 128, Data Matrix</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;"><code>\^^</code></td>
|
||||
<td style="text-align: left;">Literal <code>\^</code></td>
|
||||
<td>Code128, Data Matrix</td>
|
||||
<td>Aztec Code, Code 128, Data Matrix</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;"><code>\^A</code>, <code>\^B</code>,
|
||||
<code>\^C</code></td>
|
||||
<td style="text-align: left;">Select Code Set A, B or C
|
||||
respectively</td>
|
||||
<td>Code128 only</td>
|
||||
<td>Code 128 only</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;"><code>\^@</code></td>
|
||||
<td style="text-align: left;">Exit manual Code Set selection and resume
|
||||
automatic Code Set selection</td>
|
||||
<td>Code128 only</td>
|
||||
<td>Code 128 only</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -4297,7 +4297,8 @@ other shortcuts if available (affects <code>AZTEC</code>,
|
||||
<tr>
|
||||
<td style="text-align: left;"><code>EXTRA_ESCAPE_MODE</code></td>
|
||||
<td style="text-align: left;">Process special symbology-specific escape
|
||||
sequences (<code>CODE128</code> and <code>DATAMATRIX</code> only).</td>
|
||||
sequences (<code>AZTEC</code>, <code>CODE128</code> and
|
||||
<code>DATAMATRIX</code> only).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;"><code>GS1SYNTAXENGINE_MODE</code></td>
|
||||
@@ -4740,8 +4741,8 @@ alt="zint -b C25INTER --compliantheight -d "9212320967"" />
|
||||
<p>No check digit is added by default, but can be set the same as for <a
|
||||
href="#standard-code-2-of-5">6.1.2.1 Standard Code 2 of 5</a>.</p>
|
||||
<h4 id="code-2-of-5-data-logic">6.1.2.5 Code 2 of 5 Data Logic</h4>
|
||||
<p>Data Logic can encode numeric input (digits 0-9) up to a maximum of
|
||||
113 digits.</p>
|
||||
<p>Data Logic, also known as China Post or Hong Kong 2 of 5, can encode
|
||||
numeric input (digits 0-9) up to a maximum of 113 digits.</p>
|
||||
<figure>
|
||||
<img src="images/c25logic.svg" class="lin"
|
||||
alt="zint -b C25LOGIC -d "9212320967"" />
|
||||
@@ -5998,7 +5999,7 @@ alt="zint -b PHARMA_TWO --compliantheight -d "29876543"" />
|
||||
</figure>
|
||||
<h3 id="postnet">6.4.2 POSTNET</h3>
|
||||
<p>Used by the United States Postal Service until 2009, the POSTNET
|
||||
barcode was used for encoding zip-codes on mail items. POSTNET uses
|
||||
barcode was used for encoding ZIP codes on mail items. POSTNET uses
|
||||
numerical input data and includes a modulo-10 check digit. While Zint
|
||||
will encode POSTNET symbols of up to 38 digits in length, standard
|
||||
lengths as used by USPS were <code>PostNet6</code> (5-digit ZIP input),
|
||||
@@ -6085,69 +6086,75 @@ alt="zint -b AUSPOST --compliantheight -d "96184209"" />
|
||||
<p>Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format
|
||||
Control Code (FCC) is added by Zint and should not be included in the
|
||||
input data. Reed-Solomon error correction data is generated by Zint.
|
||||
Encoding behaviour is determined by the length of the input data
|
||||
according to the formula shown in the following table. The first 8
|
||||
digits is the DPID.</p>
|
||||
Encoding behaviour is determined by the length and type of the input
|
||||
data as shown in the following table, where <code>C</code> means any
|
||||
valid character.</p>
|
||||
<table id="tbl:auspost_input_formats" style="width:86%;">
|
||||
<caption><span class="table-label">Table 23:</span> Australia Post Input
|
||||
Formats</caption>
|
||||
<colgroup>
|
||||
<col style="width: 13%" />
|
||||
<col style="width: 38%" />
|
||||
<col style="width: 11%" />
|
||||
<col style="width: 20%" />
|
||||
<col style="width: 22%" />
|
||||
<col style="width: 12%" />
|
||||
<col style="width: 8%" />
|
||||
<col style="width: 6%" />
|
||||
<col style="width: 12%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align: left;">Input Length</th>
|
||||
<th style="text-align: left;">Required Input Format</th>
|
||||
<th>Symbol Length</th>
|
||||
<th style="text-align: left;">DPID (required)</th>
|
||||
<th style="text-align: left;">Customer Data (optional)</th>
|
||||
<th style="text-align: left;">Symbol Length</th>
|
||||
<th>FCC</th>
|
||||
<th>Encoding Table(s)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align: left;">8</td>
|
||||
<td style="text-align: left;"><code>99999999</code></td>
|
||||
<td>37-bar</td>
|
||||
<td style="text-align: left;">1-8</td>
|
||||
<td style="text-align: left;">1 to 8 digits</td>
|
||||
<td style="text-align: left;">None</td>
|
||||
<td style="text-align: left;">37 bars</td>
|
||||
<td>11</td>
|
||||
<td>N</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">13</td>
|
||||
<td style="text-align: left;"><code>99999999AAAAA</code></td>
|
||||
<td>52-bar</td>
|
||||
<td style="text-align: left;">9-13</td>
|
||||
<td style="text-align: left;">8 digits</td>
|
||||
<td style="text-align: left;">1 to 5 <code>C</code></td>
|
||||
<td style="text-align: left;">52 bars</td>
|
||||
<td>59</td>
|
||||
<td>N and C</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">16</td>
|
||||
<td style="text-align: left;"><code>9999999999999999</code></td>
|
||||
<td>52-bar</td>
|
||||
<td style="text-align: left;">9-16</td>
|
||||
<td style="text-align: left;">8 digits</td>
|
||||
<td style="text-align: left;">1 to 8 digits</td>
|
||||
<td style="text-align: left;">52 bars</td>
|
||||
<td>59</td>
|
||||
<td>N</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">18</td>
|
||||
<td style="text-align: left;"><code>99999999AAAAAAAAAA</code></td>
|
||||
<td>67-bar</td>
|
||||
<td style="text-align: left;">9-18</td>
|
||||
<td style="text-align: left;">8 digits</td>
|
||||
<td style="text-align: left;">1 to 10 <code>C</code></td>
|
||||
<td style="text-align: left;">67 bars</td>
|
||||
<td>62</td>
|
||||
<td>N and C</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: left;">23</td>
|
||||
<td style="text-align: left;"><code>99999999999999999999999</code></td>
|
||||
<td>67-bar</td>
|
||||
<td style="text-align: left;">9-23</td>
|
||||
<td style="text-align: left;">8 digits</td>
|
||||
<td style="text-align: left;">1 to 15 digits</td>
|
||||
<td style="text-align: left;">67 bars</td>
|
||||
<td>62</td>
|
||||
<td>N</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The special Null FCC 00, non-machine readable and intended for
|
||||
customer use only, is used (all input lengths) if the DPID is all
|
||||
zeroes.</p>
|
||||
<p>The special Null FCC 00, intended for customer use only, is used (all
|
||||
input lengths) if the DPID is all zeroes.</p>
|
||||
<h4 id="reply-paid-barcode">6.5.1.2 Reply Paid Barcode</h4>
|
||||
<p>A Reply Paid version of the Australia Post 4-State Barcode (FCC 45)
|
||||
which requires an 8-digit DPID input.</p>
|
||||
@@ -6282,10 +6289,10 @@ alt="zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234&qu
|
||||
<figcaption><span class="figure-label">Figure 108:</span>
|
||||
<code>zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"</code></figcaption>
|
||||
</figure>
|
||||
<p>Intelligent Mail is a fixed length (65-bar) symbol which combines
|
||||
<p>Intelligent Mail is a fixed length 65-bar symbol which combines
|
||||
routing and customer information in a single symbol. Input data consists
|
||||
of a 20-digit tracking code, followed by a dash (<code>-</code>),
|
||||
followed by a delivery point zip-code which can be 0, 5, 9 or 11 digits
|
||||
followed by a delivery point ZIP code which can be 0, 5, 9 or 11 digits
|
||||
in length. For example all of the following inputs are valid data
|
||||
entries:</p>
|
||||
<ul>
|
||||
@@ -7764,6 +7771,14 @@ length of approximately 3823 numeric or 3067 alphabetic characters or
|
||||
1914 bytes of data. A separate symbology ID
|
||||
(<code>BARCODE_HIBC_AZTEC</code>) can be used to encode Health Industry
|
||||
Barcode (HIBC) data.</p>
|
||||
<p>Manual insertion of <code>FNC1</code> is possible using the
|
||||
<code>--extraesc</code> option (API
|
||||
<code>input_mode |= EXTRA_ESCAPE_MODE</code>), which apart from
|
||||
processing normal escape sequences also processes the extra escape
|
||||
sequences given in <span class="cross-ref-group"><a
|
||||
href="#tbl:extra_escapes" class="cross-ref">Table 3: Extra Escape
|
||||
Sequences</a></span> - see <a href="#data-matrix-iso-16022">6.6.1 Data
|
||||
Matrix (ISO 16022)</a> for details.</p>
|
||||
<p>For a faster but less optimal encodation, the <code>--fast</code>
|
||||
option (API <code>input_mode |= FAST_MODE</code>) may be used.</p>
|
||||
<p>Aztec Code supports Structured Append of up to 26 symbols and an
|
||||
@@ -8520,12 +8535,12 @@ reply mail with a</td>
|
||||
<tr>
|
||||
<td>B</td>
|
||||
<td style="text-align: left;">Used for business reply mail without a
|
||||
pre-printed zip code.</td>
|
||||
pre-printed ZIP code.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>C</td>
|
||||
<td style="text-align: left;">Used for business reply mail with a
|
||||
pre-printed zip code.</td>
|
||||
pre-printed ZIP code.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>D</td>
|
||||
@@ -9421,9 +9436,9 @@ are:</p>
|
||||
<dt><code>--extraesc</code></dt>
|
||||
<dd>
|
||||
<p>As well as processing the normal escape sequences above, process the
|
||||
special escape sequences beginning with <code>\^</code>. For Code 128
|
||||
and Data Matrix, process the escape sequence <code>\^1</code> that
|
||||
inserts an <code>FNC1</code> character, and the escaping sequence
|
||||
special escape sequences beginning with <code>\^</code>. For Aztec Code,
|
||||
Code 128 and Data Matrix, process the escape sequence <code>\^1</code>
|
||||
that inserts an <code>FNC1</code> character, and the escaping sequence
|
||||
<code>\^^</code> that encodes a literal <code>\^</code>. For Code 128
|
||||
only, process the escape sequences <code>\^A</code>, <code>\^B</code>,
|
||||
<code>\^C</code> and <code>\^@</code> that allow manual switching of
|
||||
|
||||
+31
-23
@@ -603,14 +603,16 @@ the sequence backslash caret ("`\^`"):
|
||||
Extra Escape Interpretation Available for Symbology
|
||||
Sequence
|
||||
----------------- ------------------------------ -----------------------
|
||||
`\^1` Insert `FNC1` character Code128, Data Matrix
|
||||
`\^1` Insert `FNC1` character Aztec Code, Code 128,
|
||||
Data Matrix
|
||||
|
||||
`\^^` Literal `\^` Code128, Data Matrix
|
||||
`\^^` Literal `\^` Aztec Code, Code 128,
|
||||
Data Matrix
|
||||
|
||||
`\^A`, `\^B`, `\^C` Select Code Set A, B or C Code128 only
|
||||
`\^A`, `\^B`, `\^C` Select Code Set A, B or C Code 128 only
|
||||
respectively
|
||||
|
||||
`\^@` Exit manual Code Set selection Code128 only
|
||||
`\^@` Exit manual Code Set selection Code 128 only
|
||||
and resume automatic Code Set
|
||||
selection
|
||||
---------------------------------------------------------------------------
|
||||
@@ -2552,7 +2554,7 @@ Value Effect
|
||||
`MICROPDF417`, `PDF417`, `QRCODE` and `UPNQR` only).
|
||||
|
||||
`EXTRA_ESCAPE_MODE` Process special symbology-specific escape sequences
|
||||
(`CODE128` and `DATAMATRIX` only).
|
||||
(`AZTEC`, `CODE128` and `DATAMATRIX` only).
|
||||
|
||||
`GS1SYNTAXENGINE_MODE` Use the GS1 Syntax Engine (if available) to strictly
|
||||
validate GS1 input.
|
||||
@@ -3007,7 +3009,8 @@ Standard Code 2 of 5].
|
||||
|
||||
#### 6.1.2.5 Code 2 of 5 Data Logic
|
||||
|
||||
Data Logic can encode numeric input (digits 0-9) up to a maximum of 113 digits.
|
||||
Data Logic, also known as China Post or Hong Kong 2 of 5, can encode numeric
|
||||
input (digits 0-9) up to a maximum of 113 digits.
|
||||
|
||||
{.lin}
|
||||
|
||||
@@ -4056,7 +4059,7 @@ pharmaceuticals. The symbology is able to encode whole numbers between 4 and
|
||||
### 6.4.2 POSTNET
|
||||
|
||||
Used by the United States Postal Service until 2009, the POSTNET barcode was
|
||||
used for encoding zip-codes on mail items. POSTNET uses numerical input data and
|
||||
used for encoding ZIP codes on mail items. POSTNET uses numerical input data and
|
||||
includes a modulo-10 check digit. While Zint will encode POSTNET symbols of up
|
||||
to 38 digits in length, standard lengths as used by USPS were `PostNet6`
|
||||
(5-digit ZIP input), `PostNet10` (5-digit ZIP + 4-digit user data) and
|
||||
@@ -4141,28 +4144,28 @@ on mail items.
|
||||
Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control
|
||||
Code (FCC) is added by Zint and should not be included in the input data.
|
||||
Reed-Solomon error correction data is generated by Zint. Encoding behaviour is
|
||||
determined by the length of the input data according to the formula shown in the
|
||||
following table. The first 8 digits is the DPID.
|
||||
determined by the length and type of the input data as shown in the following
|
||||
table, where `C` means any valid character.
|
||||
|
||||
-------------------------------------------------------------
|
||||
Input Required Input Format Symbol FCC Encoding
|
||||
Length Length Table(s)
|
||||
------ ------------------------- ------ --- --------
|
||||
8 `99999999` 37-bar 11 N
|
||||
Input DPID Customer Data Symbol FCC Encoding
|
||||
Length (required) (optional) Length Table(s)
|
||||
------ ------------- -------------- ------- --- --------
|
||||
1-8 1 to 8 digits None 37 bars 11 N
|
||||
|
||||
13 `99999999AAAAA` 52-bar 59 N and C
|
||||
9-13 8 digits 1 to 5 `C` 52 bars 59 N and C
|
||||
|
||||
16 `9999999999999999` 52-bar 59 N
|
||||
9-16 8 digits 1 to 8 digits 52 bars 59 N
|
||||
|
||||
18 `99999999AAAAAAAAAA` 67-bar 62 N and C
|
||||
9-18 8 digits 1 to 10 `C` 67 bars 62 N and C
|
||||
|
||||
23 `99999999999999999999999` 67-bar 62 N
|
||||
9-23 8 digits 1 to 15 digits 67 bars 62 N
|
||||
-------------------------------------------------------------
|
||||
|
||||
Table: Australia Post Input Formats {#tbl:auspost_input_formats}
|
||||
|
||||
The special Null FCC 00, non-machine readable and intended for customer use
|
||||
only, is used (all input lengths) if the DPID is all zeroes.
|
||||
The special Null FCC 00, intended for customer use only, is used (all input
|
||||
lengths) if the DPID is all zeroes.
|
||||
|
||||
#### 6.5.1.2 Reply Paid Barcode
|
||||
|
||||
@@ -4256,9 +4259,9 @@ PLANET symbologies in 2009.
|
||||
{.trk}
|
||||
|
||||
Intelligent Mail is a fixed length (65-bar) symbol which combines routing and
|
||||
Intelligent Mail is a fixed length 65-bar symbol which combines routing and
|
||||
customer information in a single symbol. Input data consists of a 20-digit
|
||||
tracking code, followed by a dash (`-`), followed by a delivery point zip-code
|
||||
tracking code, followed by a dash (`-`), followed by a delivery point ZIP code
|
||||
which can be 0, 5, 9 or 11 digits in length. For example all of the following
|
||||
inputs are valid data entries:
|
||||
|
||||
@@ -4887,6 +4890,11 @@ approximately 3823 numeric or 3067 alphabetic characters or 1914 bytes of data.
|
||||
A separate symbology ID (`BARCODE_HIBC_AZTEC`) can be used to encode Health
|
||||
Industry Barcode (HIBC) data.
|
||||
|
||||
Manual insertion of `FNC1` is possible using the `--extraesc` option (API
|
||||
`input_mode |= EXTRA_ESCAPE_MODE`), which apart from processing normal escape
|
||||
sequences also processes the extra escape sequences given in
|
||||
[#tbl:extra_escapes] - see [6.6.1 Data Matrix (ISO 16022)] for details.
|
||||
|
||||
For a faster but less optimal encodation, the `--fast` option (API `input_mode
|
||||
|= FAST_MODE`) may be used.
|
||||
|
||||
@@ -5164,8 +5172,8 @@ Code Letter Usage
|
||||
----------- --------------------------------------------------------------
|
||||
A Used for courtesy reply mail and metered reply mail with a
|
||||
pre-printed POSTNET symbol.
|
||||
B Used for business reply mail without a pre-printed zip code.
|
||||
C Used for business reply mail with a pre-printed zip code.
|
||||
B Used for business reply mail without a pre-printed ZIP code.
|
||||
C Used for business reply mail with a pre-printed ZIP code.
|
||||
D Used for Information Based Indicia (IBI) postage.
|
||||
E Used for customized mail with a USPS Intelligent Mail barcode.
|
||||
|
||||
|
||||
+38
-30
@@ -755,14 +755,16 @@ the sequence backslash caret (“\^”):
|
||||
Extra Escape Interpretation Available for Symbology
|
||||
Sequence
|
||||
-------------------- ------------------------------- -----------------------
|
||||
\^1 Insert FNC1 character Code128, Data Matrix
|
||||
\^1 Insert FNC1 character Aztec Code, Code 128,
|
||||
Data Matrix
|
||||
|
||||
\^^ Literal \^ Code128, Data Matrix
|
||||
\^^ Literal \^ Aztec Code, Code 128,
|
||||
Data Matrix
|
||||
|
||||
\^A, \^B, \^C Select Code Set A, B or C Code128 only
|
||||
\^A, \^B, \^C Select Code Set A, B or C Code 128 only
|
||||
respectively
|
||||
|
||||
\^@ Exit manual Code Set selection Code128 only
|
||||
\^@ Exit manual Code Set selection Code 128 only
|
||||
and resume automatic Code Set
|
||||
selection
|
||||
----------------------------------------------------------------------------
|
||||
@@ -2509,7 +2511,7 @@ member:
|
||||
MICROPDF417, PDF417, QRCODE and UPNQR only).
|
||||
|
||||
EXTRA_ESCAPE_MODE Process special symbology-specific escape sequences
|
||||
(CODE128 and DATAMATRIX only).
|
||||
(AZTEC, CODE128 and DATAMATRIX only).
|
||||
|
||||
GS1SYNTAXENGINE_MODE Use the GS1 Syntax Engine (if available) to strictly
|
||||
validate GS1 input.
|
||||
@@ -2909,7 +2911,8 @@ Standard Code 2 of 5.
|
||||
|
||||
6.1.2.5 Code 2 of 5 Data Logic
|
||||
|
||||
Data Logic can encode numeric input (digits 0-9) up to a maximum of 113 digits.
|
||||
Data Logic, also known as China Post or Hong Kong 2 of 5, can encode numeric
|
||||
input (digits 0-9) up to a maximum of 113 digits.
|
||||
|
||||
[zint -b C25LOGIC -d "9212320967"]
|
||||
|
||||
@@ -3874,7 +3877,7 @@ pharmaceuticals. The symbology is able to encode whole numbers between 4 and
|
||||
6.4.2 POSTNET
|
||||
|
||||
Used by the United States Postal Service until 2009, the POSTNET barcode was
|
||||
used for encoding zip-codes on mail items. POSTNET uses numerical input data and
|
||||
used for encoding ZIP codes on mail items. POSTNET uses numerical input data and
|
||||
includes a modulo-10 check digit. While Zint will encode POSTNET symbols of up
|
||||
to 38 digits in length, standard lengths as used by USPS were PostNet6 (5-digit
|
||||
ZIP input), PostNet10 (5-digit ZIP + 4-digit user data) and PostNet12 (5-digit
|
||||
@@ -3948,28 +3951,28 @@ on mail items.
|
||||
Valid data characters are 0-9, A-Z, a-z, space and hash (#). A Format Control
|
||||
Code (FCC) is added by Zint and should not be included in the input data.
|
||||
Reed-Solomon error correction data is generated by Zint. Encoding behaviour is
|
||||
determined by the length of the input data according to the formula shown in the
|
||||
following table. The first 8 digits is the DPID.
|
||||
determined by the length and type of the input data as shown in the following
|
||||
table, where C means any valid character.
|
||||
|
||||
---------------------------------------------------------------
|
||||
Input Required Input Format Symbol FCC Encoding
|
||||
Length Length Table(s)
|
||||
--------- --------------------------- -------- ----- ----------
|
||||
8 99999999 37-bar 11 N
|
||||
-----------------------------------------------------------------
|
||||
Input DPID Customer Data Symbol FCC Encoding
|
||||
Length (required) (optional) Length Table(s)
|
||||
-------- -------------- --------------- -------- ----- ----------
|
||||
1-8 1 to 8 digits None 37 bars 11 N
|
||||
|
||||
13 99999999AAAAA 52-bar 59 N and C
|
||||
9-13 8 digits 1 to 5 C 52 bars 59 N and C
|
||||
|
||||
16 9999999999999999 52-bar 59 N
|
||||
9-16 8 digits 1 to 8 digits 52 bars 59 N
|
||||
|
||||
18 99999999AAAAAAAAAA 67-bar 62 N and C
|
||||
9-18 8 digits 1 to 10 C 67 bars 62 N and C
|
||||
|
||||
23 99999999999999999999999 67-bar 62 N
|
||||
---------------------------------------------------------------
|
||||
9-23 8 digits 1 to 15 digits 67 bars 62 N
|
||||
-----------------------------------------------------------------
|
||||
|
||||
Table 23: Australia Post Input Formats
|
||||
|
||||
The special Null FCC 00, non-machine readable and intended for customer use
|
||||
only, is used (all input lengths) if the DPID is all zeroes.
|
||||
The special Null FCC 00, intended for customer use only, is used (all input
|
||||
lengths) if the DPID is all zeroes.
|
||||
|
||||
6.5.1.2 Reply Paid Barcode
|
||||
|
||||
@@ -4062,9 +4065,9 @@ PLANET symbologies in 2009.
|
||||
|
||||
[zint -b USPS_IMAIL --compliantheight -d "01234567094987654321-01234"]
|
||||
|
||||
Intelligent Mail is a fixed length (65-bar) symbol which combines routing and
|
||||
Intelligent Mail is a fixed length 65-bar symbol which combines routing and
|
||||
customer information in a single symbol. Input data consists of a 20-digit
|
||||
tracking code, followed by a dash (-), followed by a delivery point zip-code
|
||||
tracking code, followed by a dash (-), followed by a delivery point ZIP code
|
||||
which can be 0, 5, 9 or 11 digits in length. For example all of the following
|
||||
inputs are valid data entries:
|
||||
|
||||
@@ -4663,6 +4666,11 @@ approximately 3823 numeric or 3067 alphabetic characters or 1914 bytes of data.
|
||||
A separate symbology ID (BARCODE_HIBC_AZTEC) can be used to encode Health
|
||||
Industry Barcode (HIBC) data.
|
||||
|
||||
Manual insertion of FNC1 is possible using the --extraesc option (API
|
||||
input_mode |= EXTRA_ESCAPE_MODE), which apart from processing normal escape
|
||||
sequences also processes the extra escape sequences given in Table 3: Extra
|
||||
Escape Sequences - see 6.6.1 Data Matrix (ISO 16022) for details.
|
||||
|
||||
For a faster but less optimal encodation, the --fast option (API
|
||||
input_mode |= FAST_MODE) may be used.
|
||||
|
||||
@@ -4933,8 +4941,8 @@ as shown in the table below.
|
||||
------------- ----------------------------------------------------------------
|
||||
A Used for courtesy reply mail and metered reply mail with a
|
||||
pre-printed POSTNET symbol.
|
||||
B Used for business reply mail without a pre-printed zip code.
|
||||
C Used for business reply mail with a pre-printed zip code.
|
||||
B Used for business reply mail without a pre-printed ZIP code.
|
||||
C Used for business reply mail with a pre-printed ZIP code.
|
||||
D Used for Information Based Indicia (IBI) postage.
|
||||
E Used for customized mail with a USPS Intelligent Mail barcode.
|
||||
|
||||
@@ -5459,11 +5467,11 @@ OPTIONS
|
||||
--extraesc
|
||||
|
||||
As well as processing the normal escape sequences above, process the special
|
||||
escape sequences beginning with \^. For Code 128 and Data Matrix, process
|
||||
the escape sequence \^1 that inserts an FNC1 character, and the escaping
|
||||
sequence \^^ that encodes a literal \^. For Code 128 only, process the
|
||||
escape sequences \^A, \^B, \^C and \^@ that allow manual switching of Code
|
||||
Sets. The sequence \^@ turns off manual switching.
|
||||
escape sequences beginning with \^. For Aztec Code, Code 128 and Data
|
||||
Matrix, process the escape sequence \^1 that inserts an FNC1 character, and
|
||||
the escaping sequence \^^ that encodes a literal \^. For Code 128 only,
|
||||
process the escape sequences \^A, \^B, \^C and \^@ that allow manual
|
||||
switching of Code Sets. The sequence \^@ turns off manual switching.
|
||||
|
||||
--fast
|
||||
|
||||
|
||||
+1
-1
@@ -215,7 +215,7 @@ The escape sequences are:
|
||||
\f[CR]\-\-extraesc\f[R]
|
||||
As well as processing the normal escape sequences above, process the
|
||||
special escape sequences beginning with \f[CR]\(rs\(ha\f[R].
|
||||
For Code 128 and Data Matrix, process the escape sequence
|
||||
For Aztec Code, Code 128 and Data Matrix, process the escape sequence
|
||||
\f[CR]\(rs\(ha1\f[R] that inserts an \f[CR]FNC1\f[R] character, and the
|
||||
escaping sequence \f[CR]\(rs\(ha\(ha\f[R] that encodes a literal
|
||||
\f[CR]\(rs\(ha\f[R].
|
||||
|
||||
+3
-3
@@ -194,9 +194,9 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
|
||||
`--extraesc`
|
||||
|
||||
: As well as processing the normal escape sequences above, process the special escape sequences beginning with `\^`.
|
||||
For Code 128 and Data Matrix, process the escape sequence `\^1` that inserts an `FNC1` character, and the escaping
|
||||
sequence `\^^` that encodes a literal `\^`. For Code 128 only, process the escape sequences `\^A`, `\^B`, `\^C`
|
||||
and `\^@` that allow manual switching of Code Sets. The sequence `\^@` turns off manual switching.
|
||||
For Aztec Code, Code 128 and Data Matrix, process the escape sequence `\^1` that inserts an `FNC1` character, and
|
||||
the escaping sequence `\^^` that encodes a literal `\^`. For Code 128 only, process the escape sequences `\^A`,
|
||||
`\^B`, `\^C` and `\^@` that allow manual switching of Code Sets. The sequence `\^@` turns off manual switching.
|
||||
|
||||
`--fast`
|
||||
|
||||
|
||||
@@ -369,6 +369,18 @@ the data with a slash "/"</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QRadioButton" name="radAztecExtraEsc">
|
||||
<property name="text">
|
||||
<string>Manual FN&C1s (Extra Escape)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Process special escape sequence "\^1"
|
||||
allowing manual FNC1s
|
||||
(literal "\^" may be escaped with "\^^")</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -1856,6 +1856,7 @@ void MainWindow::change_options()
|
||||
connect(get_widget(QSL("radAztecStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radAztecGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radAztecHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radAztecExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("chkAztecFull")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("chkAztecFast")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("cmbAztecStructAppCount")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
|
||||
@@ -2026,9 +2027,9 @@ void MainWindow::change_options()
|
||||
dm_startmode_ui_set();
|
||||
tabMain->insertTab(1, m_optionWidget, tr("D&ata Matrix"));
|
||||
connect(get_widget(QSL("radDMStand")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radDMExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radDMGS1")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radDMHIBC")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("radDMExtraEsc")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("cmbDMSize")), SIGNAL(currentIndexChanged(int)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("chkDMRectangle")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("chkDMRE")), SIGNAL(toggled(bool)), SLOT(update_preview()));
|
||||
@@ -2952,10 +2953,14 @@ void MainWindow::update_preview()
|
||||
break;
|
||||
|
||||
case BARCODE_AZTEC:
|
||||
if (get_rad_val(QSL("radAztecHIBC")))
|
||||
if (get_rad_val(QSL("radAztecHIBC"))) {
|
||||
m_bc.bc.setSymbol(BARCODE_HIBC_AZTEC);
|
||||
else
|
||||
} else {
|
||||
m_bc.bc.setSymbol(BARCODE_AZTEC);
|
||||
if (get_rad_val(QSL("radAztecExtraEsc"))) {
|
||||
m_bc.bc.setInputMode(m_bc.bc.inputMode() | EXTRA_ESCAPE_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
if (get_rad_val(QSL("radAztecSize"))) {
|
||||
m_bc.bc.setOption2(get_cmb_index(QSL("cmbAztecSize")) + 1);
|
||||
@@ -4458,7 +4463,8 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology)
|
||||
settings.setValue(QSL("studio/bc/aztec/size"), m_aztecSizeIndex);
|
||||
settings.setValue(QSL("studio/bc/aztec/ecc"), m_aztecECCIndex);
|
||||
settings.setValue(QSL("studio/bc/aztec/encoding_mode"), get_rad_grp_index(
|
||||
QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC")));
|
||||
QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC")
|
||||
<< QSL("radAztecExtraEsc")));
|
||||
settings.setValue(QSL("studio/bc/aztec/structapp_count"), get_cmb_index(QSL("cmbAztecStructAppCount")));
|
||||
settings.setValue(QSL("studio/bc/aztec/chk_full"), get_chk_val(QSL("chkAztecFull")));
|
||||
settings.setValue(QSL("studio/bc/aztec/chk_fast"), get_chk_val(QSL("chkAztecFast")));
|
||||
@@ -4933,7 +4939,8 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
|
||||
}
|
||||
set_cmb_from_setting(settings, QSL("studio/bc/aztec/ecc"), QSL("cmbAztecECC"));
|
||||
set_rad_from_setting(settings, QSL("studio/bc/aztec/encoding_mode"),
|
||||
QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC"));
|
||||
QStringList() << QSL("radAztecStand") << QSL("radAztecGS1") << QSL("radAztecHIBC")
|
||||
<< QSL("radAztecExtraEsc"));
|
||||
set_chk_from_setting(settings, QSL("studio/bc/aztec/chk_full"), QSL("chkAztecFull"));
|
||||
set_chk_from_setting(settings, QSL("studio/bc/aztec/chk_fast"), QSL("chkAztecFast"));
|
||||
set_cmb_from_setting(settings, QSL("studio/bc/aztec/structapp_count"), QSL("cmbAztecStructAppCount"));
|
||||
|
||||
Reference in New Issue
Block a user