mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add GS1 support to Aztec Code
This commit is contained in:
parent
c7affa89de
commit
2dd4f31da4
@ -47,25 +47,42 @@ void insert(char binary_string[], int posn, char newbit)
|
|||||||
binary_string[posn] = newbit;
|
binary_string[posn] = newbit;
|
||||||
}
|
}
|
||||||
|
|
||||||
int aztec_text_process(unsigned char source[], char binary_string[])
|
int aztec_text_process(unsigned char source[], char binary_string[], int gs1)
|
||||||
{ /* Encode input data into a binary string */
|
{ /* Encode input data into a binary string */
|
||||||
int i, j, k, bytes;
|
int i, j, k, bytes;
|
||||||
int charmap[ustrlen(source)], typemap[ustrlen(source)], maplength;
|
int charmap[ustrlen(source)], typemap[ustrlen(source)], maplength;
|
||||||
int curtable, newtable, lasttable, chartype;
|
int curtable, newtable, lasttable, chartype;
|
||||||
int blockmap[2][ustrlen(source)], blocks;
|
int blockmap[2][ustrlen(source)], blocks;
|
||||||
|
|
||||||
|
|
||||||
/* Lookup input string in encoding table */
|
/* Lookup input string in encoding table */
|
||||||
|
maplength = 0;
|
||||||
|
if((gs1) && (i == 0)) {
|
||||||
|
/* Add FNC1 to beginning of GS1 messages */
|
||||||
|
charmap[maplength] = 0;
|
||||||
|
typemap[maplength] = 8;
|
||||||
|
maplength++;
|
||||||
|
charmap[maplength] = 400;
|
||||||
|
typemap[maplength] = 8;
|
||||||
|
maplength++;
|
||||||
|
}
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < ustrlen(source); i++) {
|
||||||
if(source[i] > 127) {
|
if(source[i] > 127) {
|
||||||
charmap[i] = source[i];
|
charmap[maplength] = source[i];
|
||||||
typemap[i] = BINARY;
|
typemap[maplength] = BINARY;
|
||||||
} else {
|
} else {
|
||||||
charmap[i] = AztecSymbolChar[source[i]];
|
charmap[maplength] = AztecSymbolChar[source[i]];
|
||||||
typemap[i] = AztecCodeSet[source[i]];
|
typemap[maplength] = AztecCodeSet[source[i]];
|
||||||
}
|
}
|
||||||
|
if((gs1) && (source[i] == '[')) {
|
||||||
|
/* FNC1 represented by FLG(0) */
|
||||||
|
charmap[maplength] = 0;
|
||||||
|
typemap[maplength] = 8;
|
||||||
|
maplength++;
|
||||||
|
charmap[maplength] = 400;
|
||||||
|
typemap[maplength] = 8;
|
||||||
|
}
|
||||||
|
maplength++;
|
||||||
}
|
}
|
||||||
maplength = ustrlen(source);
|
|
||||||
|
|
||||||
/* Look for double character encoding possibilities */
|
/* Look for double character encoding possibilities */
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -522,7 +539,11 @@ int aztec_text_process(unsigned char source[], char binary_string[])
|
|||||||
case LOWER:
|
case LOWER:
|
||||||
case MIXED:
|
case MIXED:
|
||||||
case PUNC:
|
case PUNC:
|
||||||
concat(binary_string, hexbit[charmap[i]]);
|
if(charmap[i] >= 400) {
|
||||||
|
concat(binary_string, tribit[charmap[i] - 400]);
|
||||||
|
} else {
|
||||||
|
concat(binary_string, hexbit[charmap[i]]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case DIGIT:
|
case DIGIT:
|
||||||
concat(binary_string, pentbit[charmap[i]]);
|
concat(binary_string, pentbit[charmap[i]]);
|
||||||
@ -556,12 +577,13 @@ int aztec(struct zint_symbol *symbol, unsigned char source[])
|
|||||||
unsigned int data_part[1500], ecc_part[840];
|
unsigned int data_part[1500], ecc_part[840];
|
||||||
unsigned char desc_data[4], desc_ecc[6];
|
unsigned char desc_data[4], desc_ecc[6];
|
||||||
int err_code, ecc_level, compact, data_length, data_maxsize, codeword_size, adjusted_length;
|
int err_code, ecc_level, compact, data_length, data_maxsize, codeword_size, adjusted_length;
|
||||||
int remainder, padbits, count;
|
int remainder, padbits, count, gs1;
|
||||||
|
|
||||||
memset(binary_string,0,20000);
|
memset(binary_string,0,20000);
|
||||||
memset(adjusted_string,0,20000);
|
memset(adjusted_string,0,20000);
|
||||||
|
|
||||||
err_code = aztec_text_process(source, binary_string);
|
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
|
||||||
|
err_code = aztec_text_process(source, binary_string, gs1);
|
||||||
|
|
||||||
if(err_code != 0) {
|
if(err_code != 0) {
|
||||||
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters [921]");
|
strcpy(symbol->errtxt, "Input too long or too many extended ASCII characters [921]");
|
||||||
|
@ -245,6 +245,8 @@ static char *pentbit[32] = {"0000", "0001", "0010", "0011", "0100", "0101", "011
|
|||||||
"1010", "1011", "1100", "1101", "1110", "1111"
|
"1010", "1011", "1100", "1101", "1110", "1111"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static char *tribit[8] = {"000", "001", "010", "011", "100", "101", "110", "111"};
|
||||||
|
|
||||||
static int AztecSizes[32] = { /* Codewords per symbol */
|
static int AztecSizes[32] = { /* Codewords per symbol */
|
||||||
21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790,
|
21, 48, 60, 88, 120, 156, 196, 240, 230, 272, 316, 364, 416, 470, 528, 588, 652, 720, 790,
|
||||||
864, 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664
|
864, 940, 1020, 920, 992, 1066, 1144, 1224, 1306, 1392, 1480, 1570, 1664
|
||||||
|
@ -90,7 +90,7 @@ int gs1_verify(struct zint_symbol *symbol, unsigned char source[], char reduced[
|
|||||||
ai_latch = 0;
|
ai_latch = 0;
|
||||||
for(i = 0; i < ustrlen(source); i++) {
|
for(i = 0; i < ustrlen(source); i++) {
|
||||||
ai_length += j;
|
ai_length += j;
|
||||||
if((j == 1) && ((source[i] < '0') || (source[i] > '9'))) { ai_latch = 1; }
|
if(((j == 1) && (source[i] != ']')) && ((source[i] < '0') || (source[i] > '9'))) { ai_latch = 1; }
|
||||||
if(source[i] == '[') { bracket_level++; j = 1; }
|
if(source[i] == '[') { bracket_level++; j = 1; }
|
||||||
if(source[i] == ']') {
|
if(source[i] == ']') {
|
||||||
bracket_level--;
|
bracket_level--;
|
||||||
|
@ -201,6 +201,7 @@ int gs1_compliant(int symbology)
|
|||||||
case BARCODE_RSS14_OMNI_CC:
|
case BARCODE_RSS14_OMNI_CC:
|
||||||
case BARCODE_RSS_EXPSTACK_CC:
|
case BARCODE_RSS_EXPSTACK_CC:
|
||||||
case BARCODE_CODE16K:
|
case BARCODE_CODE16K:
|
||||||
|
case BARCODE_AZTEC:
|
||||||
result = 1;
|
result = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user