Add GS1PARENS_MODE (input_mode) to allow inputting GS1 AIs in parentheses

This commit is contained in:
gitlost 2021-05-15 12:23:46 +01:00
parent 6fb0d077bc
commit 79d3c1dc7a
38 changed files with 672 additions and 359 deletions

14
README
View File

@ -294,6 +294,12 @@ Changes:
- Performance improvements (large data) for Aztec, Han Xin, Grid Matrix, PDF417
and QR
- Option scmvv for MaxiCode #212; postcode needn't be space-filled
- eci: Add support for all ECIs (Big5, Korean, UCS-2BE)
- CLI: Handle UTF-8 args on Windows; -b <barcode name>
- DATAMATRIX: make EOD encodation strictly ISO 16022 compliant
- png.c: Use palette for file size savings
- tif.c: Use palette/bilevel/LZW to reduce file size, alpha/CMYK support
- Option gs1parens (GS1PARENS_MODE)
Bugs:
- Code16k selects GS1 mode by default in GUI
@ -308,6 +314,14 @@ Bugs:
- EAN composite: allow for check digit + buffer overflow for too long add-on
- Han Xin fix 0xFFE terminator
- GUI: Use UTF-8 for QSettings (non-ASCII was getting garbled on restore)
- DOTCODE: Fix best_mask -> high_score prime test
- CODEONE: various fixes, ECI support
- #218 Prevent buffer overflow in ean_leading_zeroes by checking max lengths
- MAXICODE: fix mask typos for ECI 3/4 bytes
- Fix UPCEAN small font ignored/disabled (introduced [1adba1])
- get_best_eci: check UTF-8 before returning 26
- MAXICODE: fix shifting from sets C/D/E to A/B (only latch available)
- EAN14, NVE18: fix checksum calc for zero-filled input
CONTACT US
----------

View File

