MAXICODE: Zero-pad US postcodes that lack "+4" (Annex B.1.4a)

Adapted from OkapiBarcode, with stricter interpretation (only pad
  if "+4" totally absent), props Daniel Gredler
gs1: update to latest gs1-syntax-dictionary (linter mm -> mi)
bwipp: update to latest
This commit is contained in:
gitlost 2024-10-09 18:25:38 +01:00
parent c1666cf350
commit 752c1fae5d
6 changed files with 96 additions and 50 deletions

View File

@ -395,8 +395,8 @@ static int yymmdd(const unsigned char *data, int data_len, int offset, int min,
return 1;
}
/* Check for a time HHMM */
static int hhmm(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no,
/* Check for a time HHMI */
static int hhmi(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no,
int *p_err_posn, char err_msg[50], const int length_only) {
(void)max;
@ -452,8 +452,8 @@ static int hh(const unsigned char *data, int data_len, int offset, int min, int
return 1;
}
/* Check for a time MM (minutes) */
static int mm(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no,
/* Check for a time MI (minutes) */
static int mi(const unsigned char *data, int data_len, int offset, int min, int max, int *p_err_no,
int *p_err_posn, char err_msg[50], const int length_only) {
(void)max;

View File

@ -290,16 +290,16 @@ static int n1_yesno(const unsigned char *data,
&& yesno(data, data_len, 0, 1, 1, p_err_no, p_err_posn, err_msg, 0);
}
/* N6,yymmd0 N4,hhmm (Used by NOT BEF DEL DT, NOT AFT DEL DT) */
static int n6_yymmd0_n4_hhmm(const unsigned char *data,
/* N6,yymmd0 N4,hhmi (Used by NOT BEF DEL DT, NOT AFT DEL DT) */
static int n6_yymmd0_n4_hhmi(const unsigned char *data,
const int data_len, int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 10
&& yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmi(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmd0(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
&& hhmi(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* N6,yymmdd (Used by REL DATE, FIRST FREEZE DATE) */
@ -328,16 +328,16 @@ static int n13(const unsigned char *data,
&& numeric(data, data_len, 0, 13, 13, p_err_no, p_err_posn, err_msg);
}
/* N6,yymmdd N4,hhmm (Used by EXPIRY TIME) */
static int n6_yymmdd_n4_hhmm(const unsigned char *data,
/* N6,yymmdd N4,hhmi (Used by EXPIRY TIME) */
static int n6_yymmdd_n4_hhmi(const unsigned char *data,
const int data_len, int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 10
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmi(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg)
&& hhmm(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
&& hhmi(data, data_len, 6, 4, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* N..4 (Used by ACTIVE POTENCY) */
@ -380,16 +380,16 @@ static int x__2(const unsigned char *data,
&& cset82(data, data_len, 0, 1, 2, p_err_no, p_err_posn, err_msg);
}
/* N6,yymmdd [N4],hhmm (Used by TEST BY DATE) */
static int n6_yymmdd__n4__hhmm(const unsigned char *data,
/* N6,yymmdd [N4],hhmi (Used by TEST BY DATE) */
static int n6_yymmdd__n4__hhmi(const unsigned char *data,
const int data_len, int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 6 && data_len <= 10
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmm(data, data_len, 6, 0, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmi(data, data_len, 6, 0, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 0, 4, p_err_no, p_err_posn, err_msg)
&& hhmm(data, data_len, 6, 0, 4, p_err_no, p_err_posn, err_msg, 0);
&& hhmi(data, data_len, 6, 0, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* N3,iso3166999 X..27 (Used by PROCESSOR # 0, PROCESSOR # 1, PROCESSOR # 2, PROCESSOR # 3, PROCESSOR # 4, PROC...) */
@ -456,16 +456,16 @@ static int n8_yyyymmdd(const unsigned char *data,
&& yyyymmdd(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 0);
}
/* N8,yyyymmdd N4,hhmm (Used by DOB TIME) */
static int n8_yyyymmdd_n4_hhmm(const unsigned char *data,
/* N8,yyyymmdd N4,hhmi (Used by DOB TIME) */
static int n8_yyyymmdd_n4_hhmi(const unsigned char *data,
const int data_len, int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len == 12
&& yyyymmdd(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmm(data, data_len, 8, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hhmi(data, data_len, 8, 4, 4, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg)
&& yyyymmdd(data, data_len, 0, 8, 8, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 8, 4, 4, p_err_no, p_err_posn, err_msg)
&& hhmm(data, data_len, 8, 4, 4, p_err_no, p_err_posn, err_msg, 0);
&& hhmi(data, data_len, 8, 4, 4, p_err_no, p_err_posn, err_msg, 0);
}
/* N1,iso5218 (Used by BIO SEX) */
@ -559,20 +559,20 @@ static int x__34_iban(const unsigned char *data,
&& iban(data, data_len, 0, 1, 34, p_err_no, p_err_posn, err_msg, 0);
}
/* N6,yymmdd N2,hh [N2],mm [N2],ss (Used by PROD TIME) */
static int n6_yymmdd_n2_hh__n2__mm__n2__ss(const unsigned char *data,
/* N6,yymmdd N2,hh [N2],mi [N2],ss (Used by PROD TIME) */
static int n6_yymmdd_n2_hh__n2__mi__n2__ss(const unsigned char *data,
const int data_len, int *p_err_no, int *p_err_posn, char err_msg[50]) {
return data_len >= 8 && data_len <= 12
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& hh(data, data_len, 6, 2, 2, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& mm(data, data_len, 8, 0, 2, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& mi(data, data_len, 8, 0, 2, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& ss(data, data_len, 10, 0, 2, p_err_no, p_err_posn, err_msg, 1 /*length_only*/)
&& numeric(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg)
&& yymmdd(data, data_len, 0, 6, 6, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 6, 2, 2, p_err_no, p_err_posn, err_msg)
&& hh(data, data_len, 6, 2, 2, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 8, 0, 2, p_err_no, p_err_posn, err_msg)
&& mm(data, data_len, 8, 0, 2, p_err_no, p_err_posn, err_msg, 0)
&& mi(data, data_len, 8, 0, 2, p_err_no, p_err_posn, err_msg, 0)
&& numeric(data, data_len, 10, 0, 2, p_err_no, p_err_posn, err_msg)
&& ss(data, data_len, 10, 0, 2, p_err_no, p_err_posn, err_msg, 0);
}
@ -850,7 +850,7 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
return n1_yesno(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4324 || ai == 4325) {
return n6_yymmd0_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
return n6_yymmd0_n4_hhmi(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 4326) {
return n6_yymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
@ -868,7 +868,7 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
return x__30(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7003) {
return n6_yymmdd_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
return n6_yymmdd_n4_hhmi(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7004) {
return n__4(data, data_len, p_err_no, p_err_posn, err_msg);
@ -892,7 +892,7 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
return x__2(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7011) {
return n6_yymmdd__n4__hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
return n6_yymmdd__n4__hhmi(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai >= 7020 && ai <= 7022) {
return x__20(data, data_len, p_err_no, p_err_posn, err_msg);
@ -928,7 +928,7 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
return n8_yyyymmdd(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7251) {
return n8_yyyymmdd_n4_hhmm(data, data_len, p_err_no, p_err_posn, err_msg);
return n8_yyyymmdd_n4_hhmi(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 7252) {
return n1_iso5218(data, data_len, p_err_no, p_err_posn, err_msg);
@ -973,7 +973,7 @@ static int gs1_lint(const int ai, const unsigned char *data, const int data_len,
return x__34_iban(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8008) {
return n6_yymmdd_n2_hh__n2__mm__n2__ss(data, data_len, p_err_no, p_err_posn, err_msg);
return n6_yymmdd_n2_hh__n2__mi__n2__ss(data, data_len, p_err_no, p_err_posn, err_msg);
}
if (ai == 8009) {
return x__50(data, data_len, p_err_no, p_err_posn, err_msg);

View File

@ -1,7 +1,7 @@
/* maxicode.c - Handles MaxiCode */
/*
libzint - the open source barcode library
Copyright (C) 2010-2023 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2010-2024 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -613,6 +613,12 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
return ZINT_ERROR_INVALID_DATA;
}
}
if (countrycode == 840 && postcode_len == 5) {
/* Annex B, section B.1, paragraph 4.a, "In the case of country code 840, if the "+4" is unknown,
then fill with zeroes" (adapted from OkaiBarcode, stricter interpretation, props Daniel Gredler) */
memcpy(postcode + 5, "0000", 5); /* Include NUL char */
postcode_len = 9;
}
maxi_do_primary_2(maxi_codeword, postcode, postcode_len, countrycode, service);
} else {
/* Just truncate and space-pad */

View File

@ -395,7 +395,42 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101101000001111000100110"
"110110100000010000001011110011"
},
/* 3*/ { -1, 3, -1, { 0, 0, "" }, "CEN", -1, "B1050056999", 0, 33, 30, 1, "ISO/IEC 16023:2000 B.1 Example (primary only given, data arbitrary); verified manually against tec-it",
/* 3*/ { ESCAPE_MODE, 2, 96, { 0, 0, "" }, "1Z00004951\\GUPSN\\G06X610\\G159\\G1234567\\G1/1\\G\\GY\\G634 ALPHA DR\\GPITTSBURGH\\GPA\\R\\E", -1, "15238840001", 0, 33, 30, 0, "OkapiBarcode zero-pad postcode lacking +4 (US 840 only), ISO/IEC 16023:2000 Annex B.1.4a; BWIPP different encodation",
"110101110110111110111111101111"
"010101010111000011011000010010"
"110110110001001010101010010011"
"111000101010101111111111111100"
"001111000010110010011000000011"
"001001110010101010100000000000"
"111011111110111111101111111110"
"100110000011001001110000001010"
"010001100010101010101001110001"
"110111101111010000011011111100"
"001100111111000000001010101001"
"101110100000000001010011011000"
"101010010010000000010110111100"
"111101110000000000010011100010"
"101010110000000000000110011101"
"001000010000000000001100011110"
"010011001000000000001000001010"
"000000101000000000001010000010"
"000100001100000000000010101010"
"000010010100000000000100110010"
"100000111100000000010001100011"
"101000101000000000111110100000"
"001000001110100101011010100101"
"011001111110011001010100001000"
"000010100010110001010101011010"
"100111000011111000001001011000"
"110010001001010010101100011101"
"001001110101110100011001110010"
"011111010011101100111101010011"
"111111101111101010101101111000"
"101001110101110111010111000011"
"010110101101000001111000100110"
"110110100000010000001011110011"
},
/* 4*/ { -1, 3, -1, { 0, 0, "" }, "CEN", -1, "B1050056999", 0, 33, 30, 1, "ISO/IEC 16023:2000 B.1 Example (primary only given, data arbitrary); verified manually against tec-it",
"000000010101010101010101010111"
"001011000000000000000000000010"
"111001101010101010101010101000"
@ -430,7 +465,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010010001001110010000101000010"
"010001011010000011010010011100"
},
/* 4*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, { 0, 0, "" }, "Comité Européen de Normalisation\034rue de Stassart 36\034B-1050 BRUXELLES\034TEL +3225196811", -1, "", 0, 33, 30, 0, "ISO/IEC 16023:2000 Example F.5 **NOT SAME** uses different encodation (2 Shift A among other things); BWIPP different encodation again",
/* 5*/ { UNICODE_MODE | ESCAPE_MODE, -1, -1, { 0, 0, "" }, "Comité Européen de Normalisation\034rue de Stassart 36\034B-1050 BRUXELLES\034TEL +3225196811", -1, "", 0, 33, 30, 0, "ISO/IEC 16023:2000 Example F.5 **NOT SAME** uses different encodation (2 Shift A among other things); BWIPP different encodation again",
"010010100010110000000100001111"
"001010001100110110111110100110"
"001010011100101010011100100000"
@ -465,7 +500,7 @@ static void test_encode(const testCtx *const p_ctx) {
"001011110011100001001001101100"
"000010111011111010110011000011"
},
/* 5*/ { -1, -1, -1, { 0, 0, "" }, "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", -1, "", 0, 33, 30, 1, "Numeric compaction, verified manually against tec-it",
/* 6*/ { -1, -1, -1, { 0, 0, "" }, "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999", -1, "", 0, 33, 30, 1, "Numeric compaction, verified manually against tec-it",
"010111101101010111101101010111"
"111011110110111011110110111010"
"001111111101001111111101001100"
@ -500,7 +535,7 @@ static void test_encode(const testCtx *const p_ctx) {
"111010101011001101111001011010"
"011110011111000011101011111011"
},
/* 6*/ { -1, 5, -1, { 0, 0, "" }, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\037\237\240\242\243\244\245\246\247\251\255\256\266\225\226\227\230\231\232\233\234\235\236", 51, "", 0, 33, 30, 1, "Mode 5 set E",
/* 7*/ { -1, 5, -1, { 0, 0, "" }, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\037\237\240\242\243\244\245\246\247\251\255\256\266\225\226\227\230\231\232\233\234\235\236", 51, "", 0, 33, 30, 1, "Mode 5 set E",
"000000000000000000101010101011"
"100101010111111111000000001010"
"110010011100100111001001110010"
@ -535,7 +570,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100111110000101000000001110100"
"100101010010100000010101000111"
},
/* 7*/ { -1, 6, -1, { 0, 0, "" }, "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\241\250\253\257\260\264\267\270\273\277\212\213\214\215\216\217\220\221\222\223\224", -1, "", 0, 33, 30, 1, "Mode 6 set D",
/* 8*/ { -1, 6, -1, { 0, 0, "" }, "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\241\250\253\257\260\264\267\270\273\277\212\213\214\215\216\217\220\221\222\223\224", -1, "", 0, 33, 30, 1, "Mode 6 set D",
"000000000000000000101010101011"
"100101010111111111000000001010"
"110010011100100111001001110001"
@ -570,7 +605,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011111001010000101000011000110"
"101111010010011100100011110010"
},
/* 8*/ { -1, 6, -1, { 0, 0, "" }, "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\252\254\261\262\263\265\271\272\274\275\276\200\201\202\203\204\205\206\207\210\211", -1, "", 0, 33, 30, 1, "Mode 6 set C",
/* 9*/ { -1, 6, -1, { 0, 0, "" }, "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\252\254\261\262\263\265\271\272\274\275\276\200\201\202\203\204\205\206\207\210\211", -1, "", 0, 33, 30, 1, "Mode 6 set C",
"000000000000000000101010101011"
"100101010111111111000000001010"
"110010011100100111001001110001"
@ -605,7 +640,7 @@ static void test_encode(const testCtx *const p_ctx) {
"011111001010000101000011000110"
"101111010010011100100011110010"
},
/* 9*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "`abcdefghijklmnopqrstuvwxyz\034\\G\\R{}~\177;<=>?[\\\\]^_ ,./:@!|", -1, "", 0, 33, 30, 1, "Mode 4 Set B",
/* 10*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "`abcdefghijklmnopqrstuvwxyz\034\\G\\R{}~\177;<=>?[\\\\]^_ ,./:@!|", -1, "", 0, 33, 30, 1, "Mode 4 Set B",
"000000000000000010101010101011"
"010101011111111100000000101010"
"001001110010011100100111001000"
@ -640,7 +675,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100100110011010101001011100100"
"001000101111010000111000010101"
},
/* 10*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "\\rABCDEFGHIJKLMNOPQRSTUVWXYZ\034\\G\\R \"#$%&'()*+,-./0123456789:", -1, "", 0, 33, 30, 1, "Mode 4 Set A",
/* 11*/ { UNICODE_MODE | ESCAPE_MODE, 4, -1, { 0, 0, "" }, "\\rABCDEFGHIJKLMNOPQRSTUVWXYZ\034\\G\\R \"#$%&'()*+,-./0123456789:", -1, "", 0, 33, 30, 1, "Mode 4 Set A",
"000000000000001010101010101011"
"010101111111110000000010101010"
"100111001001110010011100100101"
@ -675,7 +710,7 @@ static void test_encode(const testCtx *const p_ctx) {
"110111010000000001010000100110"
"101001001010011101111100111011"
},
/* 11*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDabcdAabcABabcABCabcABCDaABCabABCabcABCéa", -1, "", 0, 33, 30, 1, "Mode 4 LCHB SHA 2SHA 3SHA LCHA SHB LCHB 3SHA 3SHA SHD",
/* 12*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDabcdAabcABabcABCabcABCDaABCabABCabcABCéa", -1, "", 0, 33, 30, 1, "Mode 4 LCHB SHA 2SHA 3SHA LCHA SHB LCHB 3SHA 3SHA SHD",
"110000000011000000000011000011"
"010000000001000000000001000000"
"111010011100100110011110100101"
@ -710,7 +745,7 @@ static void test_encode(const testCtx *const p_ctx) {
"110001000010011110111101111000"
"011010011011111110001000000010"
},
/* 12*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ1", -1, "", 0, 33, 30, 1, "Mode 4 LCKC LCHA",
/* 13*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ1", -1, "", 0, 33, 30, 1, "Mode 4 LCKC LCHA",
"010101010101010101010101010111"
"000000000000000000000000000000"
"101010101010101010101010101010"
@ -745,7 +780,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101111010110101010111100"
"010100000000010110101010010100"
},
/* 13*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ123456789", -1, "", 0, 33, 30, 1, "Mode 4 LCKC NS",
/* 14*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ÀÁÂÃ123456789", -1, "", 0, 33, 30, 1, "Mode 4 LCKC NS",
"111110110101010101010101010111"
"111010010000000000000000000000"
"000010011010101010101010101000"
@ -780,7 +815,7 @@ static void test_encode(const testCtx *const p_ctx) {
"000000111100011110100001110000"
"101000000010100111001011110101"
},
/* 14*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "àáâã1", -1, "", 0, 33, 30, 1, "Mode 4 LCKD LCHA",
/* 15*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "àáâã1", -1, "", 0, 33, 30, 1, "Mode 4 LCKD LCHA",
"010101010101010101010101010111"
"000000000000000000000000000000"
"101010101010101010101010101010"
@ -815,7 +850,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101111010110101010111100"
"010100000000010110101010010100"
},
/* 15*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥1", -1, "", 0, 33, 30, 1, "Mode 4 LCKE LCHA",
/* 16*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥1", -1, "", 0, 33, 30, 1, "Mode 4 LCKE LCHA",
"010101010101010101010101010111"
"000000000000000000000000000000"
"101010101010101010101010101010"
@ -850,7 +885,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010110101111010110101010111100"
"010100000000010110101010010100"
},
/* 16*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥123456789", -1, "", 0, 33, 30, 1, "Mode 4 LCKE NS",
/* 17*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "¢£¤¥123456789", -1, "", 0, 33, 30, 1, "Mode 4 LCKE NS",
"111110110101010101010101010111"
"111010010000000000000000000000"
"000010011010101010101010101000"
@ -885,7 +920,7 @@ static void test_encode(const testCtx *const p_ctx) {
"000000111100011110100001110000"
"101000000010100111001011110101"
},
/* 17*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDE12abcde1ÀÁÂ⣤¥1àáâãabcde123A123456789àáâ㢣¤¥abc", -1, "", 0, 33, 30, 1, "Mode 4 mixed sets",
/* 18*/ { UNICODE_MODE, 4, -1, { 0, 0, "" }, "ABCDE12abcde1ÀÁÂ⣤¥1àáâãabcde123A123456789àáâ㢣¤¥abc", -1, "", 0, 33, 30, 1, "Mode 4 mixed sets",
"000000001111111100000000111111"
"000010100100111100000000111100"
"011100101110000000100111010100"
@ -920,7 +955,7 @@ static void test_encode(const testCtx *const p_ctx) {
"100011000001110011101110101000"
"001001110010111101100100010001"
},
/* 18*/ { UNICODE_MODE, 4, -1, { 3, 7, "" }, "THIS IS A 91 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, APPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "Mode 4 Structured Append",
/* 19*/ { UNICODE_MODE, 4, -1, { 3, 7, "" }, "THIS IS A 91 CHARACTER CODE SET A MESSAGE THAT FILLS A MODE 4, APPENDED, MAXICODE SYMBOL...", -1, "", 0, 33, 30, 1, "Mode 4 Structured Append",
"010001111101000000100000100011"
"000000010000000100000000101000"
"001000101000110010011011001000"
@ -955,7 +990,7 @@ static void test_encode(const testCtx *const p_ctx) {
"010101011101100110111011100100"
"011001000011110011011110111010"
},
/* 19*/ { UNICODE_MODE, 3, -1, { 1, 8, "" }, "COMMISSION FOR EUROPEAN NORMALIZATION, RUE DE STASSART 36, B-1050 BRUXELLES", -1, "B1050056999", 0, 33, 30, 1, "Mode 3 Structured Append",
/* 20*/ { UNICODE_MODE, 3, -1, { 1, 8, "" }, "COMMISSION FOR EUROPEAN NORMALIZATION, RUE DE STASSART 36, B-1050 BRUXELLES", -1, "B1050056999", 0, 33, 30, 1, "Mode 3 Structured Append",
"010000000000001010000000010011"
"001000111111010000011111001000"
"101111111010101111101101000101"

View File

@ -3933,7 +3933,7 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
char *escaped = is_escaped ? (char *) z_alloca(expected_len + 1) : NULL;
char *hibc = is_hibc ? (char *) z_alloca(expected_len + 2 + 1) : NULL;
char *maxi = symbology == BARCODE_MAXICODE && primary
? (char *) z_alloca(expected_len + strlen(primary) + 6 + 9 + 1) : NULL;
? (char *) z_alloca(expected_len + strlen(primary) + 4 + 6 + 9 + 1) : NULL;
char *vin = is_vin_international ? (char *) z_alloca(expected_len + 1 + 1) : NULL;
char *c25inter = have_c25inter ? (char *) z_alloca(expected_len + 13 + 1 + 1) : NULL;
char *upcean = is_upcean ? (char *) z_alloca(expected_len + 1 + 1) : NULL;
@ -4045,8 +4045,13 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
sprintf(maxi + maxi_len, "%-6.*s\035%.*s\035%.*s\035", primary_len - 6, primary,
3, primary + primary_len - 6, 3, primary + primary_len - 3);
} else {
sprintf(maxi + maxi_len, "%.*s\035%.*s\035%.*s\035", primary_len - 6, primary,
3, primary + primary_len - 6, 3, primary + primary_len - 3);
if (primary_len == 11 && primary[5] == '8' && primary[6] == '4' && primary[7] == '0') {
sprintf(maxi + maxi_len, "%.*s0000\035%.*s\035%.*s\035", primary_len - 6, primary,
3, primary + primary_len - 6, 3, primary + primary_len - 3);
} else {
sprintf(maxi + maxi_len, "%.*s\035%.*s\035%.*s\035", primary_len - 6, primary,
3, primary + primary_len - 6, 3, primary + primary_len - 3);
}
}
#else
sprintf(maxi + maxi_len, "%.*s\035%.*s\035%.*s\035", primary_len - 6, primary,