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,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"