@ -305,6 +305,10 @@ INTERNAL int c39(struct zint_symbol *symbol, unsigned char source[], int length)
}
}
if (symbol->debug) {
printf("Barspaces: %s\n", dest);
}
expand(symbol, dest);
if (symbol->symbology == BARCODE_CODE39) {

View File

@ -1041,7 +1041,7 @@ INTERNAL int nve_18(struct zint_symbol *symbol, unsigned char source[], int leng
}
zeroes = 17 - length;
ustrcpy(ean128_equiv, "[00]");
ustrcpy(ean128_equiv, symbol->input_mode & GS1PARENS_MODE ? "(00)" : "[00]");
memset(ean128_equiv + 4, '0', zeroes);
ustrcpy(ean128_equiv + 4 + zeroes, source);
@ -1079,7 +1079,7 @@ INTERNAL int ean_14(struct zint_symbol *symbol, unsigned char source[], int leng
}
zeroes = 13 - length;
ustrcpy(ean128_equiv, "[01]");
ustrcpy(ean128_equiv, symbol->input_mode & GS1PARENS_MODE ? "(01)" : "[01]");
memset(ean128_equiv + 4, '0', zeroes);
ustrcpy(ean128_equiv + 4 + zeroes, source);

View File

@ -1247,13 +1247,14 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
return 0;
}
static int linear_dummy_run(unsigned char *source, const int length, char *errtxt) {
static int linear_dummy_run(int input_mode, unsigned char *source, const int length, char *errtxt) {
struct zint_symbol *dummy;
int error_number;
int linear_width;
dummy = ZBarcode_Create();
dummy->symbology = BARCODE_GS1_128_CC;
dummy->input_mode = input_mode;
dummy->option_1 = 3;
error_number = ean_128(dummy, source, length);
linear_width = dummy->width;
@ -1304,7 +1305,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
if (symbol->symbology == BARCODE_GS1_128_CC) {
/* Do a test run of encoding the linear component to establish its width */
linear_width = linear_dummy_run((unsigned char *) symbol->primary, pri_len, symbol->errtxt);
linear_width = linear_dummy_run(symbol->input_mode, (unsigned char *) symbol->primary, pri_len, symbol->errtxt);
if (linear_width == 0) {
strcat(symbol->errtxt, " in linear component");
return ZINT_ERROR_INVALID_DATA;
@ -1424,6 +1425,7 @@ INTERNAL int composite(struct zint_symbol *symbol, unsigned char source[], int l
linear = ZBarcode_Create(); /* Symbol contains the 2D component and Linear contains the rest */
linear->symbology = symbol->symbology;
linear->input_mode = symbol->input_mode;
linear->option_2 = symbol->option_2;
linear->debug = symbol->debug;

View File

@ -243,7 +243,7 @@ static int isc40text(const int current_mode, const unsigned char input) {
}
/* Return true (1) if a character is valid in X12 set */
static int isX12(const int input) {
static int isX12(const unsigned char input) {
if (isc40(input)) {
return 1;

View File

@ -1187,7 +1187,9 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
int bracket_level, max_bracket_level, ai_length, max_ai_length, min_ai_length;
int ai_count;
int error_value = 0;
int ai_max = chr_cnt(source, src_len, '[') + 1; /* Plus 1 so non-zero */
char obracket = symbol->input_mode & GS1PARENS_MODE ? '(' : '[';
char cbracket = symbol->input_mode & GS1PARENS_MODE ? ')' : ']';
int ai_max = chr_cnt(source, src_len, obracket) + 1; /* Plus 1 so non-zero */
#ifndef _MSC_VER
int ai_value[ai_max], ai_location[ai_max], data_location[ai_max], data_length[ai_max];
#else
@ -1217,7 +1219,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
}
}
if (source[0] != '[') {
if (source[0] != obracket) {
strcpy(symbol->errtxt, "252: Data does not start with an AI");
if (symbol->warn_level != WARN_ZPL_COMPAT) {
return ZINT_ERROR_INVALID_DATA;
@ -1236,14 +1238,14 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
ai_latch = 0;
for (i = 0; i < src_len; i++) {
ai_length += j;
if (((j == 1) && (source[i] != ']')) && ((source[i] < '0') || (source[i] > '9'))) {
if (((j == 1) && (source[i] != cbracket)) && ((source[i] < '0') || (source[i] > '9'))) {
ai_latch = 1;
}
if (source[i] == '[') {
if (source[i] == obracket) {
bracket_level++;
j = 1;
}
if (source[i] == ']') {
if (source[i] == cbracket) {
bracket_level--;
if (ai_length < min_ai_length) {
min_ai_length = ai_length;
@ -1292,13 +1294,13 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
ai_count = 0;
for (i = 1; i < src_len; i++) {
if (source[i - 1] == '[') {
if (source[i - 1] == obracket) {
ai_location[ai_count] = i;
j = 0;
do {
ai_string[j] = source[i + j];
j++;
} while (ai_string[j - 1] != ']');
} while (ai_string[j - 1] != cbracket);
ai_string[j - 1] = '\0';
ai_value[ai_count] = atoi(ai_string);
ai_count++;
@ -1315,7 +1317,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
}
data_length[i] = 0;
while ((data_location[i] + data_length[i] < src_len)
&& (source[data_location[i] + data_length[i]] != '[')) {
&& (source[data_location[i] + data_length[i]] != obracket)) {
data_length[i]++;
}
if (data_length[i] == 0) {
@ -1352,10 +1354,10 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
j = 0;
ai_latch = 1;
for (i = 0; i < src_len; i++) {
if ((source[i] != '[') && (source[i] != ']')) {
if ((source[i] != obracket) && (source[i] != cbracket)) {
reduced[j++] = source[i];
}
if (source[i] == '[') {
if (source[i] == obracket) {
/* Start of an AI string */
if (ai_latch == 0) {
reduced[j++] = '[';

View File

@ -39,6 +39,7 @@
#include "common.h"
#include "eci.h"
#include "gs1.h"
#include "zfiletypes.h"
#define TECHNETIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"
@ -49,10 +50,10 @@ typedef int static_assert_int_at_least_32bits[CHAR_BIT != 8 || sizeof(int) < 4 ?
struct zint_symbol *ZBarcode_Create() {
struct zint_symbol *symbol;
symbol = (struct zint_symbol*) malloc(sizeof (*symbol));
symbol = (struct zint_symbol *) malloc(sizeof(*symbol));
if (!symbol) return NULL;
memset(symbol, 0, sizeof (*symbol));
memset(symbol, 0, sizeof(*symbol));
symbol->symbology = BARCODE_CODE128;
strcpy(symbol->fgcolour, "000000");
@ -952,7 +953,7 @@ static int escape_char_process(struct zint_symbol *symbol, unsigned char *input_
#ifndef _MSC_VER
unsigned char escaped_string[*length + 1];
#else
unsigned char* escaped_string = (unsigned char*) _alloca(*length + 1);
unsigned char *escaped_string = (unsigned char *) _alloca(*length + 1);
#endif
in_posn = 0;

View File

@ -45,6 +45,7 @@
#include <assert.h>
#include "common.h"
#include "output.h"
#include "zfiletypes.h"
#include "font.h" /* Font for human readable text */

View File

@ -56,10 +56,12 @@ static void test_options(int index, int debug) {
/* 3*/ { BARCODE_AZTEC, -1, -1, -1, 36, "1234567890", 0, 151, 151 },
/* 4*/ { BARCODE_AZTEC, -1, -1, -1, 37, "1234567890", ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 5*/ { BARCODE_AZTEC, GS1_MODE, READER_INIT, -1, -1, "[91]A", ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 6*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, "A", 0, 109, 109 }, // 22 layers
/* 7*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, "A", ZINT_ERROR_TOO_LONG, -1, -1 }, // 23 layers
/* 8*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, "A", 0, 15, 15 }, // Compact 1 layer
/* 9*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 2, "A", 0, 19, 19 }, // Compact 2 layers gets set to full 1 layer if READER_INIT set
/* 6*/ { BARCODE_AZTEC, GS1_MODE, -1, -1, -1, "[91]A", 0, 15, 15 },
/* 7*/ { BARCODE_AZTEC, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, "(91)A", 0, 15, 15 },
/* 8*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 26, "A", 0, 109, 109 }, // 22 layers
/* 9*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 27, "A", ZINT_ERROR_TOO_LONG, -1, -1 }, // 23 layers
/* 10*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 1, "A", 0, 15, 15 }, // Compact 1 layer
/* 11*/ { BARCODE_AZTEC, -1, READER_INIT, -1, 2, "A", 0, 19, 19 }, // Compact 2 layers gets set to full 1 layer if READER_INIT set
};
int data_size = ARRAY_SIZE(data);

View File

@ -216,25 +216,26 @@ static void test_input(int index, int debug) {
/* 4*/ { -1, -1, 1, "1", -1, 0, 16, 18, "", },
/* 5*/ { -1, -1, 1, "ABCDEFGHIJKLMN", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 518: Input too long for selected symbol size", },
/* 6*/ { GS1_MODE, -1, 1, "[01]12345678901231", -1, 0, 16, 18, "", },
/* 7*/ { -1, 3, 1, "1", -1, 0, 16, 18, "", },
/* 8*/ { UNICODE_MODE, 3, 1, "é", -1, 0, 16, 18, "", },
/* 9*/ { GS1_MODE, 3, 1, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 18, "Warning 512: ECI ignored for GS1 mode", },
/* 10*/ { -1, -1, 9, "123456789012345678", -1, 0, 8, 31, "", },
/* 11*/ { -1, -1, 9, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 515: Invalid input data (Version S encodes numeric input only)", },
/* 12*/ { -1, -1, 9, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 514: Input data too long for Version S", },
/* 13*/ { GS1_MODE, -1, 9, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 8, 31, "Warning 511: ECI and GS1 mode ignored for Version S", },
/* 14*/ { -1, 3, 9, "1", -1, ZINT_WARN_INVALID_OPTION, 8, 11, "Warning 511: ECI and GS1 mode ignored for Version S", },
/* 15*/ { -1, -1, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, 0, 16, 49, "", },
/* 16*/ { -1, -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", },
/* 17*/ { -1, -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 0, 16, 49, "", },
/* 18*/ { -1, -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", },
/* 19*/ { -1, -1, 10, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 38, 0, 16, 49, "", },
/* 20*/ { -1, 3, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456", -1, 0, 16, 49, "", },
/* 21*/ { -1, 3, 10, "12345678901234567890123456789012345678901234567890123456789012345678901234567", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", },
/* 22*/ { -1, 3, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", },
/* 23*/ { GS1_MODE, -1, 10, "[01]12345678901231", -1, 0, 16, 17, "", },
/* 24*/ { GS1_MODE, 3, 10, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 17, "Warning 512: ECI ignored for GS1 mode", },
/* 25*/ { -1, -1, 11, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 513: Invalid symbol size", },
/* 7*/ { GS1_MODE | GS1PARENS_MODE, -1, 1, "(01)12345678901231", -1, 0, 16, 18, "", },
/* 8*/ { -1, 3, 1, "1", -1, 0, 16, 18, "", },
/* 9*/ { UNICODE_MODE, 3, 1, "é", -1, 0, 16, 18, "", },
/* 10*/ { GS1_MODE, 3, 1, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 18, "Warning 512: ECI ignored for GS1 mode", },
/* 11*/ { -1, -1, 9, "123456789012345678", -1, 0, 8, 31, "", },
/* 12*/ { -1, -1, 9, "12345678901234567A", -1, ZINT_ERROR_INVALID_DATA, -1, -1, "Error 515: Invalid input data (Version S encodes numeric input only)", },
/* 13*/ { -1, -1, 9, "1234567890123456789", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 514: Input data too long for Version S", },
/* 14*/ { GS1_MODE, -1, 9, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 8, 31, "Warning 511: ECI and GS1 mode ignored for Version S", },
/* 15*/ { -1, 3, 9, "1", -1, ZINT_WARN_INVALID_OPTION, 8, 11, "Warning 511: ECI and GS1 mode ignored for Version S", },
/* 16*/ { -1, -1, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", -1, 0, 16, 49, "", },
/* 17*/ { -1, -1, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", },
/* 18*/ { -1, -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, 0, 16, 49, "", },
/* 19*/ { -1, -1, 10, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", },
/* 20*/ { -1, -1, 10, "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 38, 0, 16, 49, "", },
/* 21*/ { -1, 3, 10, "1234567890123456789012345678901234567890123456789012345678901234567890123456", -1, 0, 16, 49, "", },
/* 22*/ { -1, 3, 10, "12345678901234567890123456789012345678901234567890123456789012345678901234567", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 516: Input data too long for Version T", },
/* 23*/ { -1, 3, 10, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234", -1, ZINT_ERROR_TOO_LONG, -1, -1, "Error 519: Input data too long for Version T", },
/* 24*/ { GS1_MODE, -1, 10, "[01]12345678901231", -1, 0, 16, 17, "", },
/* 25*/ { GS1_MODE, 3, 10, "[01]12345678901231", -1, ZINT_WARN_INVALID_OPTION, 16, 17, "Warning 512: ECI ignored for GS1 mode", },
/* 26*/ { -1, -1, 11, "1", -1, ZINT_ERROR_INVALID_OPTION, -1, -1, "Error 513: Invalid symbol size", },
};
int data_size = ARRAY_SIZE(data);

View File

@ -368,6 +368,7 @@ static void test_ean128_input(int index, int generate, int debug) {
int ret;
struct item {
int input_mode;
char *data;
int ret;
int expected_width;
@ -375,28 +376,29 @@ static void test_ean128_input(int index, int generate, int debug) {
char *comment;
};
struct item data[] = {
/* 0*/ { "[90]1[90]1", 0, 123, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9" },
/* 1*/ { "[90]1[90]12", 0, 123, "(11) 105 102 90 100 17 99 102 90 12 13 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12" },
/* 2*/ { "[90]1[90]123", 0, 134, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23" },
/* 3*/ { "[90]12[90]1", 0, 123, "(11) 105 102 90 12 102 100 25 99 1 19 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 4*/ { "[90]12[90]12", 0, 101, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" },
/* 5*/ { "[90]12[90]123", 0, 134, "(12) 105 102 90 12 102 100 25 99 1 23 20 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" },
/* 6*/ { "[90]123[90]1", 0, 134, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01" },
/* 7*/ { "[90]123[90]1234", 0, 145, "(13) 105 102 90 12 100 19 99 102 90 12 34 98 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34" },
/* 8*/ { "[90]1[90]1[90]1", 0, 178, "(16) 105 102 90 100 17 102 25 99 1 102 100 25 99 1 51 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 9*/ { "[90]1[90]12[90]1", 0, 178, "(16) 105 102 90 100 17 99 102 90 12 102 100 25 99 1 8 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 10*/ { "[90]1[90]123[90]1", 0, 189, "(17) 105 102 90 100 17 102 25 99 1 23 102 100 25 99 1 70 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 11*/ { "[90]12[90]123[90]1", 0, 189, "(17) 105 102 90 12 102 100 25 99 1 23 102 100 25 99 1 33 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 12*/ { "[90]12[90]123[90]12", 0, 167, "(15) 105 102 90 12 102 100 25 99 1 23 102 90 12 11 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 90 12" },
/* 13*/ { "[90]123[90]1[90]1", 0, 189, "(17) 105 102 90 12 100 19 102 25 99 1 102 100 25 99 1 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 14*/ { "[90]123[90]12[90]1", 0, 189, "(17) 105 102 90 12 100 19 99 102 90 12 102 100 25 99 1 80 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 15*/ { "[90]123[90]123[90]12", 0, 178, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 23 FNC1 90 12" },
/* 16*/ { "[90]123[90]1234[90]1", 0, 200, "(18) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 26 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 17*/ { "[90]123[90]1234[90]123", 0, 211, "(19) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 23 85 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01 23" },
/* 18*/ { "[90]12345[90]1234[90]1", 0, 211, "(19) 105 102 90 12 34 100 21 99 102 90 12 34 102 100 25 99 1 30 106", "StartC FNC1 90 12 34 CodeB 5 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 19*/ { "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" },
/* 20*/ { "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
/* 21*/ { "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" } };
/* 0*/ { GS1_MODE, "[90]1[90]1", 0, 123, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9" },
/* 1*/ { GS1_MODE | GS1PARENS_MODE, "(90)1(90)1", 0, 123, "(11) 105 102 90 100 17 102 25 99 1 56 106", "StartC FNC1 90 CodeB 1 FNC1 9" },
/* 2*/ { GS1_MODE, "[90]1[90]12", 0, 123, "(11) 105 102 90 100 17 99 102 90 12 13 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12" },
/* 3*/ { GS1_MODE, "[90]1[90]123", 0, 134, "(12) 105 102 90 100 17 102 25 99 1 23 57 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23" },
/* 4*/ { GS1_MODE, "[90]12[90]1", 0, 123, "(11) 105 102 90 12 102 100 25 99 1 19 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 5*/ { GS1_MODE, "[90]12[90]12", 0, 101, "(9) 105 102 90 12 102 90 12 14 106", "StartC FNC1 90 12 FNC1 90 12" },
/* 6*/ { GS1_MODE, "[90]12[90]123", 0, 134, "(12) 105 102 90 12 102 100 25 99 1 23 20 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23" },
/* 7*/ { GS1_MODE, "[90]123[90]1", 0, 134, "(12) 105 102 90 12 100 19 102 25 99 1 34 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01" },
/* 8*/ { GS1_MODE, "[90]123[90]1234", 0, 145, "(13) 105 102 90 12 100 19 99 102 90 12 34 98 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34" },
/* 9*/ { GS1_MODE, "[90]1[90]1[90]1", 0, 178, "(16) 105 102 90 100 17 102 25 99 1 102 100 25 99 1 51 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 10*/ { GS1_MODE, "[90]1[90]12[90]1", 0, 178, "(16) 105 102 90 100 17 99 102 90 12 102 100 25 99 1 8 106", "StartC FNC1 90 CodeB 1 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 11*/ { GS1_MODE, "[90]1[90]123[90]1", 0, 189, "(17) 105 102 90 100 17 102 25 99 1 23 102 100 25 99 1 70 106", "StartC FNC1 90 CodeB 1 FNC1 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 12*/ { GS1_MODE, "[90]12[90]123[90]1", 0, 189, "(17) 105 102 90 12 102 100 25 99 1 23 102 100 25 99 1 33 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 CodeB 9 CodeC 01" },
/* 13*/ { GS1_MODE, "[90]12[90]123[90]12", 0, 167, "(15) 105 102 90 12 102 100 25 99 1 23 102 90 12 11 106", "StartC FNC1 90 12 FNC1 CodeB 9 CodeC 01 23 FNC1 90 12" },
/* 14*/ { GS1_MODE, "[90]123[90]1[90]1", 0, 189, "(17) 105 102 90 12 100 19 102 25 99 1 102 100 25 99 1 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 FNC1 CodeB 9 CodeC 01" },
/* 15*/ { GS1_MODE, "[90]123[90]12[90]1", 0, 189, "(17) 105 102 90 12 100 19 99 102 90 12 102 100 25 99 1 80 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 FNC1 CodeB 9 CodeC 01" },
/* 16*/ { GS1_MODE, "[90]123[90]123[90]12", 0, 178, "(16) 105 102 90 12 100 19 102 25 99 1 23 102 90 12 47 106", "StartC FNC1 90 12 CodeB 3 FNC1 9 CodeC 01 23 FNC1 90 12" },
/* 17*/ { GS1_MODE, "[90]123[90]1234[90]1", 0, 200, "(18) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 26 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 18*/ { GS1_MODE, "[90]123[90]1234[90]123", 0, 211, "(19) 105 102 90 12 100 19 99 102 90 12 34 102 100 25 99 1 23 85 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01 23" },
/* 19*/ { GS1_MODE, "[90]12345[90]1234[90]1", 0, 211, "(19) 105 102 90 12 34 100 21 99 102 90 12 34 102 100 25 99 1 30 106", "StartC FNC1 90 12 34 CodeB 5 CodeC FNC1 90 12 34 FNC1 CodeB 9 CodeC 01" },
/* 20*/ { GS1_MODE, "[90]1A[90]1", 0, 134, "(12) 104 102 25 16 17 33 102 25 99 1 65 106", "StartB FNC1 9 0 1 A FNC1 9 CodeC 01" },
/* 21*/ { GS1_MODE, "[90]12A[90]123", 0, 145, "(13) 105 102 90 12 100 33 102 25 99 1 23 25 106", "StartC FNC1 90 12 CodeB A FNC1 9 CodeC 01 23" },
/* 22*/ { GS1_MODE, "[90]123[90]A234[90]123", 0, 244, "(22) 105 102 90 12 100 19 99 102 90 100 33 18 99 34 102 100 25 99 1 23 37 106", "StartC FNC1 90 12 CodeB 3 CodeC FNC1 90 CodeB A 2 CodeC 34 FNC1 CodeB 9 CodeC 01 23" } };
int data_size = ARRAY_SIZE(data);
char escaped[1024];
@ -410,14 +412,14 @@ static void test_ean128_input(int index, int generate, int debug) {
symbol->debug = ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_GS1_128, GS1_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, BARCODE_GS1_128, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
printf(" /*%3d*/ { %s, \"%s\", %s, %d, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)),
testUtilErrorName(data[i].ret), symbol->width, symbol->errtxt, data[i].comment);
} else {
if (ret < ZINT_ERROR) {

View File

@ -166,19 +166,20 @@ static void test_input(int index, int generate, int debug) {
/* 2*/ { UNICODE_MODE, "12", -1, 0, 2, 70, "(10) 2 12 103 103 103 103 103 103 98 27", "ModeC 12 Pad (6)" },
/* 3*/ { GS1_MODE, "[90]A", -1, 0, 2, 70, "(10) 3 25 16 33 103 103 103 103 83 20", "ModeBFNC1 9 0 A Pad (4)" },
/* 4*/ { GS1_MODE, "[90]12", -1, 0, 2, 70, "(10) 4 90 12 103 103 103 103 103 79 62", "ModeCFNC1 90 12 Pad (5)" },
/* 5*/ { UNICODE_MODE, "a0123456789", -1, 0, 2, 70, "(10) 5 65 1 23 45 67 89 103 27 86", "ModeC1SB a 01 23 45 67 89 Pad" },
/* 6*/ { UNICODE_MODE, "ab0123456789", -1, 0, 2, 70, "(10) 6 65 66 1 23 45 67 89 19 42", "ModeC2SB a b 01 23 45 67 89" },
/* 7*/ { UNICODE_MODE, "1234\037a", -1, 0, 2, 70, "(10) 2 12 34 101 95 98 65 103 67 53", "ModeC 12 34 CodeA US 1SB a Pad" },
/* 8*/ { UNICODE_MODE, "\000\037ß", 4, 0, 2, 70, "(10) 0 64 95 101 63 103 103 103 75 11", "ModeA NUL US FNC4 ß Pad (3)" },
/* 9*/ { UNICODE_MODE, "\000\037é", 4, 0, 2, 70, "(10) 0 64 95 101 98 73 103 103 75 6", "ModeA NUL US FNC4 1SB é Pad (2)" },
/* 10*/ { UNICODE_MODE, "\000\037éa", 5, 0, 2, 70, "(10) 0 64 95 100 100 73 65 103 99 69", "ModeA NUL US CodeB FNC4 é a Pad" },
/* 11*/ { UNICODE_MODE, "abß", -1, 0, 2, 70, "(10) 1 65 66 100 63 103 103 103 66 56", "ModeB a b FNC4 ß Pad (3)" },
/* 12*/ { DATA_MODE, "\141\142\237", -1, 0, 2, 70, "(10) 1 65 66 100 98 95 103 103 6 71", "ModeB a b FNC4 1SA APC Pad (2)" },
/* 13*/ { DATA_MODE, "\141\142\237\037", -1, 0, 2, 70, "(10) 1 65 66 101 101 95 95 103 72 93", "ModeB a b CodeA FNC4 APC US Pad" },
/* 14*/ { UNICODE_MODE, "ééé", -1, 0, 2, 70, "(10) 1 100 73 100 73 100 73 103 105 106", "ModeB FNC4 é FNC4 é FNC4 é Pad" },
/* 15*/ { UNICODE_MODE, "aééééb", -1, 0, 3, 70, "(15) 8 65 100 73 100 73 100 73 100 73 66 103 103 39 83", "ModeB a FNC4 é (4) b Pad (2)" },
/* 16*/ { UNICODE_MODE, "aéééééb", -1, 0, 3, 70, "(15) 8 65 100 73 100 73 100 73 100 73 100 73 66 74 106", "ModeB a FNC4 é (5) b" },
/* 17*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 4, 70, "(20) 15 65 100 73 100 73 100 73 100 73 100 73 66 67 68 69 100 73 14 69", "ModeB a FNC4 é (5) b c d e FNC4 é" },
/* 5*/ { GS1_MODE | GS1PARENS_MODE, "(90)12", -1, 0, 2, 70, "(10) 4 90 12 103 103 103 103 103 79 62", "ModeCFNC1 90 12 Pad (5)" },
/* 6*/ { UNICODE_MODE, "a0123456789", -1, 0, 2, 70, "(10) 5 65 1 23 45 67 89 103 27 86", "ModeC1SB a 01 23 45 67 89 Pad" },
/* 7*/ { UNICODE_MODE, "ab0123456789", -1, 0, 2, 70, "(10) 6 65 66 1 23 45 67 89 19 42", "ModeC2SB a b 01 23 45 67 89" },
/* 8*/ { UNICODE_MODE, "1234\037a", -1, 0, 2, 70, "(10) 2 12 34 101 95 98 65 103 67 53", "ModeC 12 34 CodeA US 1SB a Pad" },
/* 9*/ { UNICODE_MODE, "\000\037ß", 4, 0, 2, 70, "(10) 0 64 95 101 63 103 103 103 75 11", "ModeA NUL US FNC4 ß Pad (3)" },
/* 10*/ { UNICODE_MODE, "\000\037é", 4, 0, 2, 70, "(10) 0 64 95 101 98 73 103 103 75 6", "ModeA NUL US FNC4 1SB é Pad (2)" },
/* 11*/ { UNICODE_MODE, "\000\037éa", 5, 0, 2, 70, "(10) 0 64 95 100 100 73 65 103 99 69", "ModeA NUL US CodeB FNC4 é a Pad" },
/* 12*/ { UNICODE_MODE, "abß", -1, 0, 2, 70, "(10) 1 65 66 100 63 103 103 103 66 56", "ModeB a b FNC4 ß Pad (3)" },
/* 13*/ { DATA_MODE, "\141\142\237", -1, 0, 2, 70, "(10) 1 65 66 100 98 95 103 103 6 71", "ModeB a b FNC4 1SA APC Pad (2)" },
/* 14*/ { DATA_MODE, "\141\142\237\037", -1, 0, 2, 70, "(10) 1 65 66 101 101 95 95 103 72 93", "ModeB a b CodeA FNC4 APC US Pad" },
/* 15*/ { UNICODE_MODE, "ééé", -1, 0, 2, 70, "(10) 1 100 73 100 73 100 73 103 105 106", "ModeB FNC4 é FNC4 é FNC4 é Pad" },
/* 16*/ { UNICODE_MODE, "aééééb", -1, 0, 3, 70, "(15) 8 65 100 73 100 73 100 73 100 73 66 103 103 39 83", "ModeB a FNC4 é (4) b Pad (2)" },
/* 17*/ { UNICODE_MODE, "aéééééb", -1, 0, 3, 70, "(15) 8 65 100 73 100 73 100 73 100 73 100 73 66 74 106", "ModeB a FNC4 é (5) b" },
/* 18*/ { UNICODE_MODE, "aééééébcdeé", -1, 0, 4, 70, "(20) 15 65 100 73 100 73 100 73 100 73 100 73 66 67 68 69 100 73 14 69", "ModeB a FNC4 é (5) b c d e FNC4 é" },
};
int data_size = ARRAY_SIZE(data);

View File

@ -112,6 +112,7 @@ static void test_input(int index, int generate, int debug) {
/* 11*/ { UNICODE_MODE, "\000A\000a\000", 5, 0, 2, 70, "(16) 38 10 43 38 44 10 43 30 38 48 25 23 38 32 4 12", "NUL A S1 NUL S2 a S1 (C18 30) NUL (Start 4, Alphanumeric S1)" },
/* 12*/ { UNICODE_MODE, "1234\037aA12345A", -1, 0, 3, 70, "(24) 1 2 3 4 43 5 44 4 10 10 48 5 17 9 48 0 10 48 19 2 13 32 7 33", "1 2 3 4 S1 US S2 (C18 4) a A NS 12345 NS (C28 0) A (Start 0, Alpha)" },
/* 13*/ { GS1_MODE, "[90]12345[91]AB12345", -1, 0, 4, 70, "(32) 45 48 47 15 4 7 9 28 48 45 9 1 10 11 48 25 5 17 9 48 48 48 48 27 48 48 37 39 26 8 14", "FNC1 NS 9012345 (C18 28) NS FNC1 9 1 A B NS (C28 25) 12345 Pad (4) (C38 27) (Start 0, Alpha)" },
/* 14*/ { GS1_MODE | GS1PARENS_MODE, "(90)12345(91)AB12345", -1, 0, 4, 70, "(32) 45 48 47 15 4 7 9 28 48 45 9 1 10 11 48 25 5 17 9 48 48 48 48 27 48 48 37 39 26 8 14", "FNC1 NS 9012345 (C18 28) NS FNC1 9 1 A B NS (C28 25) 12345 Pad (4) (C38 27) (Start 0, Alpha)" },
};
int data_size = ARRAY_SIZE(data);

View File

@ -2772,6 +2772,75 @@ static void test_addongap(int index, int generate, int debug) {
testFinish();
}
static void test_gs1parens(int index, int debug) {
testStart("");
int ret;
struct item {
int symbology;
int input_mode;
char *data;
char *composite;
int ret;
int expected_rows;
int expected_width;
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_EANX_CC, -1, "1234567", "[21]A12345678", 0, 8, 72 }, // EAN-8
/* 1*/ { BARCODE_EANX_CC, GS1PARENS_MODE, "1234567", "(21)A12345678", 0, 8, 72 }, // EAN-8
/* 2*/ { BARCODE_EANX_CC, -1, "123456789012", "[21]A12345678", 0, 7, 99 }, // EAN-13
/* 3*/ { BARCODE_EANX_CC, GS1PARENS_MODE, "123456789012", "(21)A12345678", 0, 7, 99 }, // EAN-13
/* 4*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[21]A12345678", 0, 5, 145 },
/* 5*/ { BARCODE_GS1_128_CC, GS1PARENS_MODE, "(01)12345678901231", "(21)A12345678", 0, 5, 145 },
/* 6*/ { BARCODE_DBAR_OMN_CC, -1, "12345678901231", "[21]A12345678", 0, 5, 100 },
/* 7*/ { BARCODE_DBAR_OMN_CC, GS1PARENS_MODE, "12345678901231", "(21)A12345678", 0, 5, 100 },
/* 8*/ { BARCODE_DBAR_LTD_CC, -1, "12345678901231", "[21]A12345678", 0, 6, 79 },
/* 9*/ { BARCODE_DBAR_LTD_CC, GS1PARENS_MODE, "12345678901231", "(21)A12345678", 0, 6, 79 },
/* 10*/ { BARCODE_DBAR_EXP_CC, -1, "[01]12345678901231[3103]001234", "[21]A12345678", 0, 5, 200 },
/* 11*/ { BARCODE_DBAR_EXP_CC, GS1PARENS_MODE, "(01)12345678901231(3103)001234", "(21)A12345678", 0, 5, 200 },
/* 12*/ { BARCODE_UPCA_CC, -1, "12345678901", "[21]A12345678", 0, 7, 99 },
/* 13*/ { BARCODE_UPCA_CC, GS1PARENS_MODE, "12345678901", "(21)A12345678", 0, 7, 99 },
/* 14*/ { BARCODE_UPCE_CC, -1, "1234567", "[21]A12345678", 0, 9, 55 },
/* 15*/ { BARCODE_UPCE_CC, GS1PARENS_MODE, "1234567", "(21)A12345678", 0, 9, 55 },
/* 16*/ { BARCODE_DBAR_STK_CC, -1, "12345678901231", "[21]A12345678", 0, 9, 56 },
/* 17*/ { BARCODE_DBAR_STK_CC, GS1PARENS_MODE, "12345678901231", "(21)A12345678", 0, 9, 56 },
/* 18*/ { BARCODE_DBAR_OMNSTK_CC, -1, "12345678901231", "[21]A12345678", 0, 11, 56 },
/* 19*/ { BARCODE_DBAR_OMNSTK_CC, GS1PARENS_MODE, "12345678901231", "(21)A12345678", 0, 11, 56 },
/* 20*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[01]12345678901231[3103]001234", "[21]A12345678", 0, 9, 102 },
/* 21*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(01)12345678901231(3103)001234", "(21)A12345678", 0, 9, 102 },
};
int data_size = ARRAY_SIZE(data);
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
assert_zero(length >= 128, "i:%d length %d >= 128\n", i, length);
strcpy(symbol->primary, data[i].data);
int composite_length = strlen(data[i].composite);
ret = ZBarcode_Encode(symbol, (const unsigned char *) data[i].composite, composite_length);
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);
}
ZBarcode_Delete(symbol);
}
testFinish();
}
// #181 Christian Hartlage OSS-Fuzz
static void test_fuzz(int index, int debug) {
testStart("");
@ -2916,6 +2985,7 @@ int main(int argc, char *argv[]) {
{ "test_encodation_10", test_encodation_10, 1, 1, 1 },
{ "test_encodation_11", test_encodation_11, 1, 1, 1 },
{ "test_addongap", test_addongap, 1, 1, 1 },
{ "test_gs1parens", test_gs1parens, 1, 0, 1 },
{ "test_fuzz", test_fuzz, 1, 0, 1 },
{ "test_perf", test_perf, 1, 0, 1 },
};

View File

@ -421,6 +421,7 @@ static void test_options(int index, int debug) {
int ret;
struct item {
int symbology;
int input_mode;
int option_1;
int option_2;
int option_3;
@ -432,17 +433,19 @@ static void test_options(int index, int debug) {
};
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
struct item data[] = {
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, "1", 0, 10, 10 },
/* 1*/ { BARCODE_DATAMATRIX, 2, -1, -1, "1", ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 2*/ { BARCODE_DATAMATRIX, -1, 1, -1, "1", 0, 10, 10 },
/* 3*/ { BARCODE_DATAMATRIX, -1, 2, -1, "1", 0, 12, 12 },
/* 4*/ { BARCODE_DATAMATRIX, -1, 48, -1, "1", 0, 26, 64 },
/* 5*/ { BARCODE_DATAMATRIX, -1, 49, -1, "1", 0, 10, 10 }, // Ignored
/* 6*/ { BARCODE_DATAMATRIX, -1, -1, -1, "ABCDEFGHIJK", 0, 8, 32 },
/* 7*/ { BARCODE_DATAMATRIX, -1, -1, DM_SQUARE, "ABCDEFGHIJK", 0, 16, 16 },
/* 8*/ { BARCODE_DATAMATRIX, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32 },
/* 9*/ { BARCODE_DATAMATRIX, -1, -1, DM_DMRE, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 20, 44 },
/* 10*/ { BARCODE_DATAMATRIX, -1, -1, 9999, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32 }, // Ignored
/* 0*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, "1", 0, 10, 10 },
/* 1*/ { BARCODE_DATAMATRIX, -1, 2, -1, -1, "1", ZINT_ERROR_INVALID_OPTION, -1, -1 },
/* 2*/ { BARCODE_DATAMATRIX, -1, -1, 1, -1, "1", 0, 10, 10 },
/* 3*/ { BARCODE_DATAMATRIX, -1, -1, 2, -1, "1", 0, 12, 12 },
/* 4*/ { BARCODE_DATAMATRIX, -1, -1, 48, -1, "1", 0, 26, 64 },
/* 5*/ { BARCODE_DATAMATRIX, -1, -1, 49, -1, "1", 0, 10, 10 }, // Ignored
/* 6*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, "ABCDEFGHIJK", 0, 8, 32 },
/* 7*/ { BARCODE_DATAMATRIX, -1, -1, -1, DM_SQUARE, "ABCDEFGHIJK", 0, 16, 16 },
/* 8*/ { BARCODE_DATAMATRIX, -1, -1, -1, -1, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32 },
/* 9*/ { BARCODE_DATAMATRIX, -1, -1, -1, DM_DMRE, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 20, 44 },
/* 10*/ { BARCODE_DATAMATRIX, -1, -1, -1, 9999, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU", 0, 32, 32 }, // Ignored
/* 11*/ { BARCODE_DATAMATRIX, GS1_MODE, -1, -1, -1, "[90]12", 0, 10, 10 },
/* 12*/ { BARCODE_DATAMATRIX, GS1_MODE | GS1PARENS_MODE, -1, -1, -1, "(90)12", 0, 10, 10 },
};
int data_size = ARRAY_SIZE(data);
@ -453,7 +456,7 @@ static void test_options(int index, int debug) {
struct zint_symbol *symbol = ZBarcode_Create();
assert_nonnull(symbol, "Symbol not created\n");
int length = testUtilSetSymbol(symbol, data[i].symbology, -1 /*input_mode*/, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, data[i].symbology, data[i].input_mode, -1 /*eci*/, data[i].option_1, data[i].option_2, data[i].option_3, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret, symbol->errtxt);

View File

@ -71,17 +71,18 @@ static void test_input(int index, int generate, int debug) {
/* 22*/ { UNICODE_MODE, -1, "1712345610", -1, 0, "6B 64 0C 22 38", "FNC1 (0x6B) 17..10 12 34 56" },
/* 23*/ { GS1_MODE, -1, "[17]123456[10]123", -1, ZINT_WARN_NONCOMPLIANT, "Warning 64 0C 22 38 0C 66 13", "17..10 12 34 56 12 ShiftB (0x66) 3" },
/* 24*/ { GS1_MODE, -1, "[90]ABC[90]abc[90]123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
/* 25*/ { UNICODE_MODE, -1, "99aA[{00\000", 9, 0, "6B 63 6A 41 21 3B 5B 10 10 65 40", "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" },
/* 26*/ { UNICODE_MODE, -1, "\015\012", -1, 0, "66 60", "ShiftB (0x66) CR/LF" },
/* 27*/ { UNICODE_MODE, -1, "A\015\012", -1, 0, "67 21 60", "2xShiftB (0x67) A CR/LF" },
/* 28*/ { UNICODE_MODE, -1, "\015\015\012", -1, 0, "65 4D 4D 4A", "LatchA (0x65) CR CR LF" },
/* 29*/ { UNICODE_MODE, -1, "ABCDE12345678", -1, 0, "6A 21 22 23 24 25 69 0C 22 38 4E", "LatchB (0x6A) A B C D 4xShiftC 12 34 56 78" },
/* 30*/ { UNICODE_MODE, -1, "\000ABCD1234567890", 15, 0, "65 40 21 22 23 24 6A 0C 22 38 4E 5A", "LatchA (0x65) NULL A B C D LatchC (0x6A) 12 34 56 78 90" },
/* 31*/ { DATA_MODE, -1, "\141\142\143\144\145\200\201\202\203\204\377", -1, 0, "6A 41 42 43 44 45 70 31 5A 35 21 5A 5F 02 31", "LatchB (0x6A) a b c d e BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x84 0xFF" },
/* 32*/ { DATA_MODE, -1, "\200\061\062\240\063\064\201\202\065\066", -1, 0, "6E 40 0C 6F 00 22 70 03 10 42 6E 15 16", "UpperShiftA (0x6E) NUL 12 UpperShiftB (0x6F) SP 34 BinaryLatch (0x70) 0x81 0x82 TermB (0x6E) 5 6" },
/* 33*/ { DATA_MODE, -1, "\200\201\202\203\061\062\063\064", -1, 0, "70 13 56 0A 59 2C 67 0C 22", "BinaryLatch (0x70) 0x80 0x81 0x82 0x83 Intr2xShiftC (0x67) 12 3" },
/* 34*/ { DATA_MODE, -1, "\001\200\201\202\203\204\200\201\202\203\204", -1, 0, "65 41 70 31 5A 35 21 5A 5F 31 5A 35 21 5A 5F", "LatchA (0x65) SOH BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x80 0x81 0x82 0x83" },
/* 35*/ { UNICODE_MODE, -1, "\001abc\011\015\012\036", -1, 0, "65 41 65 41 42 43 61 60 64", "LatchA (0x65) SOH 6xShiftB (0x65) a b c HT CR/LF RS" },
/* 25*/ { GS1_MODE | GS1PARENS_MODE, -1, "(90)ABC(90)abc(90)123", -1, 0, "5A 6A 21 22 23 6B 19 10 41 42 43 6B 19 67 01 17", "90 LatchB (0x6A) A B C FNC1 (0x6B) 9 0 a b c FNC1 (0x6B) 9 2xShitfC (0x67) 01 23" },
/* 26*/ { UNICODE_MODE, -1, "99aA[{00\000", 9, 0, "6B 63 6A 41 21 3B 5B 10 10 65 40", "FNC1 (0x6B) 99 LatchB (0x6A) a A [ { 0 0 ShiftA (0x65) NUL" },
/* 27*/ { UNICODE_MODE, -1, "\015\012", -1, 0, "66 60", "ShiftB (0x66) CR/LF" },
/* 28*/ { UNICODE_MODE, -1, "A\015\012", -1, 0, "67 21 60", "2xShiftB (0x67) A CR/LF" },
/* 29*/ { UNICODE_MODE, -1, "\015\015\012", -1, 0, "65 4D 4D 4A", "LatchA (0x65) CR CR LF" },
/* 30*/ { UNICODE_MODE, -1, "ABCDE12345678", -1, 0, "6A 21 22 23 24 25 69 0C 22 38 4E", "LatchB (0x6A) A B C D 4xShiftC 12 34 56 78" },
/* 31*/ { UNICODE_MODE, -1, "\000ABCD1234567890", 15, 0, "65 40 21 22 23 24 6A 0C 22 38 4E 5A", "LatchA (0x65) NULL A B C D LatchC (0x6A) 12 34 56 78 90" },
/* 32*/ { DATA_MODE, -1, "\141\142\143\144\145\200\201\202\203\204\377", -1, 0, "6A 41 42 43 44 45 70 31 5A 35 21 5A 5F 02 31", "LatchB (0x6A) a b c d e BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x84 0xFF" },
/* 33*/ { DATA_MODE, -1, "\200\061\062\240\063\064\201\202\065\066", -1, 0, "6E 40 0C 6F 00 22 70 03 10 42 6E 15 16", "UpperShiftA (0x6E) NUL 12 UpperShiftB (0x6F) SP 34 BinaryLatch (0x70) 0x81 0x82 TermB (0x6E) 5 6" },
/* 34*/ { DATA_MODE, -1, "\200\201\202\203\061\062\063\064", -1, 0, "70 13 56 0A 59 2C 67 0C 22", "BinaryLatch (0x70) 0x80 0x81 0x82 0x83 Intr2xShiftC (0x67) 12 3" },
/* 35*/ { DATA_MODE, -1, "\001\200\201\202\203\204\200\201\202\203\204", -1, 0, "65 41 70 31 5A 35 21 5A 5F 31 5A 35 21 5A 5F", "LatchA (0x65) SOH BinaryLatch (0x70) 0x80 0x81 0x82 0x83 0x80 0x81 0x82 0x83" },
/* 36*/ { UNICODE_MODE, -1, "\001abc\011\015\012\036", -1, 0, "65 41 65 41 42 43 61 60 64", "LatchA (0x65) SOH 6xShiftB (0x65) a b c HT CR/LF RS" },
};
int data_size = ARRAY_SIZE(data);

View File

@ -62,102 +62,131 @@ static void test_gs1_reduce(int index, int generate, int debug) {
/* 3*/ { BARCODE_GS1_128, UNICODE_MODE, "[01]12345678901231", "", 0, "Input mode ignored",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 4*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
/* 4*/ { BARCODE_GS1_128, GS1PARENS_MODE, "(01)12345678901231", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 5*/ { BARCODE_GS1_128_CC, -1, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 5*/ { BARCODE_GS1_128_CC, GS1_MODE, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
/* 6*/ { BARCODE_GS1_128_CC, GS1_MODE, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 6*/ { BARCODE_GS1_128_CC, UNICODE_MODE, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
/* 7*/ { BARCODE_GS1_128_CC, UNICODE_MODE, "[01]12345678901231", "[21]1234", 0, "Input mode ignored",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 7*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against tec-it",
/* 8*/ { BARCODE_GS1_128_CC, GS1PARENS_MODE, "(01)12345678901231", "(21)1234", 0, "Input mode ignored (parentheses instead of square brackets)",
"0000000000000000000001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010000000000000000000000000"
"0000000000000000000001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010000000000000000000000000"
"0000000000000000000001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010000000000000000000000000"
"0010110001100001010001001100100110100110001101110100111000111010010011110101100100001001010011000110010011100100010100001000101001110011100010100"
"1101001110011110101110110011011001011001110010001011000111000101101100001010011011110110101100111001101100011011101011110111010110001100011101011"
},
/* 9*/ { BARCODE_EAN14, -1, "1234567890123", "", 0, "Input mode ignored; verified manually against tec-it",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 8*/ { BARCODE_EAN14, GS1_MODE, "1234567890123", "", 0, "Input mode ignored",
/*10*/ { BARCODE_EAN14, GS1_MODE, "1234567890123", "", 0, "Input mode ignored",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/* 9*/ { BARCODE_EAN14, UNICODE_MODE, "1234567890123", "", 0, "Input mode ignored",
/*11*/ { BARCODE_EAN14, UNICODE_MODE, "1234567890123", "", 0, "Input mode ignored",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/*10*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "Input mode ignored; verified manually against tec-it",
/*12*/ { BARCODE_EAN14, GS1PARENS_MODE, "1234567890123", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"11010011100111101011101100110110010110011100100010110001110001011011000010100110111101101011001110011011000110100001100101100011101011"
},
/*13*/ { BARCODE_NVE18, -1, "12345678901234567", "", 0, "Input mode ignored; verified manually against tec-it",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*11*/ { BARCODE_NVE18, GS1_MODE, "12345678901234567", "", 0, "Input mode ignored",
/*14*/ { BARCODE_NVE18, GS1_MODE, "12345678901234567", "", 0, "Input mode ignored",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*12*/ { BARCODE_NVE18, UNICODE_MODE, "12345678901234567", "", 0, "Input mode ignored",
/*15*/ { BARCODE_NVE18, UNICODE_MODE, "12345678901234567", "", 0, "Input mode ignored",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*13*/ { BARCODE_DBAR_EXP, -1, "2012", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*14*/ { BARCODE_DBAR_EXP, -1, "[20]12", "", 0, "Input mode ignored",
/*16*/ { BARCODE_NVE18, GS1PARENS_MODE, "12345678901234567", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"110100111001111010111011011001100101100111001000101100011100010110110000101001101111011010110011100100010110001110001011011000010010101101110001100011101011"
},
/*17*/ { BARCODE_DBAR_EXP, -1, "2012", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*18*/ { BARCODE_DBAR_EXP, -1, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*15*/ { BARCODE_DBAR_EXP, GS1_MODE, "[20]12", "", 0, "Input mode ignored",
/*19*/ { BARCODE_DBAR_EXP, GS1PARENS_MODE, "(20)12", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*16*/ { BARCODE_DBAR_EXP, UNICODE_MODE, "[20]12", "", 0, "Input mode ignored",
/*20*/ { BARCODE_DBAR_EXP, GS1_MODE, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*17*/ { BARCODE_DBAR_EXP_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored; verified manually against tec-it",
/*21*/ { BARCODE_DBAR_EXP, GS1_MODE | GS1PARENS_MODE, "(20)12", "", 0, "Input mode ignored (parentheses instead of square brackets)",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*22*/ { BARCODE_DBAR_EXP, UNICODE_MODE, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*23*/ { BARCODE_DBAR_EXP_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored; verified manually against tec-it",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*18*/ { BARCODE_DBAR_EXP_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
/*24*/ { BARCODE_DBAR_EXP_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*19*/ { BARCODE_DBAR_EXP_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
/*25*/ { BARCODE_DBAR_EXP_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*20*/ { BARCODE_DBAR_EXPSTK, -1, "12", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*21*/ { BARCODE_DBAR_EXPSTK, -1, "[20]12", "", 0, "Input mode ignored",
/*26*/ { BARCODE_DBAR_EXPSTK, -1, "12", "", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*27*/ { BARCODE_DBAR_EXPSTK, -1, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*22*/ { BARCODE_DBAR_EXPSTK, GS1_MODE, "[20]12", "", 0, "Input mode ignored",
/*28*/ { BARCODE_DBAR_EXPSTK, GS1_MODE, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*23*/ { BARCODE_DBAR_EXPSTK, UNICODE_MODE, "[20]12", "", 0, "Input mode ignored",
/*29*/ { BARCODE_DBAR_EXPSTK, UNICODE_MODE, "[20]12", "", 0, "Input mode ignored",
"010010000010000101101111111100001010000010000110010101111100101110001011110000000010101111100001011101"
},
/*24*/ { BARCODE_DBAR_EXPSTK_CC, -1, "12", "[21]1234", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*25*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored; verified manually against tec-it (same as BARCODE_DBAR_EXP_CC above)",
/*30*/ { BARCODE_DBAR_EXPSTK_CC, -1, "12", "[21]1234", ZINT_ERROR_INVALID_DATA, "GS1 data required", "" },
/*31*/ { BARCODE_DBAR_EXPSTK_CC, -1, "[20]12", "[21]1234", 0, "Input mode ignored; verified manually against tec-it (same as BARCODE_DBAR_EXP_CC above)",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*26*/ { BARCODE_DBAR_EXPSTK_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
/*32*/ { BARCODE_DBAR_EXPSTK_CC, GS1PARENS_MODE, "(20)12", "(21)1234", 0, "Input mode ignored (parentheses instead of square brackets)",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*27*/ { BARCODE_DBAR_EXPSTK_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
/*33*/ { BARCODE_DBAR_EXPSTK_CC, GS1_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
"000001111111010110010000000010100100111001100001011010000011010001110100001010101001010000011110100000"
"010010000000101001101111111100001011000110011110100101111100101110001011110000000010101111100001011101"
},
/*34*/ { BARCODE_DBAR_EXPSTK_CC, UNICODE_MODE, "[20]12", "[21]1234", 0, "Input mode ignored",
"001101101110110100001000001101001100111011000010011101001100001010001100010010011011000000110110001010"
"001101101100111110100010011001101011100100000010011001001001111001011110011101011001000000110010001010"
"001101101000101111100110000101001111010000001010011001101011101110011110010011110110000110111010001010"
@ -1731,40 +1760,47 @@ static void test_input_mode(int index, int debug) {
struct item data[] = {
/* 0*/ { BARCODE_AZTEC, "[01]12345678901231", "", GS1_MODE, -1 , 0, 0 },
/* 1*/ { BARCODE_AZTEC, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 2*/ { BARCODE_AZTEC, "[01]12345678901231", "", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 3*/ { BARCODE_AZTEC, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 4*/ { BARCODE_AZTEC, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 5*/ { BARCODE_AZTEC, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 6*/ { BARCODE_CODABLOCKF, "[01]12345678901231", "", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 7*/ { BARCODE_CODABLOCKF, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 8*/ { BARCODE_CODABLOCKF, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 9*/ { BARCODE_CODABLOCKF, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 10*/ { BARCODE_CODEONE, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 11*/ { BARCODE_CODEONE, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 12*/ { BARCODE_CODEONE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 13*/ { BARCODE_CODEONE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 14*/ { BARCODE_CODE16K, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 15*/ { BARCODE_CODE16K, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 16*/ { BARCODE_CODE16K, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 17*/ { BARCODE_CODE16K, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 18*/ { BARCODE_CODE49, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 19*/ { BARCODE_CODE49, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 20*/ { BARCODE_CODE49, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 21*/ { BARCODE_CODE49, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 22*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 23*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 24*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 25*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 26*/ { BARCODE_DATAMATRIX, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 27*/ { BARCODE_DATAMATRIX, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 28*/ { BARCODE_DOTCODE, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 29*/ { BARCODE_DOTCODE, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 30*/ { BARCODE_DOTCODE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 31*/ { BARCODE_DOTCODE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 32*/ { BARCODE_QRCODE, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 33*/ { BARCODE_QRCODE, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 34*/ { BARCODE_QRCODE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 35*/ { BARCODE_QRCODE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 2*/ { BARCODE_AZTEC, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 3*/ { BARCODE_AZTEC, "[01]12345678901231", "", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 4*/ { BARCODE_AZTEC, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 5*/ { BARCODE_AZTEC, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 6*/ { BARCODE_AZTEC, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 7*/ { BARCODE_CODABLOCKF, "[01]12345678901231", "", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 8*/ { BARCODE_CODABLOCKF, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 9*/ { BARCODE_CODABLOCKF, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 10*/ { BARCODE_CODABLOCKF, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_OPTION, 0 },
/* 11*/ { BARCODE_CODEONE, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 12*/ { BARCODE_CODEONE, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 13*/ { BARCODE_CODEONE, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 14*/ { BARCODE_CODEONE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 15*/ { BARCODE_CODEONE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 16*/ { BARCODE_CODE16K, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 17*/ { BARCODE_CODE16K, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 18*/ { BARCODE_CODE16K, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 19*/ { BARCODE_CODE16K, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 20*/ { BARCODE_CODE16K, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 21*/ { BARCODE_CODE49, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 22*/ { BARCODE_CODE49, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 23*/ { BARCODE_CODE49, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 24*/ { BARCODE_CODE49, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 25*/ { BARCODE_CODE49, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 26*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 27*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 28*/ { BARCODE_DATAMATRIX, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 29*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 30*/ { BARCODE_DATAMATRIX, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, READER_INIT, ZINT_ERROR_INVALID_OPTION, 0 },
/* 31*/ { BARCODE_DATAMATRIX, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 32*/ { BARCODE_DATAMATRIX, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 33*/ { BARCODE_DOTCODE, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 34*/ { BARCODE_DOTCODE, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 35*/ { BARCODE_DOTCODE, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 36*/ { BARCODE_DOTCODE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 37*/ { BARCODE_DOTCODE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 38*/ { BARCODE_QRCODE, "[01]12345678901231", "", GS1_MODE, -1, 0, 0 },
/* 39*/ { BARCODE_QRCODE, "[01]12345678901231", "", GS1_MODE | ESCAPE_MODE, -1, 0, 1 },
/* 40*/ { BARCODE_QRCODE, "(01)12345678901231", "", GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, -1, 0, 1 },
/* 41*/ { BARCODE_QRCODE, "1234", "", GS1_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
/* 42*/ { BARCODE_QRCODE, "1234", "", GS1_MODE | ESCAPE_MODE, -1, ZINT_ERROR_INVALID_DATA, 0 },
};
int data_size = ARRAY_SIZE(data);

View File

@ -233,7 +233,7 @@ static void test_encode(int index, int generate, int debug) {
char *expected;
};
struct item data[] = {
/* 0*/ { -1, -1, -1, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure 2, same",
/* 0*/ { -1, -1, -1, "THIS IS A 93 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, UNAPPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "ISO/IEC 16023:2000 Figure 2 (and L1), same",
"011111010000001000001000100111"
"000100000001000000001010000000"
"001011001100100110110010010010"

View File

@ -316,22 +316,25 @@ static void test_qr_gs1(int index, int generate, int debug) {
int ret;
struct item {
int input_mode;
char *data;
int ret;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { "[01]12345678901231", 0, "51 04 00 B3 AA 37 DE 87 B1", "N16" },
/* 1*/ { "[01]04912345123459[15]970331[30]128[10]ABC123", 0, "51 07 40 A7 AC EA 80 15 9E 4F CA 52 D2 D3 84 09 D5 E0 28 FD 82 F0 C0 EC 11 EC 11 EC", "N29 A9" },
/* 2*/ { "[91]12%[20]12", 0, "52 05 99 60 5F B5 35 80 01 08 00 EC 11", "A10(11)" },
/* 3*/ { "[91]123%[20]12", 0, "52 06 19 60 5E 2B 76 A0 5A 05 E0 EC 11", "A11(12)" },
/* 4*/ { "[91]1234%[20]12", 0, "52 06 99 60 5E 22 F6 A6 B0 00 21 00 EC", "A12(13)" },
/* 5*/ { "[91]12345%[20]12", 0, "51 01 F8 F3 A9 48 0F B5 35 80 01 08 00", "N7 A6(7) (same bit count as A13(14))" },
/* 6*/ { "[91]%%[20]12", 0, "52 05 99 6D A9 B5 35 80 01 08 00 EC 11", "A9(11)" },
/* 7*/ { "[91]%%%[20]12", 0, "52 06 99 6D A9 B5 36 A6 B0 00 21 00 EC", "A10(13)" },
/* 8*/ { "[91]A%%%%1234567890123AA%", 0, "52 05 99 63 D1 B5 36 A6 D4 98 40 D1 ED C8 C5 40 C3 20 21 CC DA 80", "A7(11) N13 A3(4)" },
/* 9*/ { "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(34) 52 17 19 6D A8 17 76 A6 D4 22 A5 C7 6A 6D 4D A8 22 C7 39 61 DA 9B 53 6A 6B 01 17 B5", "A31(46)" },
/* 0*/ { GS1_MODE, "[01]12345678901231", 0, "51 04 00 B3 AA 37 DE 87 B1", "N16" },
/* 1*/ { GS1_MODE | GS1PARENS_MODE, "(01)12345678901231", 0, "51 04 00 B3 AA 37 DE 87 B1", "N16" },
/* 2*/ { GS1_MODE, "[01]04912345123459[15]970331[30]128[10]ABC123", 0, "51 07 40 A7 AC EA 80 15 9E 4F CA 52 D2 D3 84 09 D5 E0 28 FD 82 F0 C0 EC 11 EC 11 EC", "N29 A9" },
/* 3*/ { GS1_MODE | GS1PARENS_MODE, "(01)04912345123459(15)970331(30)128(10)ABC123", 0, "51 07 40 A7 AC EA 80 15 9E 4F CA 52 D2 D3 84 09 D5 E0 28 FD 82 F0 C0 EC 11 EC 11 EC", "N29 A9" },
/* 4*/ { GS1_MODE, "[91]12%[20]12", 0, "52 05 99 60 5F B5 35 80 01 08 00 EC 11", "A10(11)" },
/* 5*/ { GS1_MODE, "[91]123%[20]12", 0, "52 06 19 60 5E 2B 76 A0 5A 05 E0 EC 11", "A11(12)" },
/* 6*/ { GS1_MODE, "[91]1234%[20]12", 0, "52 06 99 60 5E 22 F6 A6 B0 00 21 00 EC", "A12(13)" },
/* 7*/ { GS1_MODE, "[91]12345%[20]12", 0, "51 01 F8 F3 A9 48 0F B5 35 80 01 08 00", "N7 A6(7) (same bit count as A13(14))" },
/* 8*/ { GS1_MODE, "[91]%%[20]12", 0, "52 05 99 6D A9 B5 35 80 01 08 00 EC 11", "A9(11)" },
/* 9*/ { GS1_MODE, "[91]%%%[20]12", 0, "52 06 99 6D A9 B5 36 A6 B0 00 21 00 EC", "A10(13)" },
/* 10*/ { GS1_MODE, "[91]A%%%%1234567890123AA%", 0, "52 05 99 63 D1 B5 36 A6 D4 98 40 D1 ED C8 C5 40 C3 20 21 CC DA 80", "A7(11) N13 A3(4)" },
/* 11*/ { GS1_MODE, "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(34) 52 17 19 6D A8 17 76 A6 D4 22 A5 C7 6A 6D 4D A8 22 C7 39 61 DA 9B 53 6A 6B 01 17 B5", "A31(46)" },
};
int data_size = ARRAY_SIZE(data);
@ -347,14 +350,14 @@ static void test_qr_gs1(int index, int generate, int debug) {
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_QRCODE, GS1_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, BARCODE_QRCODE, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
} else {
if (ret < ZINT_ERROR) {
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);
@ -2494,23 +2497,26 @@ static void test_rmqr_gs1(int index, int generate, int debug) {
int ret;
struct item {
int input_mode;
char *data;
int ret;
char *expected;
char *comment;
};
struct item data[] = {
/* 0*/ { "[01]12345678901231", 0, "A6 00 59 D5 1B EF 43 D8 80 EC 11 EC", "N16" },
/* 1*/ { "[01]04912345123459[15]970331[30]128[10]ABC123", 0, "A5 D0 29 EB 3A A0 05 67 93 F2 94 B4 B4 E2 4E AF 01 47 EC 17 86", "N29 A9" },
/* 2*/ { "[91]12%[20]12", 0, "A4 9C 79 32 25 1D 24 32 48 00 EC 11", "N4 B2 N4" },
/* 3*/ { "[91]123%[20]12", 0, "A4 BC 79 74 3D A9 31 21 92 40 EC 11", "N5 A2 N4" },
/* 4*/ { "[91]1234%[20]12", 0, "A4 DC 79 D4 C8 94 74 90 C9 20 EC 11", "N6 B2 N4" },
/* 5*/ { "[91]12345%[20]12", 0, "A4 FC 79 D4 A8 7B 52 62 43 24 80 EC", "N7 A2(3) N4" },
/* 6*/ { "[91]1A%[20]12", 0, "A8 E6 58 1B ED 49 89 0C 92 00 EC 11", "A6(7) N4" },
/* 7*/ { "[91]%%[20]12", 0, "A4 56 D9 92 92 8E 92 19 24 00 EC 11", "N2 B3 N4" },
/* 8*/ { "[91]%%%[20]12", 0, "A4 56 DA 12 92 92 8E 92 19 24 00 EC", "N2 B4 N4" },
/* 9*/ { "[91]A%%%%12345678A%A", 0, "A8 A6 58 F4 4C C6 4A 4A 4A 48 1E DC 89 C8 87 A3 5C 00 EC", "A4(5) B3 N8 A3(4)" },
/* 10*/ { "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(33) AA 63 2D B5 02 EE D4 DA 84 54 B8 ED 4D A9 B5 04 58 E7 2C 3B 53 6A 6D 4D 60 22 F6 A3", "A27(38) B4" },
/* 0*/ { GS1_MODE, "[01]12345678901231", 0, "A6 00 59 D5 1B EF 43 D8 80 EC 11 EC", "N16" },
/* 1*/ { GS1_MODE | GS1PARENS_MODE, "(01)12345678901231", 0, "A6 00 59 D5 1B EF 43 D8 80 EC 11 EC", "N16" },
/* 2*/ { GS1_MODE, "[01]04912345123459[15]970331[30]128[10]ABC123", 0, "A5 D0 29 EB 3A A0 05 67 93 F2 94 B4 B4 E2 4E AF 01 47 EC 17 86", "N29 A9" },
/* 3*/ { GS1_MODE | GS1PARENS_MODE, "(01)04912345123459(15)970331(30)128(10)ABC123", 0, "A5 D0 29 EB 3A A0 05 67 93 F2 94 B4 B4 E2 4E AF 01 47 EC 17 86", "N29 A9" },
/* 4*/ { GS1_MODE, "[91]12%[20]12", 0, "A4 9C 79 32 25 1D 24 32 48 00 EC 11", "N4 B2 N4" },
/* 5*/ { GS1_MODE, "[91]123%[20]12", 0, "A4 BC 79 74 3D A9 31 21 92 40 EC 11", "N5 A2 N4" },
/* 6*/ { GS1_MODE, "[91]1234%[20]12", 0, "A4 DC 79 D4 C8 94 74 90 C9 20 EC 11", "N6 B2 N4" },
/* 7*/ { GS1_MODE, "[91]12345%[20]12", 0, "A4 FC 79 D4 A8 7B 52 62 43 24 80 EC", "N7 A2(3) N4" },
/* 8*/ { GS1_MODE, "[91]1A%[20]12", 0, "A8 E6 58 1B ED 49 89 0C 92 00 EC 11", "A6(7) N4" },
/* 9*/ { GS1_MODE, "[91]%%[20]12", 0, "A4 56 D9 92 92 8E 92 19 24 00 EC 11", "N2 B3 N4" },
/* 10*/ { GS1_MODE, "[91]%%%[20]12", 0, "A4 56 DA 12 92 92 8E 92 19 24 00 EC", "N2 B4 N4" },
/* 11*/ { GS1_MODE, "[91]A%%%%12345678A%A", 0, "A8 A6 58 F4 4C C6 4A 4A 4A 48 1E DC 89 C8 87 A3 5C 00 EC", "A4(5) B3 N8 A3(4)" },
/* 12*/ { GS1_MODE, "[91]%23%%6789%%%34567%%%%234%%%%%", 0, "(33) AA 63 2D B5 02 EE D4 DA 84 54 B8 ED 4D A9 B5 04 58 E7 2C 3B 53 6A 6D 4D 60 22 F6 A3", "A27(38) B4" },
};
int data_size = ARRAY_SIZE(data);
@ -2525,14 +2531,14 @@ static void test_rmqr_gs1(int index, int generate, int debug) {
debug |= ZINT_DEBUG_TEST; // Needed to get codeword dump in errtxt
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, GS1_MODE, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
int length = testUtilSetSymbol(symbol, BARCODE_RMQR, data[i].input_mode, -1 /*eci*/, -1 /*option_1*/, -1, -1, -1 /*output_options*/, data[i].data, -1, debug);
ret = ZBarcode_Encode(symbol, (unsigned char *) data[i].data, length);
assert_equal(ret, data[i].ret, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret);
if (generate) {
printf(" /*%3d*/ { \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
printf(" /*%3d*/ { %s, \"%s\", %s, \"%s\", \"%s\" },\n",
i, testUtilInputModeName(data[i].input_mode), testUtilEscape(data[i].data, length, escaped, sizeof(escaped)), testUtilErrorName(data[i].ret), symbol->errtxt, data[i].comment);
} else {
if (ret < ZINT_ERROR) {
assert_zero(strcmp(symbol->errtxt, data[i].expected), "i:%d strcmp(%s, %s) != 0\n", i, symbol->errtxt, data[i].expected);

View File

@ -140,15 +140,16 @@ static void test_input(int index, int generate, int debug) {
/* 33*/ { GS1_MODE, 0, -1, -1, "[01]03453120000011[17]121125[10]ABCD1234", 0, "(20) 273 129 131 173 159 148 128 128 139 145 140 139 153 138 65 66 67 68 140 162", "Mode: a (34); Figure G.6 uses C43 for 6 of last 7 chars (same codeword count)" },
/* 34*/ { GS1_MODE, 0, -1, -1, "[17]120508[10]ABCD1234[410]9501101020917", 0, "(21) 273 145 140 133 136 138 65 66 67 68 140 162 272 169 137 178 139 129 130 137 145", "Mode: a (35)" },
/* 35*/ { GS1_MODE, 0, -1, -1, "[17]120508[10]ABCDEFGHI[410]9501101020917", 0, "(24) 273 145 140 133 136 138 65 66 67 68 69 70 71 72 73 272 169 137 178 139 129 130 137 145", "Mode: a (36)" },
/* 36*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://", 0, "(4) 272 278 269 165", "Mode: c (6)" },
/* 37*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, ".cgi", 0, "(4) 272 278 274 131", "Mode: c (4)" },
/* 38*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://a.cgi", 0, "(6) 272 280 269 123 274 131", "Mode: c (11)" },
/* 39*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "e: file:f.shtml !", 0, "(12) 272 280 30 94 236 235 72 233 39 52 267 250", "Mode: c (17)" },
/* 40*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aaatel:", 0, "(6) 272 280 262 76 6 89", "Mode: c (7)" },
/* 41*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aatel:a", 0, "(6) 272 280 262 76 271 161", "Mode: c (7)" },
/* 42*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Atel:aAa", 0, "(8) 272 275 6 89 275 148 0 42", "Mode: c (8)" },
/* 43*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "tel:AAaa", 0, "(8) 272 275 271 161 6 28 262 118", "Mode: c (8)" },
/* 44*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "AAaatel:aA", 0, "(10) 272 276 0 42 0 41 118 46 6 156", "Mode: c (10)" },
/* 36*/ { GS1_MODE | GS1PARENS_MODE, 0, -1, -1, "(17)120508(10)ABCDEFGHI(410)9501101020917", 0, "(24) 273 145 140 133 136 138 65 66 67 68 69 70 71 72 73 272 169 137 178 139 129 130 137 145", "Mode: a (36)" },
/* 37*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://", 0, "(4) 272 278 269 165", "Mode: c (6)" },
/* 38*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, ".cgi", 0, "(4) 272 278 274 131", "Mode: c (4)" },
/* 39*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "ftp://a.cgi", 0, "(6) 272 280 269 123 274 131", "Mode: c (11)" },
/* 40*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "e: file:f.shtml !", 0, "(12) 272 280 30 94 236 235 72 233 39 52 267 250", "Mode: c (17)" },
/* 41*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aaatel:", 0, "(6) 272 280 262 76 6 89", "Mode: c (7)" },
/* 42*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Aatel:a", 0, "(6) 272 280 262 76 271 161", "Mode: c (7)" },
/* 43*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "Atel:aAa", 0, "(8) 272 275 6 89 275 148 0 42", "Mode: c (8)" },
/* 44*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "tel:AAaa", 0, "(8) 272 275 271 161 6 28 262 118", "Mode: c (8)" },
/* 45*/ { UNICODE_MODE, 0, -1, ULTRA_COMPRESSION, "AAaatel:aA", 0, "(10) 272 276 0 42 0 41 118 46 6 156", "Mode: c (10)" },
};
int data_size = ARRAY_SIZE(data);

View File

@ -40,6 +40,7 @@
#include <zlib.h>
#include <setjmp.h>
#endif
#include <assert.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>
@ -452,34 +453,51 @@ const char *testUtilErrorName(int error_number) {
}
const char *testUtilInputModeName(int input_mode) {
static char buf[512];
struct item {
const char *name;
int define;
int val;
};
static const struct item data[] = {
{ "DATA_MODE", DATA_MODE, 0 },
{ "UNICODE_MODE", UNICODE_MODE, 1 },
{ "GS1_MODE", GS1_MODE, 2 },
{ "", -1, 3 },
{ "", -1, 4 },
{ "", -1, 5 },
{ "", -1, 6 },
{ "", -1, 7 },
{ "DATA_MODE | ESCAPE_MODE", DATA_MODE | ESCAPE_MODE, 8 },
{ "UNICODE_MODE | ESCAPE_MODE", UNICODE_MODE | ESCAPE_MODE, 9 },
{ "GS1_MODE | ESCAPE_MODE", GS1_MODE | ESCAPE_MODE, 10 },
{ "ESCAPE_MODE", ESCAPE_MODE, 8 },
{ "GS1PARENS_MODE", GS1PARENS_MODE, 16 },
};
static const int data_size = sizeof(data) / sizeof(struct item);
static const int data_size = ARRAY_SIZE(data);
int set, i;
if (input_mode < 0 || input_mode >= data_size) {
return input_mode == -1 ? "-1" : "";
if (input_mode < 0) {
return "-1";
}
if (data[input_mode].val != input_mode || (data[input_mode].define != -1 && data[input_mode].define != input_mode)) { // Self-check
fprintf(stderr, "testUtilInputModeName: data table out of sync (%d)\n", input_mode);
buf[0] = '\0';
if ((input_mode & 0x7) & UNICODE_MODE) {
strcpy(buf, "UNICODE_MODE");
set = UNICODE_MODE;
} else if ((input_mode & 0x7) & GS1_MODE) {
strcpy(buf, "GS1_MODE");
set = GS1_MODE;
} else {
set = DATA_MODE;
}
for (i = 0; i < data_size; i++) {
if (data[i].define != data[i].val) { // Self-check
fprintf(stderr, "testUtilInputModeName: data table out of sync (%d)\n", i);
abort();
}
if (input_mode & data[i].define) {
if (*buf) {
strcat(buf, " | ");
}
strcat(buf, data[i].name);
set |= data[i].define;
}
}
if (set != input_mode) {
fprintf(stderr, "testUtilInputModeName: unknown input mode %d (%d)\n", input_mode & set, input_mode);
abort();
}
return data[input_mode].name;
return buf;
}
const char *testUtilOption3Name(int option_3) {
@ -720,6 +738,7 @@ int testUtilSymbolCmp(const struct zint_symbol *a, const struct zint_symbol *b)
struct zint_vector *testUtilVectorCpy(const struct zint_vector *in) {
struct zint_vector *out = malloc(sizeof(struct zint_vector));
assert(out != NULL);
out->width = in->width;
out->height = in->height;
out->rectangles = NULL;
@ -742,6 +761,7 @@ struct zint_vector *testUtilVectorCpy(const struct zint_vector *in) {
outrect = &(out->rectangles);
while (rect) {
*outrect = malloc(sizeof(struct zint_vector_rect));
assert(*outrect != NULL);
memcpy(*outrect, rect, sizeof(struct zint_vector_rect));
outrect = &((*outrect)->next);
rect = rect->next;
@ -753,8 +773,10 @@ struct zint_vector *testUtilVectorCpy(const struct zint_vector *in) {
outstring = &(out->strings);
while (string) {
*outstring = malloc(sizeof(struct zint_vector_string));
assert(*outstring != NULL);
memcpy(*outstring, string, sizeof(struct zint_vector_string));
(*outstring)->text = malloc(sizeof(unsigned char) * (ustrlen(string->text) + 1));
assert((*outstring)->text != NULL);
ustrcpy((*outstring)->text, string->text);
outstring = &((*outstring)->next);
string = string->next;
@ -766,6 +788,7 @@ struct zint_vector *testUtilVectorCpy(const struct zint_vector *in) {
outcircle = &(out->circles);
while (circle) {
*outcircle = malloc(sizeof(struct zint_vector_circle));
assert(*outcircle != NULL);
memcpy(*outcircle, circle, sizeof(struct zint_vector_circle));
outcircle = &((*outcircle)->next);
circle = circle->next;
@ -777,6 +800,7 @@ struct zint_vector *testUtilVectorCpy(const struct zint_vector *in) {
outhexagon = &(out->hexagons);
while (hexagon) {
*outhexagon = malloc(sizeof(struct zint_vector_hexagon));
assert(*outhexagon != NULL);
memcpy(*outhexagon, hexagon, sizeof(struct zint_vector_hexagon));
outhexagon = &((*outhexagon)->next);
hexagon = hexagon->next;
@ -2094,6 +2118,8 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
int upcean = is_extendable(symbology);
int upca = symbology == BARCODE_UPCA || symbology == BARCODE_UPCA_CHK || symbology == BARCODE_UPCA_CC;
char obracket = symbol->input_mode & GS1PARENS_MODE ? '(' : '[';
char cbracket = symbol->input_mode & GS1PARENS_MODE ? ')' : ']';
int addon_posn;
int eci;
@ -2146,7 +2172,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
fprintf(stderr, "i:%d testUtilBwipp: no primary data given %s\n", index, testUtilBarcodeName(symbology));
return -1;
}
if (*primary != '[' && !upcean) {
if (*primary != obracket && !upcean) {
strcat(bwipp_data, "(01)");
}
strcat(bwipp_data, primary);
@ -2175,7 +2201,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
}
} else {
if (gs1_cvt) {
if (*data != '[' && !upcean) {
if (*data != obracket && !upcean) {
strcat(bwipp_data, symbology == BARCODE_NVE18 ? "(00)" : "(01)");
}
strcat(bwipp_data, data);
@ -2355,7 +2381,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
if ((symbol->input_mode & 0x07) == GS1_MODE) { /* Hack pseudo-GS1 support */
int last_ai, ai_latch = 0;
for (int i = 0, j = 0, len = (int) strlen(bwipp_data); i <= len; i++) { /* Reduce square brackets (include NUL) */
if (bwipp_data[i] == '[') {
if (bwipp_data[i] == obracket) {
if (ai_latch == 0) {
bwipp_data[j++] = '[';
}
@ -2363,7 +2389,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
if ((last_ai >= 0 && last_ai <= 4) || (last_ai >= 11 && last_ai <= 20) || last_ai == 23 || (last_ai >= 31 && last_ai <= 36) || last_ai == 41) {
ai_latch = 1;
}
} else if (bwipp_data[i] != ']') {
} else if (bwipp_data[i] != cbracket) {
bwipp_data[j++] = bwipp_data[i];
}
}

View File

@ -43,6 +43,7 @@
#include "common.h"
#include "output.h"
#include "zfiletypes.h"
INTERNAL int ps_plot(struct zint_symbol *symbol);
INTERNAL int svg_plot(struct zint_symbol *symbol);

48
backend/zfiletypes.h Normal file
View File

@ -0,0 +1,48 @@
/* filetypes.h - file type flags
libzint - the open source barcode library
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
#ifndef ZFILETYPES_H
#define ZFILETYPES_H
// File types
#define OUT_BUFFER 0
#define OUT_SVG_FILE 10
#define OUT_EPS_FILE 20
#define OUT_EMF_FILE 30
#define OUT_PNG_FILE 100
#define OUT_BMP_FILE 120
#define OUT_GIF_FILE 140
#define OUT_PCX_FILE 160
#define OUT_JPG_FILE 180
#define OUT_TIF_FILE 200
#endif /* ZFILETYPES_H */

View File

@ -75,14 +75,14 @@ extern "C" {
struct zint_symbol {
int symbology;
int height;
int whitespace_width;
int border_width;
int height; /* Height in X-dims (ignored for fixed-width barcodes) */
int whitespace_width; /* Width in X-dims of whitespace to left/right of barcode */
int border_width; /* Size of border in X-dims */
int output_options;
char fgcolour[10];
char *fgcolor; // pointer to fgcolour
char bgcolour[10];
char *bgcolor; // pointer to bgcolour
char fgcolour[10]; /* Foreground as RGB/RGBA hexadecimal string */
char bgcolour[10]; /* Background as RGB/RGBA hexadecimal string */
char *fgcolor; /* Pointer to fgcolour */
char *bgcolor; /* Pointer to bgcolour */
char outfile[256];
float scale;
int option_1;
@ -110,6 +110,7 @@ extern "C" {
int warn_level;
};
// Symbologies (symbology)
/* Tbarcode 7 codes */
#define BARCODE_CODE11 1
#define BARCODE_C25STANDARD 2
@ -234,7 +235,7 @@ extern "C" {
#define BARCODE_ULTRA 144
#define BARCODE_RMQR 145
// Output options
// Output options (output_options)
#define BARCODE_NO_ASCII 1
#define BARCODE_BIND 2
#define BARCODE_BOX 4
@ -247,11 +248,12 @@ extern "C" {
#define GS1_GS_SEPARATOR 512
#define OUT_BUFFER_INTERMEDIATE 1024
// Input data types
// Input data types (input_mode)
#define DATA_MODE 0
#define UNICODE_MODE 1
#define GS1_MODE 2
#define ESCAPE_MODE 8
#define GS1PARENS_MODE 16
// Data Matrix specific options (option_3)
#define DM_SQUARE 100
@ -263,7 +265,7 @@ extern "C" {
// Ultracode specific option (option_3)
#define ULTRA_COMPRESSION 128
// Warning and error conditions
// Warning and error conditions (return values)
#define ZINT_WARN_INVALID_OPTION 2
#define ZINT_WARN_USES_ECI 3
#define ZINT_WARN_NONCOMPLIANT 4
@ -277,24 +279,12 @@ extern "C" {
#define ZINT_ERROR_MEMORY 11
#define ZINT_ERROR_FILE_WRITE 12
// File types
#define OUT_BUFFER 0
#define OUT_SVG_FILE 10
#define OUT_EPS_FILE 20
#define OUT_EMF_FILE 30
#define OUT_PNG_FILE 100
#define OUT_BMP_FILE 120
#define OUT_GIF_FILE 140
#define OUT_PCX_FILE 160
#define OUT_JPG_FILE 180
#define OUT_TIF_FILE 200
// Warning warn
// Warning warn (warn_level)
#define WARN_DEFAULT 0
#define WARN_ZPL_COMPAT 1
#define WARN_FAIL_ALL 2
// Capability flags
// Capability flags (cap_flag)
#define ZINT_CAP_HRT 0x0001
#define ZINT_CAP_STACKABLE 0x0002
#define ZINT_CAP_EXTENDABLE 0x0004
@ -310,7 +300,7 @@ extern "C" {
// The largest amount of data that can be encoded is 4350 4-byte UTF-8 chars in Han Xin Code
#define ZINT_MAX_DATA_LEN 17400
// Debug flags
// Debug flags (debug)
#define ZINT_DEBUG_PRINT 1
#define ZINT_DEBUG_TEST 2
@ -333,15 +323,19 @@ extern "C" {
ZINT_EXTERN int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int in_length);
ZINT_EXTERN int ZBarcode_Encode_File(struct zint_symbol *symbol, char *filename);
ZINT_EXTERN int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Print(struct zint_symbol *symbol, unsigned char *input, int length,
int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *input, int length, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol, unsigned char *input, int length,
int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol, unsigned char *input, int length,
int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *filename, int rotate_angle);
ZINT_EXTERN int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol, char *filename,
int rotate_angle);
ZINT_EXTERN int ZBarcode_ValidID(int symbol_id);
ZINT_EXTERN unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);

View File

@ -111,6 +111,8 @@
This is a preparation to add a TCL only mode to the DLL.
2021-01-22 GL
- -cols maximum changed from 67 to 108 (DotCode)
2021-05-10 GL
- Added -gs1parens option
*/
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
@ -447,6 +449,7 @@ static char help_message[] = "zint tcl(stub,obj) dll\n"
" -format binary|unicode|gs1: input data format. Default:unicode\n"
" -fullmultibyte bool: allow multibyte compaction for xQR, HanXin, Gridmatrix\n"
/* cli option --gs1 replaced by -format */
" -gs1parens bool: for gs1, AIs enclosed in parentheses instead of square brackets\n"
" -gssep bool: for gs1, use gs as separator instead fnc1 (Datamatrix only)\n"
" -height integer: Symbol height in modules\n"
/* cli option --input not supported */
@ -692,7 +695,7 @@ static int Encode(Tcl_Interp *interp, int objc,
char *optionList[] = {
"-addongap", "-barcode", "-bg", "-bind", "-bold", "-border", "-box",
"-cols", "-dmre", "-dotsize", "-dotty", "-eci", "-fg", "-format",
"-fullmultibyte", "-gssep", "-height", "-init", "-mask", "-mode",
"-fullmultibyte", "-gs1parens", "-gssep", "-height", "-init", "-mask", "-mode",
"-nobackground", "-notext", "-primary", "-reverse", "-rotate",
"-rows", "-scale", "-scmvv", "-secure", "-separator", "-smalltext",
"-square", "-to", "-vers", "-werror", "-whitesp", "-wzpl",
@ -700,7 +703,7 @@ static int Encode(Tcl_Interp *interp, int objc,
enum iOption {
iAddonGap, iBarcode, iBG, iBind, iBold, iBorder, iBox,
iCols, iDMRE, iDotSize, iDotty, iECI, iFG, iFormat,
iFullMultiByte, iGSSep, iHeight, iInit, iMask, iMode,
iFullMultiByte, iGS1Parens, iGSSep, iHeight, iInit, iMask, iMode,
iNoBackground, iNoText, iPrimary, iReverse, iRotate,
iRows, iScale, iSCMvv, iSecure, iSeparator, iSmallText,
iSquare, iTo, iVers, iWError, iWhiteSp, iWZPL
@ -725,6 +728,7 @@ static int Encode(Tcl_Interp *interp, int objc,
case iBox:
case iDMRE:
case iDotty:
case iGS1Parens:
case iGSSep:
case iInit:
case iNoBackground:
@ -845,6 +849,13 @@ static int Encode(Tcl_Interp *interp, int objc,
my_symbol->output_options &= ~BARCODE_DOTTY_MODE;
}
break;
case iGS1Parens:
if (intValue) {
my_symbol->input_mode |= GS1PARENS_MODE;
} else {
my_symbol->input_mode &= ~GS1PARENS_MODE;
}
break;
case iGSSep:
if (intValue) {
my_symbol->output_options |= GS1_GS_SEPARATOR;

View File

@ -482,7 +482,7 @@ code that has not been explicitly requested has been inserted into a symbol.
GS1 data can be encoded in a number of symbologies. Application identifiers
should be enclosed in [square brackets] followed by the data to be encoded (see
5.1.12.3). To encode GS1 data use the --gs1 option. GS1 mode is assumed (and
6.1.12.3). To encode GS1 data use the --gs1 option. GS1 mode is assumed (and
doesn't need to be set) for GS1-128, EAN-14, DataBar and Composite symbologies
but is also available for Aztec Code, Code 16k, Code 49, Code One, Data Matrix,
DotCode, QR Code and Ultracode.
@ -779,6 +779,7 @@ int main(int argc, char **argv)
{
struct zint_symbol *my_symbol;
my_symbol = ZBarcode_Create();
my_symbol->input_mode = UNICODE_MODE;
ZBarcode_Encode(my_symbol, argv[1], 0);
ZBarcode_Print(my_symbol, 0);
ZBarcode_Delete(my_symbol);
@ -793,6 +794,7 @@ int main(int argc, char **argv)
{
struct zint_symbol *my_symbol;
my_symbol = ZBarcode_Create();
my_symbol->input_mode = UNICODE_MODE;
ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
ZBarcode_Delete(my_symbol);
return 0;
@ -819,7 +821,7 @@ int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename,
In these definitions "length" can be used to set the length of the input
string. This allows the encoding of NUL (ASCII 0) characters in those
symbologies which allow this. A value of 0 will disable this function and Zint
symbologies which allow this. A value of 0 will disable this usage and Zint
will encode data up to the first NUL character in the input string.
The "rotate_angle" value can be used to rotate the image when outputting. Valid
@ -906,13 +908,13 @@ fgcolour | character | Foreground (ink) colour as | "000000"
| | string. Must be 6 or 8 |
| | characters followed by |
| | terminating \0. |
fgcolor | pointer | Points to fgcolour allowing |
| | alternate spelling. |
bgcolour | character | Background (paper) colour | "ffffff"
| string | as RGB/RGBA hexadecimal |
| | string. Must be 6 or 8 |
| | characters followed by |
| | terminating \0. |
fgcolor | pointer | Points to fgcolour allowing |
| | alternate spelling. |
bgcolor | pointer | Points to bgcolour allowing |
| | alternate spelling. |
outfile | character | Contains the name of the | "out.png"
@ -969,6 +971,10 @@ vector | pointer to | Pointer to vector header | (output only)
| structure | vector elements. |
--------------------------------------------------------------------------------
[1] This value is ignored for Australia Post 4-State Barcodes, POSTNET, PLANET,
USPS Intelligent Mail, RM4SCC, PDF417, Data Matrix, MaxiCode, QR Code, GS1
DataBar Stacked, PDF417 and MicroPDF417 - all of which have a fixed height.
To alter these values use the syntax shown in the example below. This code has
the same result as the previous example except the output is now taller and
plotted in green.
@ -1227,30 +1233,42 @@ OUT_BUFFER_INTERMEDIATE | Return the bitmap buffer as ASCII values instead of
| separate colour channels (OUT_BUFFER only).
--------------------------------------------------------------------------------
[2] This value is ignored for Code 16k and Codablock-F. Special considerations
apply to ITF-14 - see the specific section 6.1.2.6 for that symbology.
5.9 Setting the Input Mode
--------------------------
The way in which the input data is encoded can be set using the input_mode
property. Valid values are shown in the table below.
-----------------------------------------------------------------------------
Value | Effect
-----------------------------------------------------------------------------
DATA_MODE | Uses full ASCII range interpreted as Latin-1 or binary data.
UNICODE_MODE | Uses pre-formatted UTF-8 input.
GS1_MODE | Encodes GS1 data using FNC1 characters.
ESCAPE_MODE | Process input data for escape sequences.
-----------------------------------------------------------------------------
------------------------------------------------------------------------------
Value | Effect
------------------------------------------------------------------------------
DATA_MODE | Uses full ASCII range interpreted as Latin-1 or binary data.
UNICODE_MODE | Uses pre-formatted UTF-8 input.
GS1_MODE | Encodes GS1 data using FNC1 characters.
|
ESCAPE_MODE | Process input data for escape sequences.
GS1PARENS_MODE | Parentheses (rounded brackets) used in input data instead of
| square brackets to delimit GS1 application identifiers
| (parentheses must not otherwise occur in the data).
------------------------------------------------------------------------------
DATA_MODE, UNICODE_MODE and GS1_MODE are mutually exclusive, whereas ESCAPE_MODE
is optional. So, for example, you can set
and GS1PARENS_MODE are optional. So, for example, you can set
my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
or
my_symbol->input_mode = GS1_MODE | GS1PARENS_MODE;
whereas
my_symbol->input_mode = DATA_MODE | GS1_MODE;
is not valid. Permissible escape sequences are listed in section 4.1.
is not valid. Permissible escape sequences are listed in section 4.1. An
example of GS1PARENS_MODE usage is given in section 6.1.12.3.
5.10 Verifying Symbology Availability
-------------------------------------
@ -1321,13 +1339,6 @@ int ZBarcode_Version();
The version parts are separated by hundreds. For instance, version "2.9.1" is
returned as "20901".
[1] This value is ignored for Australia Post 4-State Barcodes, POSTNET, PLANET,
USPS Intelligent Mail, RM4SCC, PDF417, Data Matrix, MaxiCode, QR Code, GS1
DataBar Stacked, PDF417 and MicroPDF417 - all of which have a fixed height.
[2] This value is ignored for Code 16k and Codablock-F. Special considerations
apply to ITF-14 - see the specific section for that symbology.
6. Types of Symbology
=====================
@ -1618,7 +1629,7 @@ developed in 1981 by Computer Identics. This symbology supports full ASCII text
and uses a three-mode system to compress the data into a smaller symbol. Zint
automatically switches between modes and adds a modulo-103 check digit. Code
128 is the default barcode symbology used by Zint. In addition Zint supports
the encoding of Latin-1 (non-English) characters in Code 128 symbols [1]. The
the encoding of Latin-1 (non-English) characters in Code 128 symbols. The
Latin-1 character set is shown in Appendix A.
6.1.11.2 Code 128 Subset B
@ -1696,16 +1707,26 @@ case the check digit will be verified.
-------------------------
Previously known as RSS Expanded this is a variable length symbology capable of
encoding data from a number of AIs in a single symbol. AIs should be encased in
[square brackets] in the input data. This will be converted to (rounded
brackets) before it is included in the human readable text attached to the
symbol. This method allows the inclusion of rounded brackets in the data to be
encoded. GTIN data (AI 01) should also include the check digit data as this is
not calculated by Zint when this symbology is encoded. Fixed length data should
be entered at the appropriate length for correct encoding. The following is an
[square brackets] in the input data. This will be converted to parentheses
(rounded brackets) before it is included in the human readable text attached to
the symbol. This method allows the inclusion of parentheses in the data to be
encoded.
For compatibility with data entry in other systems, if the data does not include
parentheses, the option --gs1parens (API input_mode |= GS1PARENS_MODE;) may be
used to signal that AIs are encased in rounded brackets instead of square ones.
GTIN data (AI 01) should also include the check digit data as this is not
calculated by Zint when this symbology is encoded. Fixed length data should be
entered at the appropriate length for correct encoding. The following is an
example of a valid DataBar Expanded input:
zint --barcode=31 -d "[01]98898765432106[3202]012345[15]991231"
or using the --gs1parens option:
zint --barcode=31 --gs1parens -d "(01)98898765432106(3202)012345(15)991231"
6.1.13 Korea Post Barcode
-------------------------
The Korean Postal Barcode is used to encode a six-digit number and includes one
@ -1901,7 +1922,7 @@ strcpy(my_symbol->primary, "331234567890");
ZBarcode_Encode_and_Print(my_symbol, "[99]1234-abcd", 0, 0);
EAN-2 and EAN-5 add-on data can be used with EAN and UPC symbols using the +
symbol as described in section 6.1.3 and 5.1.4.
symbol as described in sections 6.1.3 and 6.1.4.
The 2D component of a composite symbol can use one of three systems: CC-A, CC-B
and CC-C as described below. The 2D component type can be selected

View File

@ -138,6 +138,7 @@ static void usage(void) {
" --filetype=TYPE Set output file type BMP/EMF/EPS/GIF/PCX/PNG/SVG/TIF/TXT\n"
" --fullmultibyte Use multibyte for binary/Latin (QR/Han Xin/Grid Matrix)\n"
" --gs1 Treat input as GS1 compatible data\n"
" --gs1parens GS1 AIs in parentheses instead of square brackets\n"
" --gssep Use separator GS for GS1 (Data Matrix)\n"
" -h, --help Display help message\n"
" --height=NUMBER Set height of symbol in multiples of X-dimension\n"
@ -288,7 +289,10 @@ static int get_barcode_name(const char *barcode_name) {
{ BARCODE_DPD, "dpd" },
{ BARCODE_DPIDENT, "dpident" },
{ BARCODE_DPLEIT, "dpleit" },
{ BARCODE_EANX, "ean" }, /* Synonym */
{ BARCODE_EAN14, "ean14" },
{ BARCODE_EANX_CC, "eancc" }, /* Synonym */
{ BARCODE_EANX_CHK, "eanchk" }, /* Synonym */
{ BARCODE_EANX, "eanx" },
{ BARCODE_EANX_CC, "eanxcc" },
{ BARCODE_EANX_CHK, "eanxchk" },
@ -791,7 +795,7 @@ int main(int argc, char **argv) {
OPT_ADDONGAP = 128, OPT_BATCH, OPT_BINARY, OPT_BG, OPT_BIND, OPT_BOLD, OPT_BORDER,
OPT_BOX, OPT_CMYK, OPT_COLS, OPT_DIRECT, OPT_DMRE, OPT_DOTSIZE, OPT_DOTTY, OPT_DUMP,
OPT_ECI, OPT_ESC, OPT_FG, OPT_FILETYPE, OPT_FONTSIZE, OPT_FULLMULTIBYTE,
OPT_GS1, OPT_GSSEP, OPT_HEIGHT, OPT_INIT, OPT_MIRROR, OPT_MASK, OPT_MODE,
OPT_GS1, OPT_GS1PARENS, OPT_GSSEP, OPT_HEIGHT, OPT_INIT, OPT_MIRROR, OPT_MASK, OPT_MODE,
OPT_NOBACKGROUND, OPT_NOTEXT, OPT_PRIMARY, OPT_ROTATE, OPT_ROWS, OPT_SCALE,
OPT_SCMVV, OPT_SECURE, OPT_SEPARATOR, OPT_SMALL, OPT_SQUARE, OPT_VERBOSE, OPT_VERS,
OPT_WERROR, OPT_WZPL,
@ -823,6 +827,7 @@ int main(int argc, char **argv) {
{"fontsize", 1, NULL, OPT_FONTSIZE},
{"fullmultibyte", 0, NULL, OPT_FULLMULTIBYTE},
{"gs1", 0, 0, OPT_GS1},
{"gs1parens", 0, NULL, OPT_GS1PARENS},
{"gssep", 0, NULL, OPT_GSSEP},
{"height", 1, NULL, OPT_HEIGHT},
{"help", 0, NULL, 'h'},
@ -993,6 +998,9 @@ int main(int argc, char **argv) {
case OPT_GS1:
my_symbol->input_mode = (my_symbol->input_mode & ~0x07) | GS1_MODE;
break;
case OPT_GS1PARENS:
my_symbol->input_mode |= GS1PARENS_MODE;
break;
case OPT_GSSEP:
my_symbol->output_options |= GS1_GS_SEPARATOR;
break;

View File

@ -123,6 +123,9 @@ static void arg_input_mode(char *cmd, int input_mode) {
if (input_mode & ESCAPE_MODE) {
sprintf(cmd + (int) strlen(cmd), "%s--esc", strlen(cmd) ? " " : "");
}
if (input_mode & GS1PARENS_MODE) {
sprintf(cmd + (int) strlen(cmd), "%s--gs1parens", strlen(cmd) ? " " : "");
}
}
}
@ -208,25 +211,26 @@ static void test_dump_args(int index, int debug) {
/* 17*/ { BARCODE_PDF417, "123", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, 1, 0, 0, -1, "FF 54 7A BC 3D 4F 1D 5C 0F E8 A4\nFF 54 7A 90 2F D3 1F AB 8F E8 A4\nFF 54 6A F8 3A BF 15 3C 0F E8 A4\nFF 54 57 9E 24 E7 1A F7 CF E8 A4\nFF 54 7A E7 3D 0D 9D 73 0F E8 A4\nFF 54 7D 70 B9 CB DF 5E CF E8 A4" },
/* 18*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA 8\nB3 4\n8F 0\nB2 C\nA6 0\nBA C\nD6 0\nEB 4\nE2 8\nFF C" },
/* 19*/ { BARCODE_DATAMATRIX, "ABC", NULL, NULL, NULL, -1, READER_INIT, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A\nAC 7\n8A 4\nA0 3\nC2 2\nB5 1\n82 2\nBA 7\n8C C\nA0 5\n86 A\nFF F" },
/* 20*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nA6 C7 FA F9\nB2 AA C7 BA\n98 BF F4 0F\nE8 DA 90 C8\nC7 D5 B6 DF\nC5 50 B0 2C\nFF FF FF FF" },
/* 21*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\nA6 D3\nB2 DA\n99 19\nA8 A6\n84 F7\nC0 8C\nF9 87\nFC 4C\nD8 A5\n83 E6\n99 75\nF7 82\nAE 65\n8D 6A\nFF FF" },
/* 22*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nA6 94 BC\nB2 AD F0\n99 08 F4\nA9 E1 B8\n86 81 CC\nC2 F5 88\nF5 D5 3C\nF2 68 30\nDA 7A BC\nB7 FE 70\nA8 E7 34\n91 40 88\nD6 33 DC\nD2 89 20\nD1 6A 94\nE2 71 A8\nE4 3E EC\nF2 9D 70\nE5 8D FC\nB9 56 50\nFF FF FC" },
/* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nA6 D9 C8 0B FC 57 F3 17\nB2 BA A7 CA C9 18 87 BE\n99 2F EF 2B F1 A1 B9 DF\nA8 84 99 CA CF 4A BF 14\n86 D5 D9 87 A4 EF F4 9F\n85 44 BF 22 E7 58 C6 8A\nFF FF FF FF FF FF FF FF" },
/* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA A8\nA6 94 BC\nB2 AD F0\n99 08 F4\nA9 E1 B8\n86 81 CC\nC2 F5 88\nF5 D5 3C\nF2 68 30\nDA 7A BC\nB7 FE 70\nA8 E7 34\n91 40 88\nD6 33 DC\nD2 89 20\nD1 6A 94\nE2 71 A8\nE4 3E EC\nF2 9D 70\nE5 8D FC\nB9 56 50\nFF FF FC" },
/* 20*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA\nA6 ED A9 D1\nB2 FE 92 7E\n98 E7 C3 FF\nE8 D0 90 CC\nC7 EB 8D 63\nC5 48 D3 C4\nFF FF FF FF" },
/* 21*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJK", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA\nA6 FF\nB2 C0\n99 19\nA8 BA\n84 EF\nC0 9C\nE9 47\nE5 90\nB3 49\n91 36\nB3 7D\nD4 56\nF7 DD\nC5 62\nFF FF" },
/* 22*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA A8\nA6 94 A4\nB2 AD 98\n99 09 3C\nA9 E1 00\n86 80 F4\nC2 F5 68\nF5 D5 1C\nF2 68 70\nDA 7A 1C\nB7 FA 30\nA8 E0 F4\n91 74 D8\nD6 1D 74\nD2 31 08\nF1 E9 74\nC2 BF A8\nA6 8B 6C\n83 3D D8\nF9 ED CC\nAB 5A 58\nFF FF FC" },
/* 23*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA AA AA AA AA AA AA AA\nA6 D9 C8 0F 82 EB 81 97\nB2 BA A7 C8 F5 64 BD 2E\n99 2F EF 29 84 07 9F C7\nA8 84 99 C2 F2 1A 9F 44\n86 D5 D9 8B EF 41 BB 7F\n85 44 BF 28 F7 80 99 76\nFF FF FF FF FF FF FF FF" },
/* 24*/ { BARCODE_DATAMATRIX, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF", NULL, NULL, NULL, -1, -1, 0, -1, 1, -1, 0, -1, -1, NULL, -1, -1, 1, -1, "AA AA A8\nA6 94 A4\nB2 AD 98\n99 09 3C\nA9 E1 00\n86 80 F4\nC2 F5 68\nF5 D5 1C\nF2 68 70\nDA 7A 1C\nB7 FA 30\nA8 E0 F4\n91 74 D8\nD6 1D 74\nD2 31 08\nF1 E9 74\nC2 BF A8\nA6 8B 6C\n83 3D D8\nF9 ED CC\nAB 5A 58\nFF FF FC" },
/* 25*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nFA 9C\nBC 00\nD7 84\nED E0\nA4 E4\nA7 40\n9D 3C\nBF 50\nFA 24\nB1 68\nE5 04\n92 70\nFF FC" },
/* 26*/ { BARCODE_DATAMATRIX, "[91]12[92]34", NULL, NULL, NULL, GS1_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
/* 27*/ { BARCODE_DATAMATRIX, "[9\\x31]12[92]34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
/* 28*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
/* 29*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
/* 30*/ { BARCODE_QRCODE, "", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
/* 31*/ { BARCODE_QRCODE, "", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" },
/* 32*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" },
/* 33*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
/* 34*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
/* 35*/ { BARCODE_QRCODE, "", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
/* 36*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
/* 37*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 AA\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\nAB E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" },
/* 38*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
/* 28*/ { BARCODE_DATAMATRIX, "(9\\x31)12(92)34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
/* 29*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
/* 30*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
/* 31*/ { BARCODE_QRCODE, "", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
/* 32*/ { BARCODE_QRCODE, "", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" },
/* 33*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" },
/* 34*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
/* 35*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
/* 36*/ { BARCODE_QRCODE, "", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
/* 37*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
/* 38*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 AA\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\nAB E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" },
/* 39*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
};
int data_size = ARRAY_SIZE(data);
@ -654,25 +658,27 @@ static void test_barcode_symbology(int index, int debug) {
/* 12*/ { "code39", "1", NULL, 0, "symbology: 8," },
/* 13*/ { "excode 39", "1", NULL, 0, "symbology: 9," },
/* 14*/ { "eanx", "1", NULL, 0, "symbology: 13," },
/* 15*/ { "eanx chk", "1", NULL, 0, "symbology: 14," },
/* 16*/ { "eanxchk", "1", NULL, 0, "symbology: 14," },
/* 17*/ { "GS1128", "[01]12345678901231", NULL, 0, "symbology: 16," },
/* 18*/ { "coda bar", "A1B", NULL, 0, "symbology: 18," },
/* 19*/ { "DPLEIT", "1", NULL, 0, "symbology: 21," },
/* 20*/ { "DPIDENT", "1", NULL, 0, "symbology: 22," },
/* 21*/ { "code16k", "1", NULL, 0, "symbology: 23," },
/* 22*/ { "CODE49", "1", NULL, 0, "symbology: 24," },
/* 23*/ { "CODE93", "1", NULL, 0, "symbology: 25," },
/* 24*/ { "flat", "1", NULL, 0, "symbology: 28," },
/* 25*/ { "dbar omn", "1", NULL, 0, "symbology: 29," },
/* 26*/ { "dbar ltd", "1", NULL, 0, "symbology: 30," },
/* 27*/ { "dbarexp", "[10]12", NULL, 0, "symbology: 31," },
/* 28*/ { "telepen", "1", NULL, 0, "symbology: 32," },
/* 29*/ { "upc", "1", NULL, 1, "Error 119: Invalid barcode type 'upc'" },
/* 30*/ { "upca", "1", NULL, 0, "symbology: 34," },
/* 31*/ { "upca_chk", "123456789012", NULL, 0, "symbology: 35," },
/* 33*/ { "upce", "1", NULL, 0, "symbology: 37," },
/* 34*/ { "upce chk", "12345670", NULL, 0, "symbology: 38," },
/* 15*/ { "ean", "1", NULL, 0, "symbology: 13," },
/* 16*/ { "eanx chk", "1", NULL, 0, "symbology: 14," },
/* 17*/ { "eanxchk", "1", NULL, 0, "symbology: 14," },
/* 18*/ { "eanchk", "1", NULL, 0, "symbology: 14," },
/* 19*/ { "GS1128", "[01]12345678901231", NULL, 0, "symbology: 16," },
/* 20*/ { "coda bar", "A1B", NULL, 0, "symbology: 18," },
/* 21*/ { "DPLEIT", "1", NULL, 0, "symbology: 21," },
/* 22*/ { "DPIDENT", "1", NULL, 0, "symbology: 22," },
/* 23*/ { "code16k", "1", NULL, 0, "symbology: 23," },
/* 24*/ { "CODE49", "1", NULL, 0, "symbology: 24," },
/* 25*/ { "CODE93", "1", NULL, 0, "symbology: 25," },
/* 26*/ { "flat", "1", NULL, 0, "symbology: 28," },
/* 27*/ { "dbar omn", "1", NULL, 0, "symbology: 29," },
/* 28*/ { "dbar ltd", "1", NULL, 0, "symbology: 30," },
/* 29*/ { "dbarexp", "[10]12", NULL, 0, "symbology: 31," },
/* 30*/ { "telepen", "1", NULL, 0, "symbology: 32," },
/* 31*/ { "upc", "1", NULL, 1, "Error 119: Invalid barcode type 'upc'" },
/* 32*/ { "upca", "1", NULL, 0, "symbology: 34," },
/* 33*/ { "upca_chk", "123456789012", NULL, 0, "symbology: 35," },
/* 34*/ { "upce", "1", NULL, 0, "symbology: 37," },
/* 35*/ { "upce chk", "12345670", NULL, 0, "symbology: 38," },
/* 36*/ { "POSTNET ", "12345678901", NULL, 0, "symbology: 40," },
/* 37*/ { "MSI Plessey ", "1", NULL, 0, "symbology: 47," },
/* 38*/ { "fim ", "A", NULL, 0, "symbology: 49," },
@ -714,48 +720,49 @@ static void test_barcode_symbology(int index, int debug) {
/* 74*/ { "DPD", "0123456789012345678901234567", NULL, 0, "symbology: 96," },
/* 75*/ { "Micro QR", "1", NULL, 0, "symbology: 97," },
/* 76*/ { "hibc128", "1", NULL, 0, "symbology: 98," },
/* 76*/ { "hibccode128", "1", NULL, 0, "symbology: 98," }, // Synonym
/* 77*/ { "hibc39", "1", NULL, 0, "symbology: 99," },
/* 77*/ { "hibccode39", "1", NULL, 0, "symbology: 99," }, // Synonym
/* 78*/ { "hibcdatamatrix", "1", NULL, 0, "symbology: 102," }, // Synonym
/* 78*/ { "hibcdm", "1", NULL, 0, "symbology: 102," },
/* 79*/ { "HIBC qr", "1", NULL, 0, "symbology: 104," },
/* 79*/ { "HIBC QR Code", "1", NULL, 0, "symbology: 104," }, // Synonym
/* 80*/ { "HIBCPDF", "1", NULL, 0, "symbology: 106," },
/* 80*/ { "HIBCPDF417", "1", NULL, 0, "symbology: 106," }, // Synonym
/* 81*/ { "HIBCMICPDF", "1", NULL, 0, "symbology: 108," },
/* 81*/ { "HIBC Micro PDF", "1", NULL, 0, "symbology: 108," }, // Synonym
/* 81*/ { "HIBC Micro PDF417", "1", NULL, 0, "symbology: 108," }, // Synonym
/* 81*/ { "HIBC BlockF", "1", NULL, 0, "symbology: 110," },
/* 81*/ { "HIBC CodaBlock-F", "1", NULL, 0, "symbology: 110," }, // Synonym
/* 82*/ { "HIBC Aztec", "1", NULL, 0, "symbology: 112," },
/* 83*/ { "DotCode", "1", NULL, 0, "symbology: 115," },
/* 84*/ { "Han Xin", "1", NULL, 0, "symbology: 116," },
/* 85*/ { "Mailmark", "01000000000000000AA00AA0A", NULL, 0, "symbology: 121," },
/* 86*/ { "azrune", "1", NULL, 0, "symbology: 128," },
/* 86*/ { "aztecrune", "1", NULL, 0, "symbology: 128," }, // Synonym
/* 86*/ { "aztecrunes", "1", NULL, 0, "symbology: 128," }, // Synonym
/* 87*/ { "code32", "1", NULL, 0, "symbology: 129," },
/* 88*/ { "eanx cc", "[20]01", "1234567890128", 0, "symbology: 130," },
/* 89*/ { "GS1 128 CC", "[01]12345678901231", "[20]01", 0, "symbology: 131," },
/* 90*/ { "dbaromncc", "[20]01", "1234567890123", 0, "symbology: 132," },
/* 91*/ { "dbarltdcc", "[20]01", "1234567890123", 0, "symbology: 133," },
/* 92*/ { "dbarexpcc", "[20]01", "[01]12345678901231", 0, "symbology: 134," },
/* 93*/ { "upcacc", "[20]01", "12345678901", 0, "symbology: 135," },
/* 94*/ { "upcecc", "[20]01", "1234567", 0, "symbology: 136," },
/* 95*/ { "dbar stk cc", "[20]01", "1234567890123", 0, "symbology: 137," },
/* 96*/ { "dbaromnstkcc", "[20]01", "1234567890123", 0, "symbology: 138," },
/* 97*/ { "dbarexpstkcc", "[20]01", "[01]12345678901231", 0, "symbology: 139," },
/* 98*/ { "Channel", "1", NULL, 0, "symbology: 140," },
/* 99*/ { "CodeOne", "1", NULL, 0, "symbology: 141," },
/*100*/ { "Grid Matrix", "1", NULL, 0, "symbology: 142," },
/*101*/ { "UPN QR", "1", NULL, 0, "symbology: 143," },
/*102*/ { "UPN QR Code", "1", NULL, 0, "symbology: 143," }, // Synonym
/*103*/ { "ultra", "1", NULL, 0, "symbology: 144," },
/*104*/ { "ultracode", "1", NULL, 0, "symbology: 144," }, // Synonym
/*105*/ { "rMQR", "1", NULL, 0, "symbology: 145," },
/*106*/ { "x", "1", NULL, 1, "Error 119: Invalid barcode type 'x'" },
/*107*/ { "\177", "1", NULL, 1, "Error 119: Invalid barcode type '\177'" },
/* 77*/ { "hibccode128", "1", NULL, 0, "symbology: 98," }, // Synonym
/* 78*/ { "hibc39", "1", NULL, 0, "symbology: 99," },
/* 79*/ { "hibccode39", "1", NULL, 0, "symbology: 99," }, // Synonym
/* 80*/ { "hibcdatamatrix", "1", NULL, 0, "symbology: 102," }, // Synonym
/* 81*/ { "hibcdm", "1", NULL, 0, "symbology: 102," },
/* 82*/ { "HIBC qr", "1", NULL, 0, "symbology: 104," },
/* 83*/ { "HIBC QR Code", "1", NULL, 0, "symbology: 104," }, // Synonym
/* 84*/ { "HIBCPDF", "1", NULL, 0, "symbology: 106," },
/* 85*/ { "HIBCPDF417", "1", NULL, 0, "symbology: 106," }, // Synonym
/* 86*/ { "HIBCMICPDF", "1", NULL, 0, "symbology: 108," },
/* 87*/ { "HIBC Micro PDF", "1", NULL, 0, "symbology: 108," }, // Synonym
/* 88*/ { "HIBC Micro PDF417", "1", NULL, 0, "symbology: 108," }, // Synonym
/* 89*/ { "HIBC BlockF", "1", NULL, 0, "symbology: 110," },
/* 90*/ { "HIBC CodaBlock-F", "1", NULL, 0, "symbology: 110," }, // Synonym
/* 91*/ { "HIBC Aztec", "1", NULL, 0, "symbology: 112," },
/* 92*/ { "DotCode", "1", NULL, 0, "symbology: 115," },
/* 93*/ { "Han Xin", "1", NULL, 0, "symbology: 116," },
/* 94*/ { "Mailmark", "01000000000000000AA00AA0A", NULL, 0, "symbology: 121," },
/* 95*/ { "azrune", "1", NULL, 0, "symbology: 128," },
/* 96*/ { "aztecrune", "1", NULL, 0, "symbology: 128," }, // Synonym
/* 97*/ { "aztecrunes", "1", NULL, 0, "symbology: 128," }, // Synonym
/* 98*/ { "code32", "1", NULL, 0, "symbology: 129," },
/* 99*/ { "eanx cc", "[20]01", "1234567890128", 0, "symbology: 130," },
/*100*/ { "eancc", "[20]01", "1234567890128", 0, "symbology: 130," },
/*101*/ { "GS1 128 CC", "[01]12345678901231", "[20]01", 0, "symbology: 131," },
/*102*/ { "dbaromncc", "[20]01", "1234567890123", 0, "symbology: 132," },
/*103*/ { "dbarltdcc", "[20]01", "1234567890123", 0, "symbology: 133," },
/*104*/ { "dbarexpcc", "[20]01", "[01]12345678901231", 0, "symbology: 134," },
/*105*/ { "upcacc", "[20]01", "12345678901", 0, "symbology: 135," },
/*106*/ { "upcecc", "[20]01", "1234567", 0, "symbology: 136," },
/*107*/ { "dbar stk cc", "[20]01", "1234567890123", 0, "symbology: 137," },
/*108*/ { "dbaromnstkcc", "[20]01", "1234567890123", 0, "symbology: 138," },
/*109*/ { "dbarexpstkcc", "[20]01", "[01]12345678901231", 0, "symbology: 139," },
/*110*/ { "Channel", "1", NULL, 0, "symbology: 140," },
/*111*/ { "CodeOne", "1", NULL, 0, "symbology: 141," },
/*112*/ { "Grid Matrix", "1", NULL, 0, "symbology: 142," },
/*113*/ { "UPN QR", "1", NULL, 0, "symbology: 143," },
/*114*/ { "UPN QR Code", "1", NULL, 0, "symbology: 143," }, // Synonym
/*115*/ { "ultra", "1", NULL, 0, "symbology: 144," },
/*116*/ { "ultracode", "1", NULL, 0, "symbology: 144," }, // Synonym
/*117*/ { "rMQR", "1", NULL, 0, "symbology: 145," },
/*118*/ { "x", "1", NULL, 1, "Error 119: Invalid barcode type 'x'" },
/*119*/ { "\177", "1", NULL, 1, "Error 119: Invalid barcode type '\177'" },
};
int data_size = ARRAY_SIZE(data);
@ -777,9 +784,9 @@ static void test_barcode_symbology(int index, int debug) {
strcat(cmd, " 2>&1");
assert_nonnull(exec(cmd, buf, sizeof(buf) - 1, debug, i), "i:%d exec(%s) NULL\n", i, cmd);
assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr(%s, %s) == NULL\n", i, buf, data[i].expected);
assert_nonnull(strstr(buf, data[i].expected), "i:%d strstr(%s, %s) == NULL (%s)\n", i, buf, data[i].expected, cmd);
if (!data[i].fail) {
assert_zero(remove(outfilename), "i:%d remove(%s) != 0 (%d)\n", i, outfilename, errno);
assert_zero(remove(outfilename), "i:%d remove(%s) != 0 (%d) (%s)\n", i, outfilename, errno, cmd);
}
}

View File

@ -54,6 +54,7 @@ HEADERS += barcodeitem.h \
..\backend\stdint_msvc.h \
..\backend\tif.h \
..\backend\tif_lzw.h \
..\backend\zfiletypes.h \
..\backend\zint.h \
..\backend\zintconfig.h \

View File

@ -379,7 +379,7 @@ p, li { white-space: pre-wrap; }
<widget class="QComboBox" name="cmbECI">
<property name="minimumSize">
<size>
<width>80</width>
<width>66</width>
<height>16777215</height>
</size>
</property>
@ -585,6 +585,21 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkGS1Parens">
<property name="toolTip">
<string>Use parentheses "()" instead of square brackets "[]"
to delimit GS1 application identifiers
(ignored if disabled)</string>
</property>
<property name="text">
<string>GS1 &amp;()</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkRInit">
<property name="toolTip">

View File

@ -163,6 +163,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
chkEscape->setChecked(settings.value("studio/chk_escape").toInt() ? true : false);
chkData->setChecked(settings.value("studio/chk_data").toInt() ? true : false);
chkRInit->setChecked(settings.value("studio/chk_rinit").toInt() ? true : false);
chkGS1Parens->setChecked(settings.value("studio/chk_gs1parens").toInt() ? true : false);
chkAutoHeight->setChecked(settings.value("studio/appearance/autoheight", 1).toInt() ? true : false);
heightb->setValue(settings.value("studio/appearance/height", 50).toInt());
bwidth->setValue(settings.value("studio/appearance/border", 0).toInt());
@ -198,6 +199,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
connect(chkEscape, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(chkData, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(chkRInit, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(chkGS1Parens, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
connect(btnAbout, SIGNAL(clicked( bool )), SLOT(about()));
connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
@ -250,6 +252,7 @@ MainWindow::~MainWindow()
settings.setValue("studio/chk_escape", chkEscape->isChecked() ? 1 : 0);
settings.setValue("studio/chk_data", chkData->isChecked() ? 1 : 0);
settings.setValue("studio/chk_rinit", chkRInit->isChecked() ? 1 : 0);
settings.setValue("studio/chk_gs1parens", chkGS1Parens->isChecked() ? 1 : 0);
settings.setValue("studio/appearance/autoheight", chkAutoHeight->isChecked() ? 1 : 0);
settings.setValue("studio/appearance/height", heightb->value());
settings.setValue("studio/appearance/border", bwidth->value());
@ -1029,6 +1032,7 @@ void MainWindow::change_options()
break;
}
cmbECI->setEnabled(m_bc.bc.supportsECI(symbology)); /* Will need checking again in update_preview() as encoding mode dependent (HIBC) */
chkGS1Parens->setEnabled(m_bc.bc.supportsGS1(symbology)); /* Ditto (GS1) */
chkRInit->setEnabled(m_bc.bc.supportsReaderInit(symbology)); /* Ditto (HIBC and GS1) */
chkAutoHeight->setEnabled(!m_bc.bc.isFixedRatio(symbology));
chkHRTShow->setEnabled(m_bc.bc.hasHRT(symbology));
@ -1601,6 +1605,7 @@ void MainWindow::update_preview()
cmbECI->setEnabled(m_bc.bc.supportsECI());
lblECI->setEnabled(cmbECI->isEnabled());
}
chkGS1Parens->setEnabled(m_bc.bc.supportsGS1());
chkRInit->setEnabled(m_bc.bc.supportsReaderInit() && (m_bc.bc.inputMode() & 0x07) != GS1_MODE);
if (!grpComposite->isHidden() && chkComposite->isChecked())
@ -1612,6 +1617,8 @@ void MainWindow::update_preview()
m_bc.bc.setHeight(heightb->value());
}
m_bc.bc.setECI(cmbECI->isEnabled() ? cmbECI->currentIndex() : 0);
m_bc.bc.setGS1Parens(chkGS1Parens->isEnabled() && chkGS1Parens->isChecked());
m_bc.bc.setReaderInit(chkRInit->isEnabled() && chkRInit->isChecked());
m_bc.bc.setReaderInit(chkRInit->isEnabled() && chkRInit->isChecked());
m_bc.bc.setShowText(chkHRTShow->isEnabled() && chkHRTShow->isChecked());
m_bc.bc.setBorderType(btype->currentIndex());
@ -1901,6 +1908,7 @@ void MainWindow::save_sub_settings(QSettings &settings, int symbology) {
if (chkRInit->isEnabled()) {
settings.setValue(QString("studio/bc/%1/chk_rinit").arg(name), chkRInit->isChecked() ? 1 : 0);
}
settings.setValue(QString("studio/bc/%1/chk_gs1parens").arg(name), chkGS1Parens->isChecked() ? 1 : 0);
if (chkAutoHeight->isEnabled()) {
settings.setValue(QString("studio/bc/%1/appearance/autoheight").arg(name), chkAutoHeight->isChecked() ? 1 : 0);
settings.setValue(QString("studio/bc/%1/appearance/height").arg(name), heightb->value());
@ -2130,6 +2138,7 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology) {
if (chkRInit->isEnabled()) {
chkRInit->setChecked(settings.value(QString("studio/bc/%1/chk_rinit").arg(name)).toInt() ? true : false);
}
chkGS1Parens->setChecked(settings.value(QString("studio/bc/%1/chk_gs1parens").arg(name)).toInt() ? true : false);
if (chkAutoHeight->isEnabled()) {
chkAutoHeight->setChecked(settings.value(QString("studio/bc/%1/appearance/autoheight").arg(name), 1).toInt() ? true : false);
heightb->setValue(settings.value(QString("studio/bc/%1/appearance/height").arg(name), 50).toInt());

View File

@ -53,6 +53,7 @@ namespace Zint {
target_size_vert = 0;
m_option_2 = 0;
m_whitespace = 0;
m_gs1parens = false;
m_gssep = false;
m_reader_init = false;
m_rotate_angle = 0;
@ -86,6 +87,9 @@ namespace Zint {
m_zintSymbol->eci = m_eci;
m_zintSymbol->option_3 = m_option_3;
m_zintSymbol->scale = m_scale;
if (m_gs1parens) {
m_zintSymbol->input_mode |= GS1PARENS_MODE;
}
if (m_gssep) {
m_zintSymbol->output_options |= GS1_GS_SEPARATOR;
}
@ -312,6 +316,10 @@ namespace Zint {
}
}
void QZint::setGS1Parens(bool gs1parens) {
m_gs1parens = gs1parens;
}
void QZint::setReaderInit(bool reader_init) {
m_reader_init = reader_init;
}
@ -332,6 +340,10 @@ namespace Zint {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_ECI);
}
bool QZint::supportsGS1(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_GS1);
}
bool QZint::isFixedRatio(int symbology) const {
return ZBarcode_Cap(symbology ? symbology : m_symbol, ZINT_CAP_FIXED_RATIO);
}

View File

@ -96,6 +96,8 @@ public:
void setECI(int ECIIndex);
void setGS1Parens(bool gs1parens);
void setReaderInit(bool reader_init);
void setDebug(bool debug);
@ -103,6 +105,7 @@ public:
bool hasHRT(int symbology = 0) const;
bool isExtendable(int symbology = 0) const;
bool supportsECI(int symbology = 0) const;
bool supportsGS1(int symbology = 0) const;
bool isFixedRatio(int symbology = 0) const;
bool isDotty(int symbology = 0) const;
bool supportsReaderInit(int symbology = 0) const;
@ -155,6 +158,7 @@ private:
float m_dot_size;
int target_size_horiz;
int target_size_vert;
bool m_gs1parens;
bool m_gssep;
bool m_reader_init;
bool m_debug;

View File

@ -211,6 +211,7 @@
<ClInclude Include="..\backend\stdint_msvc.h" />
<ClInclude Include="..\backend\tif.h" />
<ClInclude Include="..\backend\tif_lzw.h" />
<ClInclude Include="..\backend\zfiletypes.h" />
<ClInclude Include="..\backend\zint.h" />
<ClInclude Include="..\backend\zintconfig.h" />
</ItemGroup>

View File

@ -621,6 +621,10 @@
RelativePath="..\backend\tif_lzw.h"
>
</File>
<File
RelativePath="..\backend\zfiletypes.h"
>
</File>
<File
RelativePath="..\backend\zint.h"
>

View File

@ -390,6 +390,7 @@
<ClInclude Include="..\..\backend\stdint_msvc.h" />
<ClInclude Include="..\..\backend\tif.h" />
<ClInclude Include="..\..\backend\tif_lzw.h" />
<ClInclude Include="..\..\backend\zfiletypes.h" />
<ClInclude Include="..\..\backend\zint.h" />
<ClInclude Include="..\..\backend\zintconfig.h" />
</ItemGroup>

View File

@ -158,6 +158,7 @@
<ClInclude Include="..\..\backend\stdint_msvc.h" />
<ClInclude Include="..\..\backend\tif.h" />
<ClInclude Include="..\..\backend\tif_lzw.h" />
<ClInclude Include="..\..\backend\zfiletypes.h" />
<ClInclude Include="..\..\backend\zint.h" />
<ClInclude Include="..\..\backend\zintconfig.h" />
</ItemGroup>

View File

@ -211,6 +211,7 @@
<ClInclude Include="..\..\backend\stdint_msvc.h" />
<ClInclude Include="..\..\backend\tif.h" />
<ClInclude Include="..\..\backend\tif_lzw.h" />
<ClInclude Include="..\..\backend\zfiletypes.h" />
<ClInclude Include="..\..\backend\zint.h" />
<ClInclude Include="..\..\backend\zintconfig.h" />
</ItemGroup>