diff --git a/backend/blockf.c b/backend/blockf.c index e6a90bdc..7c086455 100644 --- a/backend/blockf.c +++ b/backend/blockf.c @@ -57,12 +57,13 @@ static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322", "411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232", "2331112"}; -int parunmodd(unsigned char llyth); +int parunmodd(unsigned char llyth, char nullchar); void grwp(int *indexliste); void dxsmooth(int *indexliste); -int a3_convert(unsigned char source) { +int a3_convert(unsigned char source, char nullchar) { /* Annex A section 3 */ + if(source == nullchar) { return 64; } if(source < 32) { return source + 64; } if((source >= 32) && (source <= 127)) { return source - 32; } if((source >= 128) && (source <= 159)) { return (source - 128) + 64; } @@ -70,8 +71,13 @@ int a3_convert(unsigned char source) { return (source - 128) - 32; } -int character_subset_select(unsigned char source[], int input_position) { +int character_subset_select(unsigned char source[], int input_position, char nullchar) { /* Section 4.5.2 - Determining the Character Subset Selector in a Row */ + if(source[input_position] == nullchar) { + /* NULL character */ + return MODEA; + } + if((source[input_position] >= '0') && (source[input_position + 1] <= '9')) { /* Rule 1 */ return MODEC; @@ -91,7 +97,7 @@ int character_subset_select(unsigned char source[], int input_position) { return MODEB; } -int data_encode_blockf(unsigned char source[], int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode) +int data_encode_blockf(unsigned char source[], int subset_selector[], int blockmatrix[][62], int *columns_needed, int *rows_needed, int *final_mode, char nullchar) { int i, input_position, input_length, current_mode, current_row, error_number; int column_position, c, done, exit_status; @@ -112,7 +118,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm if(column_position == 0) { /* The Beginning of a row */ c = (*columns_needed); - current_mode = character_subset_select(source, input_position); + current_mode = character_subset_select(source, input_position, nullchar); subset_selector[current_row] = current_mode; } @@ -121,15 +127,15 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm /* Ensure that there is sufficient encodation capacity to continue (using the rules of Annex B.2). */ switch(current_mode) { case MODEA: /* Table B1 applies */ - if(parunmodd(source[input_position]) == ABORC) { - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + if(parunmodd(source[input_position], nullchar) == ABORC) { + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; done = 1; } - if((parunmodd(source[input_position]) == SHIFTB) && (c == 1)) { + if((parunmodd(source[input_position], nullchar) == SHIFTB) && (c == 1)) { /* Needs two symbols */ blockmatrix[current_row][column_position] = 100; /* Code B */ column_position++; @@ -161,15 +167,15 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } break; case MODEB: /* Table B2 applies */ - if(parunmodd(source[input_position]) == ABORC) { - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + if(parunmodd(source[input_position], nullchar) == ABORC) { + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; done = 1; } - if((parunmodd(source[input_position]) == SHIFTA) && (c == 1)) { + if((parunmodd(source[input_position], nullchar) == SHIFTA) && (c == 1)) { /* Needs two symbols */ blockmatrix[current_row][column_position] = 101; /* Code A */ column_position++; @@ -201,7 +207,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } break; case MODEC: /* Table B3 applies */ - if((parunmodd(source[input_position]) != ABORC) && (c == 1)) { + if((parunmodd(source[input_position], nullchar) != ABORC) && (c == 1)) { /* Needs two symbols */ blockmatrix[current_row][column_position] = 101; /* Code A */ column_position++; @@ -209,7 +215,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm done = 1; } - if(((parunmodd(source[input_position]) == ABORC) && (parunmodd(source[input_position + 1]) != ABORC)) + if(((parunmodd(source[input_position], nullchar) == ABORC) && (parunmodd(source[input_position + 1], nullchar) != ABORC)) && (c == 1)) { /* Needs two symbols */ blockmatrix[current_row][column_position] = 101; /* Code A */ @@ -234,7 +240,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if(((parunmodd(source[input_position]) == AORB) || (parunmodd(source[input_position]) == SHIFTA)) && (current_mode == MODEA)) { + if(((parunmodd(source[input_position], nullchar) == AORB) || (parunmodd(source[input_position], nullchar) == SHIFTA)) && (current_mode == MODEA)) { /* Annex B section 1 rule 2 */ /* If in Code Subset A and the next data character can be encoded in Subset A encode the next character. */ @@ -244,7 +250,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -253,7 +259,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if(((parunmodd(source[input_position]) == AORB) || (parunmodd(source[input_position]) == SHIFTB)) && (current_mode == MODEB)) { + if(((parunmodd(source[input_position], nullchar) == AORB) || (parunmodd(source[input_position], nullchar) == SHIFTB)) && (current_mode == MODEB)) { /* Annex B section 1 rule 3 */ /* If in Code Subset B and the next data character can be encoded in subset B, encode the next character. */ @@ -263,7 +269,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -272,7 +278,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if(((parunmodd(source[input_position]) == ABORC) && (parunmodd(source[input_position + 1]) == ABORC)) && (current_mode == MODEC)) { + if(((parunmodd(source[input_position], nullchar) == ABORC) && (parunmodd(source[input_position + 1], nullchar) == ABORC)) && (current_mode == MODEC)) { /* Annex B section 1 rule 4 */ /* If in Code Subset C and the next data are 2 digits, encode them. */ blockmatrix[current_row][column_position] = (ctoi(source[input_position]) * 10) + ctoi(source[input_position + 1]); @@ -284,7 +290,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if(((current_mode == MODEA) || (current_mode == MODEB)) && (parunmodd(source[input_position]) == ABORC)) { + if(((current_mode == MODEA) || (current_mode == MODEB)) && (parunmodd(source[input_position], nullchar) == ABORC)) { /* Count the number of numeric digits */ /* If 4 or more numeric data characters occur together when in subsets A or B: a. If there is an even number of numeric data characters, insert a Code C character before the @@ -292,7 +298,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm b. If there is an odd number of numeric data characters, insert a Code Set C character immedi- ately after the first numeric digit to change to subset C. */ i = 0; - do { i++; } while(parunmodd(source[input_position + i]) == ABORC); + do { i++; } while(parunmodd(source[input_position + i], nullchar) == ABORC); i--; if(i >= 4) { @@ -309,14 +315,14 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm current_mode = MODEC; } else { /* Annex B section 1 rule 5b */ - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; } done = 1; } else { - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -326,7 +332,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if((current_mode == MODEB) && (parunmodd(source[input_position]) == SHIFTA)) { + if((current_mode == MODEB) && (parunmodd(source[input_position], nullchar) == SHIFTA)) { /* Annex B section 1 rule 6 */ /* When in subset B and an ASCII control character occurs in the data: a. If there is a lower case character immediately following the control character, insert a Shift @@ -343,7 +349,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -358,7 +364,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -369,14 +375,14 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if((current_mode == MODEA) && (parunmodd(source[input_position]) == SHIFTB)) { + if((current_mode == MODEA) && (parunmodd(source[input_position], nullchar) == SHIFTB)) { /* Annex B section 1 rule 7 */ /* When in subset A and a lower case character occurs in the data: a. If following that character, a control character occurs in the data before the occurrence of another lower case character, insert a Shift character before the lower case character. b. Otherwise, insert a Code B character before the lower case character to change to subset B. */ - if((parunmodd(source[input_position + 1]) == SHIFTA) && - (parunmodd(source[input_position + 2]) == SHIFTB)) { + if((parunmodd(source[input_position + 1], nullchar) == SHIFTA) && + (parunmodd(source[input_position + 2], nullchar) == SHIFTB)) { /* Annex B section 1 rule 7a */ blockmatrix[current_row][column_position] = 98; /* Shift */ column_position++; @@ -387,7 +393,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -402,7 +408,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -413,8 +419,8 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm } if(done == 0) { - if((current_mode == MODEC) && ((parunmodd(source[input_position]) != ABORC) || - (parunmodd(source[input_position + 1]) != ABORC))) { + if((current_mode == MODEC) && ((parunmodd(source[input_position], nullchar) != ABORC) || + (parunmodd(source[input_position + 1], nullchar) != ABORC))) { /* Annex B section 1 rule 8 */ /* When in subset C and a non-numeric character (or a single digit) occurs in the data, insert a Code A or Code B character before that character, following rules 8a and 8b to determine between code @@ -422,7 +428,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm a. If an ASCII control character (eg NUL) occurs in the data before any lower case character, use Code A. b. Otherwise use Code B. */ - if(parunmodd(source[input_position]) == SHIFTA) { + if(parunmodd(source[input_position], nullchar) == SHIFTA) { /* Annex B section 1 rule 8a */ blockmatrix[current_row][column_position] = 101; /* Code A */ column_position++; @@ -433,7 +439,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -449,7 +455,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm column_position++; c--; } - blockmatrix[current_row][column_position] = a3_convert(source[input_position]); + blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar); column_position++; c--; input_position++; @@ -570,7 +576,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[]) estimate_codelength = 0.0; last_mode = AORB; /* Codablock always starts with Code A */ for(i = 0; i < input_length; i++) { - this_mode = parunmodd(source[i]); + this_mode = parunmodd(source[i], symbol->nullchar); if(this_mode != last_mode) { estimate_codelength += 1.0; } @@ -597,7 +603,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[]) } /* Encode the data */ - error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode); + error_number = data_encode_blockf(source, subset_selector, blockmatrix, &columns_needed, &rows_needed, &final_mode, symbol->nullchar); if(error_number > 0) { if(error_number == ERROR_TOO_LONG) { strcpy(symbol->errtxt, "Input data too long [743]"); diff --git a/backend/code.c b/backend/code.c index bdbdf3fd..0e29f2c2 100644 --- a/backend/code.c +++ b/backend/code.c @@ -326,13 +326,22 @@ int ec39(struct zint_symbol *symbol, unsigned char source[]) /* Creates a buffer string and places control characters into it */ for(i = 0; i < ustrlen(source); i++) { ascii_value = source[i]; - concat((char*)buffer, EC39Ctrl[ascii_value]); + if(ascii_value == symbol->nullchar) { + concat((char*)buffer, EC39Ctrl[0]); + } else { + concat((char*)buffer, EC39Ctrl[ascii_value]); + } } /* Then sends the buffer to the C39 function */ error_number = c39(symbol, buffer); strcpy(symbol->text, (char*)source); + for(i = 0; i < strlen(symbol->text); i++) { + if(symbol->text[i] == symbol->nullchar) { + symbol->text[i] = ' '; + } + } return error_number; } @@ -377,7 +386,11 @@ int c93(struct zint_symbol *symbol, unsigned char source[]) /* Message Content */ for(i = 0; i < ustrlen(source); i++) { ascii_value = source[i]; - concat(buffer, C93Ctrl[ascii_value]); + if(ascii_value == symbol->nullchar) { + concat(buffer, C93Ctrl[0]); + } else { + concat(buffer, C93Ctrl[ascii_value]); + } } /* Now we can check the true length of the barcode */ @@ -446,5 +459,10 @@ int c93(struct zint_symbol *symbol, unsigned char source[]) source[h + 2] = '\0'; expand(symbol, dest); strcpy(symbol->text, (char*)source); + for(i = 0; i < strlen(symbol->text); i++) { + if(symbol->text[i] == symbol->nullchar) { + symbol->text[i] = ' '; + } + } return error_number; } diff --git a/backend/code128.c b/backend/code128.c index a11fb5b5..89b6d884 100644 --- a/backend/code128.c +++ b/backend/code128.c @@ -57,11 +57,12 @@ static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322", "2331112"}; /* Code 128 character encodation - Table 1 */ -int parunmodd(unsigned char llyth) +int parunmodd(unsigned char llyth, char nullchar) { int modd; modd = 0; + if(llyth == nullchar) { return SHIFTA; } if(llyth <= 31) { modd = SHIFTA; } if((llyth >= 32) && (llyth <= 95)) { modd = AORB; } if((llyth >= 48) && (llyth <= 57)) { modd = ABORC; } @@ -136,10 +137,17 @@ void dxsmooth(int *indexliste) } -void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars) +void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars, char nullchr) { /* Translate Code 128 Set A characters into barcodes */ /* This set handles all control characters NULL to US */ + if(source == nullchr) { /* Handle NULL character substitution */ + concat(dest, C128Table[64]); + values[(*bar_chars)] = 64; + (*bar_chars)++; + return; + } + if(source > 127) { if(source < 160) { concat(dest, C128Table[(source - 128) + 64]); @@ -252,7 +260,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[]) indexliste = 0; indexchaine = 0; - mode = parunmodd(source[indexchaine]); + mode = parunmodd(source[indexchaine], symbol->nullchar); if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) { mode = AORB; } @@ -266,7 +274,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[]) while ((list[1][indexliste] == mode) && (indexchaine < sourcelen)) { list[0][indexliste]++; indexchaine++; - mode = parunmodd(source[indexchaine]); + mode = parunmodd(source[indexchaine], symbol->nullchar); if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) { mode = AORB; } @@ -507,7 +515,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[]) switch(set[read]) { /* Encode data characters */ case 'a': - case 'A': c128_set_a(source[read], dest, values, &bar_characters); + case 'A': c128_set_a(source[read], dest, values, &bar_characters, symbol->nullchar); read++; break; case 'b': @@ -523,12 +531,15 @@ int code_128(struct zint_symbol *symbol, unsigned char source[]) /* check digit calculation */ total_sum = 0; + /*for(i = 0; i < bar_characters; i++) { + printf("%d\n", values[i]); + }*/ + for(i = 0; i < bar_characters; i++) { if(i > 0) { values[i] *= i; - } total_sum += values[i]; } @@ -538,6 +549,11 @@ int code_128(struct zint_symbol *symbol, unsigned char source[]) concat(dest, C128Table[106]); expand(symbol, dest); strcpy(symbol->text, (char*)source); + for(i = 0; i < strlen(symbol->text); i++) { + if(symbol->text[i] == symbol->nullchar) { + symbol->text[i] = ' '; + } + } return errornum; } @@ -634,7 +650,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[]) indexliste = 0; indexchaine = 0; - mode = parunmodd(reduced[indexchaine]); + mode = parunmodd(reduced[indexchaine], 0x00); if(reduced[indexchaine] == '[') { mode = ABORC; } @@ -648,7 +664,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[]) while ((list[1][indexliste] == mode) && (indexchaine < strlen(reduced))) { list[0][indexliste]++; indexchaine++; - mode = parunmodd(reduced[indexchaine]); + mode = parunmodd(reduced[indexchaine], 0x00); if(reduced[indexchaine] == '[') { if(indexchaine % 2 == 0) { mode = ABORC; @@ -780,7 +796,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[]) if(reduced[read] != '[') { switch(set[read]) { /* Encode data characters */ - case 'A': c128_set_a(reduced[read], dest, values, &bar_characters); + case 'A': c128_set_a(reduced[read], dest, values, &bar_characters, 0x00); read++; break; case 'B': c128_set_b(reduced[read], dest, values, &bar_characters); diff --git a/backend/code16k.c b/backend/code16k.c index fe869443..938a84b7 100644 --- a/backend/code16k.c +++ b/backend/code16k.c @@ -65,12 +65,18 @@ static char *C16KStartStop[8] = {"3211", "2221", "2122", "1411", "1132", "1231", static int C16KStartValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7}; static int C16KStopValues[16] = {0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 0, 1, 2, 3}; -int parunmodd(unsigned char llyth); +int parunmodd(unsigned char llyth, char nullchar); void grwp(int *indexliste); void dxsmooth(int *indexliste); -void c16k_set_a(unsigned char source, unsigned int values[], unsigned int *bar_chars) +void c16k_set_a(unsigned char source, unsigned int values[], unsigned int *bar_chars, char nullchar) { + if(source == nullchar) { + values[(*bar_chars)] = 64; + (*bar_chars)++; + return; + } + if(source > 127) { if(source < 160) { values[(*bar_chars)] = source + 64 - 128; @@ -164,7 +170,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[]) indexliste = 0; indexchaine = 0; - mode = parunmodd(source[indexchaine]); + mode = parunmodd(source[indexchaine], symbol->nullchar); for(i = 0; i < 160; i++) { list[0][i] = 0; @@ -175,7 +181,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[]) while ((list[1][indexliste] == mode) && (indexchaine < input_length)) { list[0][indexliste]++; indexchaine++; - mode = parunmodd(source[indexchaine]); + mode = parunmodd(source[indexchaine], symbol->nullchar); } indexliste++; } while (indexchaine < input_length); @@ -385,7 +391,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[]) switch(set[read]) { /* Encode data characters */ - case 'A': c16k_set_a(source[read], values, &bar_characters); + case 'A': c16k_set_a(source[read], values, &bar_characters, symbol->nullchar); read++; break; case 'B': c16k_set_b(source[read], values, &bar_characters); diff --git a/backend/composite.c b/backend/composite.c index 028920f6..d4c0aff0 100644 --- a/backend/composite.c +++ b/backend/composite.c @@ -360,7 +360,7 @@ int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width) chainemc[mclength] = 920; mclength++; - byteprocess(chainemc, &mclength, data_string, 0, length, 0); + byteprocess(chainemc, &mclength, data_string, 0, length, 0, 0x00); /* Now figure out which variant of the symbol to use and load values accordingly */ @@ -585,7 +585,7 @@ int cc_c(struct zint_symbol *symbol, unsigned char source[], int cc_width, int e chainemc[mclength] = 920; /* CC-C identifier */ mclength++; - byteprocess(chainemc, &mclength, data_string, 0, length, 0); + byteprocess(chainemc, &mclength, data_string, 0, length, 0, 0x00); chainemc[0] = mclength; diff --git a/backend/dm200.c b/backend/dm200.c index 0e08b37c..be089a2e 100644 --- a/backend/dm200.c +++ b/backend/dm200.c @@ -326,8 +326,8 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl, char *enco t[tp++] = 238; enc = newenc; } - t[tp++] = (v >> 8); - t[tp++] = (v & 0xFF); + t[tp++] = (int)(v / 256); + t[tp++] = v % 256; p -= 3; out[0] = out[3]; out[1] = out[4]; @@ -700,10 +700,10 @@ static char *encmake(int l, unsigned char *s, int *lenp, char exact) if (bl && b == E_BINARY) enc[p][(int)b].s += enc[p + 1][(int)b].s; /* - * fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf \ - * (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); \ - * fprintf (stderr, "\n"); - */ + fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf \ + (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); \ + fprintf (stderr, "\n"); + */ } encoding = safemalloc(l + 1); p = 0; @@ -752,6 +752,8 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s int lend, *lenp; struct ecc200matrix_s *matrix; memset(binary, 0, sizeof(binary)); + unsigned char adjusted[barcodelen]; + int i; lend = 0; lenp = &lend; @@ -789,6 +791,15 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s case 30: W = 48; H = 16; break; default: W = 0; H = 0; break; } + + /* Adjust for NULL characters */ + for(i = 0; i < barcodelen; i++) { + if(barcode[i] == symbol->nullchar) { + adjusted[i] = 0x00; + } else { + adjusted[i] = barcode[i]; + } + } // encoding if (W) { // known size @@ -799,10 +810,10 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s } if (!encoding) { int len; - char *e = encmake(barcodelen, barcode, &len, 1); + char *e = encmake(barcodelen, adjusted, &len, 1); if (e && len != matrix->bytes) { // try not an exact fit free(e); - e = encmake(barcodelen, barcode, &len, 0); + e = encmake(barcodelen, adjusted, &len, 0); if (len > matrix->bytes) { strcpy(symbol->errtxt, "Cannot make barcode fit"); if (e) free (e); @@ -814,21 +825,22 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s } else { // find a suitable encoding if (encoding == NULL) - encoding = encmake(barcodelen, barcode, NULL, 1); + encoding = encmake(barcodelen, adjusted, NULL, 1); if (encoding) { // find one that fits chosen encoding for (matrix = ecc200matrix; matrix->W; matrix++) - if (ecc200encode(binary, matrix->bytes, barcode, barcodelen, encoding, 0)) + if (ecc200encode(binary, matrix->bytes, adjusted, barcodelen, encoding, 0)) { break; + } } else { int len; char *e; - e = encmake(barcodelen, barcode, &len, 1); + e = encmake(barcodelen, adjusted, &len, 1); for (matrix = ecc200matrix; matrix->W && matrix->bytes != len; matrix++) ; if (e && !matrix->W) { // try for non exact fit free(e); - e = encmake(barcodelen, barcode, &len, 0); + e = encmake(barcodelen, adjusted, &len, 0); for (matrix = ecc200matrix; matrix->W && matrix->bytes < len; matrix++) ; } encoding = e; @@ -840,11 +852,12 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s W = matrix->W; H = matrix->H; } - if (!ecc200encode(binary, matrix->bytes, barcode, barcodelen, encoding, lenp)) { + if (!ecc200encode(binary, matrix->bytes, adjusted, barcodelen, encoding, lenp)) { strcpy(symbol->errtxt, "Barcode too long"); free(encoding); return ERROR_INVALID_OPTION; } + // ecc code ecc200(binary, matrix->bytes, matrix->datablock, matrix->rsblock); { // placement diff --git a/backend/library.c b/backend/library.c index 941300f4..ca75a811 100644 --- a/backend/library.c +++ b/backend/library.c @@ -54,6 +54,7 @@ struct zint_symbol *ZBarcode_Create() symbol->row_height[i] = 0; } return symbol; + symbol->nullchar = 0x00; } diff --git a/backend/maxicode.c b/backend/maxicode.c index dc49f7b4..0c46df1c 100644 --- a/backend/maxicode.c +++ b/backend/maxicode.c @@ -112,7 +112,7 @@ void maxi_bump(int set[], int character[], int bump_posn) } } -int maxi_text_process(int mode, unsigned char source[]) +int maxi_text_process(int mode, unsigned char source[], char nullchar) { /* Format text according to Appendix A */ @@ -136,8 +136,13 @@ int maxi_text_process(int mode, unsigned char source[]) for (i = 0; i < length; i++) { /* Look up characters in table from Appendix A - this gives value and code set for most characters */ - set[i] = maxiCodeSet[source[i]]; - character[i] = maxiSymbolChar[source[i]]; + if(source[i] == nullchar) { + set[i] = maxiCodeSet[0]; + character[i] = maxiSymbolChar[0]; + } else { + set[i] = maxiCodeSet[source[i]]; + character[i] = maxiSymbolChar[source[i]]; + } } /* If a character can be represented in more than one code set, @@ -623,7 +628,7 @@ int maxicode(struct zint_symbol *symbol, unsigned char source[]) maxi_codeword[0] = mode; } - i = maxi_text_process(mode, source); + i = maxi_text_process(mode, source, symbol->nullchar); if(i == ERROR_TOO_LONG ) { strcpy(symbol->errtxt, "Input data too long [574]"); return i; diff --git a/backend/pdf417.c b/backend/pdf417.c index f3edb02f..100beabb 100644 --- a/backend/pdf417.c +++ b/backend/pdf417.c @@ -63,11 +63,15 @@ static int MicroAutosize[56] = int liste[2][1000]; /* global - okay, so I got _almost_ everything local! */ /* 866 */ -int quelmode(char codeascii) +int quelmode(char codeascii, char nullchar) { int mode; mode = BYT; + if(codeascii == nullchar) { + return BYT; + } + if((codeascii >= ' ') && (codeascii <= '~')) { mode = TEX; } if(codeascii == '\t') { mode = TEX; } if(codeascii == '\n') { mode = TEX; } @@ -304,7 +308,7 @@ void textprocess(int *chainemc, int *mclength, char chaine[], int start, int len } /* 671 */ -void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block) +void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block, char nullchar) { int i, j, k, l, longueur; @@ -343,16 +347,26 @@ void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start for(i = 0; i < 8; i++) { shiftup(y_reg); } - - if((chaine[start + j + k] & 0x80) != 0) { y_reg[7] = 1; } - if((chaine[start + j + k] & 0x40) != 0) { y_reg[6] = 1; } - if((chaine[start + j + k] & 0x20) != 0) { y_reg[5] = 1; } - if((chaine[start + j + k] & 0x10) != 0) { y_reg[4] = 1; } - if((chaine[start + j + k] & 0x08) != 0) { y_reg[3] = 1; } - if((chaine[start + j + k] & 0x04) != 0) { y_reg[2] = 1; } - if((chaine[start + j + k] & 0x02) != 0) { y_reg[1] = 1; } - if((chaine[start + j + k] & 0x01) != 0) { y_reg[0] = 1; } + if(chaine[start + j + k] == nullchar) { + y_reg[7] = 0; + y_reg[6] = 0; + y_reg[5] = 0; + y_reg[4] = 0; + y_reg[3] = 0; + y_reg[2] = 0; + y_reg[1] = 0; + y_reg[0] = 0; + } else { + if((chaine[start + j + k] & 0x80) != 0) { y_reg[7] = 1; } + if((chaine[start + j + k] & 0x40) != 0) { y_reg[6] = 1; } + if((chaine[start + j + k] & 0x20) != 0) { y_reg[5] = 1; } + if((chaine[start + j + k] & 0x10) != 0) { y_reg[4] = 1; } + if((chaine[start + j + k] & 0x08) != 0) { y_reg[3] = 1; } + if((chaine[start + j + k] & 0x04) != 0) { y_reg[2] = 1; } + if((chaine[start + j + k] & 0x02) != 0) { y_reg[1] = 1; } + if((chaine[start + j + k] & 0x01) != 0) { y_reg[0] = 1; } + } } for(l = 0; l < 4; l++) { @@ -481,7 +495,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[]) indexliste = 0; indexchaine = 0; - mode = quelmode(chaine[indexchaine]); + mode = quelmode(chaine[indexchaine], symbol->nullchar); for(i = 0; i < 1000; i++) { liste[0][i] = 0; @@ -493,7 +507,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[]) while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) { liste[0][indexliste]++; indexchaine++; - mode = quelmode(chaine[indexchaine]); + mode = quelmode(chaine[indexchaine], symbol->nullchar); } indexliste++; } while (indexchaine < ustrlen(chaine)); @@ -510,7 +524,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[]) textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i); break; case BYT: /* 670 - octet stream mode */ - byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i); + byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i, symbol->nullchar); break; case NUM: /* 712 - numeric mode */ numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i); @@ -766,7 +780,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[]) indexliste = 0; indexchaine = 0; - mode = quelmode(chaine[indexchaine]); + mode = quelmode(chaine[indexchaine], symbol->nullchar); for(i = 0; i < 1000; i++) { liste[0][i] = 0; @@ -778,7 +792,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[]) while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) { liste[0][indexliste]++; indexchaine++; - mode = quelmode(chaine[indexchaine]); + mode = quelmode(chaine[indexchaine], symbol->nullchar); } indexliste++; } while (indexchaine < ustrlen(chaine)); @@ -795,7 +809,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[]) textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i); break; case BYT: /* 670 - octet stream mode */ - byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i); + byteprocess(chainemc, &mclength, chaine, indexchaine, liste[0][i], i, symbol->nullchar); break; case NUM: /* 712 - numeric mode */ numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i); diff --git a/backend/pdf417.h b/backend/pdf417.h index 4e65ecf2..e23c881c 100644 --- a/backend/pdf417.h +++ b/backend/pdf417.h @@ -435,4 +435,4 @@ static char *RAPC[53] = {"", "112231", "121231", "122131", "131131", "131221", " "112213", "112222", "112312", "112321", "111421", "111331", "111322", "111232", "111223", "111133", "111124", "111214", "112114", "121114", "121123", "121132", "112132", "112141" }; -void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block); \ No newline at end of file +void byteprocess(int *chainemc, int *mclength, unsigned char chaine[], int start, int length, int block, char nullchar); \ No newline at end of file diff --git a/backend/telepen.c b/backend/telepen.c index 3715b47b..ae3377da 100644 --- a/backend/telepen.c +++ b/backend/telepen.c @@ -80,7 +80,11 @@ int telepen(struct zint_symbol *symbol, unsigned char source[]) for (i=0; i < ustrlen(source); i++) { ascii_value = source[i]; - concat(dest, TeleTable[ascii_value]); + if(ascii_value == symbol->nullchar) { + concat(dest, TeleTable[0]); + } else { + concat(dest, TeleTable[ascii_value]); + } count += source[i]; } diff --git a/backend/zint.h b/backend/zint.h index 3597e07c..54f0ece0 100644 --- a/backend/zint.h +++ b/backend/zint.h @@ -46,6 +46,7 @@ struct zint_symbol { char encoded_data[178][1000]; int row_height[155]; char errtxt[100]; + char nullchar; }; /* Tbarcode 7 codes */ diff --git a/docs/appxa.html b/docs/appxa.html index 2f859587..9618e67d 100644 --- a/docs/appxa.html +++ b/docs/appxa.html @@ -1,1129 +1,1135 @@ - - - - - Character Encoding - - - - - - - - - - - - - - - -
-

Zint Barcode Generator

-
-

Prev

-
-

Next

-
-
-

A. Character Encoding

-

This section is intended as a quick reference to the character -sets used by Zint. All symbologies use standard ASCII input as shown -in section A.1, but some support extended character support as shown -in the subsequent section.

-

A.1 ASCII Standard

-

The ubiquitous ASCII standard is well known to most computer -users. It's reproduced here for reference.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Hex

-
-

0

-
-

1

-
-

2

-
-

3

-
-

4

-
-

5

-
-

6

-
-

7

-
-

0

-
-

NULL

-
-

DLE

-
-

SPACE

-
-

0

-
-

@

-
-

P

-
-

`

-
-

p

-
-

1

-
-

SOH

-
-

DC1

-
-

!

-
-

1

-
-

A

-
-

Q

-
-

a

-
-

q

-
-

2

-
-

STX

-
-

DC2

-
-

"

-
-

2

-
-

B

-
-

R

-
-

b

-
-

r

-
-

3

-
-

ETX

-
-

DC3

-
-

#

-
-

3

-
-

C

-
-

S

-
-

c

-
-

s

-
-

4

-
-

EOT

-
-

DC4

-
-

$

-
-

4

-
-

D

-
-

Y

-
-

d

-
-

t

-
-

5

-
-

ENQ

-
-

NAK

-
-

%

-
-

5

-
-

E

-
-

U

-
-

e

-
-

u

-
-

6

-
-

ACK

-
-

SYN

-
-

&

-
-

6

-
-

F

-
-

V

-
-

f

-
-

v

-
-

7

-
-

BEL

-
-

ETB

-
-

'

-
-

7

-
-

G

-
-

W

-
-

g

-
-

w

-
-

8

-
-

BS

-
-

CAN

-
-

(

-
-

8

-
-

H

-
-

X

-
-

h

-
-

x

-
-

9

-
-

TAB

-
-

EM

-
-

)

-
-

9

-
-

I

-
-

Y

-
-

i

-
-

y

-
-

A

-
-

LF

-
-

SUB

-
-

*

-
-

:

-
-

J

-
-

Z

-
-

j

-
-

z

-
-

B

-
-

VT

-
-

ESC

-
-

+

-
-

;

-
-

K

-
-

[

-
-

k

-
-

{

-
-

C

-
-

FF

-
-

FS

-
-

,

-
-

<

-
-

L

-
-

\

-
-

l

-
-

|

-
-

D

-
-

CR

-
-

GS

-
-

-

-
-

=

-
-

M

-
-

]

-
-

m

-
-

}

-
-

E

-
-

SO

-
-

RS

-
-

.

-
-

>

-
-

N

-
-

^

-
-

n

-
-

~

-
-

F

-
-

SI

-
-

US

-
-

/

-
-

?

-
-

O

-
-

_

-
-

o

-
-

DEL

-
-
-

-

A.2 Latin Alphabet No 1 (ISO 8859-1)

-

A common extension to the ASCII -standard, Latin-1 is used to expand the range of Code 128 and PDF417 symbols.

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Hex

-
-

8

-
-

9

-
-

A

-
-

B

-
-

C

-
-

D

-
-

E

-
-

F

-
-

0

-
-


-

-
-


-

-
-

NBSP

-
-

°

-
-

À

-
-

Ð

-
-

à

-
-

ð

-
-

1

-
-


-

-
-


-

-
-

¡

-
-

±

-
-

Á

-
-

Ñ

-
-

á

-
-

ñ

-
-

2

-
-


-

-
-


-

-
-

¢

-
-

²

-
-

Â

-
-

Ò

-
-

â

-
-

ò

-
-

3

-
-


-

-
-


-

-
-

£

-
-

³

-
-

Ã

-
-

Ó

-
-

ã

-
-

ó

-
-

4

-
-


-

-
-


-

-
-

¤

-
-

´

-
-

Ä

-
-

Ô

-
-

ä

-
-

ô

-
-

5

-
-


-

-
-


-

-
-

¥

-
-

µ

-
-

Å

-
-

Õ

-
-

å

-
-

õ

-
-

6

-
-


-

-
-


-

-
-

¦

-
-

-
-

Æ

-
-

Ö

-
-

æ

-
-

ö

-
-

7

-
-


-

-
-


-

-
-

§

-
-

·

-
-

Ç

-
-

×

-
-

ç

-
-

÷

-
-

8

-
-


-

-
-


-

-
-

¨

-
-

¸

-
-

È

-
-

Ø

-
-

è

-
-

ø

-
-

9

-
-


-

-
-


-

-
-

©

-
-

¹

-
-

É

-
-

Ù

-
-

é

-
-

ù

-
-

A

-
-


-

-
-


-

-
-

ª

-
-

º

-
-

Ê

-
-

Ú

-
-

ê

-
-

ú

-
-

B

-
-


-

-
-


-

-
-

«

-
-

»

-
-

Ë

-
-

Û

-
-

ë

-
-

û

-
-

C

-
-


-

-
-


-

-
-

¬

-
-

¼

-
-

Ì

-
-

Ü

-
-

ì

-
-

ü

-
-

D

-
-


-

-
-


-

-
-

SHY

-
-

½

-
-

Í

-
-

Ý

-
-

í

-
-

ý

-
-

E

-
-


-

-
-


-

-
-

®

-
-

¾

-
-

Î

-
-

Þ

-
-

î

-
-

þ

-
-

F

-
-


-

-
-


-

-
-

¯

-
-

¿

-
-

Ï

-
-

ß

-
-

ï

-
-

ÿ

-
-
-
- - - - - - - - - - - -
-

Prev

-
-

Home

-
-

Next

-
-

Legal Information

-
-

 

-
-

Appendix B

-
- + + + + + Character Encoding + + + + + + + + + + + + + + + +
+

Zint Barcode Generator

+
+

Prev

+
+

Next

+
+
+

A. Character Encoding

+

This section is intended as a quick reference to the character +sets used by Zint. All symbologies use standard ASCII input as shown +in section A.1, but some support extended character support as shown +in the subsequent section.

+

A.1 ASCII Standard

+

The ubiquitous ASCII standard is well known to most computer +users. It's reproduced here for reference.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Hex

+
+

0

+
+

1

+
+

2

+
+

3

+
+

4

+
+

5

+
+

6

+
+

7

+
+

0

+
+

NULL

+
+

DLE

+
+

SPACE

+
+

0

+
+

@

+
+

P

+
+

`

+
+

p

+
+

1

+
+

SOH

+
+

DC1

+
+

!

+
+

1

+
+

A

+
+

Q

+
+

a

+
+

q

+
+

2

+
+

STX

+
+

DC2

+
+

"

+
+

2

+
+

B

+
+

R

+
+

b

+
+

r

+
+

3

+
+

ETX

+
+

DC3

+
+

#

+
+

3

+
+

C

+
+

S

+
+

c

+
+

s

+
+

4

+
+

EOT

+
+

DC4

+
+

$

+
+

4

+
+

D

+
+

Y

+
+

d

+
+

t

+
+

5

+
+

ENQ

+
+

NAK

+
+

%

+
+

5

+
+

E

+
+

U

+
+

e

+
+

u

+
+

6

+
+

ACK

+
+

SYN

+
+

&

+
+

6

+
+

F

+
+

V

+
+

f

+
+

v

+
+

7

+
+

BEL

+
+

ETB

+
+

'

+
+

7

+
+

G

+
+

W

+
+

g

+
+

w

+
+

8

+
+

BS

+
+

CAN

+
+

(

+
+

8

+
+

H

+
+

X

+
+

h

+
+

x

+
+

9

+
+

TAB

+
+

EM

+
+

)

+
+

9

+
+

I

+
+

Y

+
+

i

+
+

y

+
+

A

+
+

LF

+
+

SUB

+
+

*

+
+

:

+
+

J

+
+

Z

+
+

j

+
+

z

+
+

B

+
+

VT

+
+

ESC

+
+

+

+
+

;

+
+

K

+
+

[

+
+

k

+
+

{

+
+

C

+
+

FF

+
+

FS

+
+

,

+
+

<

+
+

L

+
+

\

+
+

l

+
+

|

+
+

D

+
+

CR

+
+

GS

+
+

-

+
+

=

+
+

M

+
+

]

+
+

m

+
+

}

+
+

E

+
+

SO

+
+

RS

+
+

.

+
+

>

+
+

N

+
+

^

+
+

n

+
+

~

+
+

F

+
+

SI

+
+

US

+
+

/

+
+

?

+
+

O

+
+

_

+
+

o

+
+

DEL

+
+
+



+

+

A.2 Latin Alphabet No 1 (ISO +8859-1)

+

A common extension to the ASCII +standard, Latin-1 is used to expand the range of Code 128, PDF417 and +other symbols. Input strings should be in Unicode format.

+


+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Hex

+
+

8

+
+

9

+
+

A

+
+

B

+
+

C

+
+

D

+
+

E

+
+

F

+
+

0

+
+


+

+
+


+

+
+

NBSP

+
+

°

+
+

À

+
+

Ð

+
+

à

+
+

ð

+
+

1

+
+


+

+
+


+

+
+

¡

+
+

±

+
+

Á

+
+

Ñ

+
+

á

+
+

ñ

+
+

2

+
+


+

+
+


+

+
+

¢

+
+

²

+
+

Â

+
+

Ò

+
+

â

+
+

ò

+
+

3

+
+


+

+
+


+

+
+

£

+
+

³

+
+

Ã

+
+

Ó

+
+

ã

+
+

ó

+
+

4

+
+


+

+
+


+

+
+

¤

+
+

´

+
+

Ä

+
+

Ô

+
+

ä

+
+

ô

+
+

5

+
+


+

+
+


+

+
+

¥

+
+

µ

+
+

Å

+
+

Õ

+
+

å

+
+

õ

+
+

6

+
+


+

+
+


+

+
+

¦

+
+

+
+

Æ

+
+

Ö

+
+

æ

+
+

ö

+
+

7

+
+


+

+
+


+

+
+

§

+
+

·

+
+

Ç

+
+

×

+
+

ç

+
+

÷

+
+

8

+
+


+

+
+


+

+
+

¨

+
+

¸

+
+

È

+
+

Ø

+
+

è

+
+

ø

+
+

9

+
+


+

+
+


+

+
+

©

+
+

¹

+
+

É

+
+

Ù

+
+

é

+
+

ù

+
+

A

+
+


+

+
+


+

+
+

ª

+
+

º

+
+

Ê

+
+

Ú

+
+

ê

+
+

ú

+
+

B

+
+


+

+
+


+

+
+

«

+
+

»

+
+

Ë

+
+

Û

+
+

ë

+
+

û

+
+

C

+
+


+

+
+


+

+
+

¬

+
+

¼

+
+

Ì

+
+

Ü

+
+

ì

+
+

ü

+
+

D

+
+


+

+
+


+

+
+

SHY

+
+

½

+
+

Í

+
+

Ý

+
+

í

+
+

ý

+
+

E

+
+


+

+
+


+

+
+

®

+
+

¾

+
+

Î

+
+

Þ

+
+

î

+
+

þ

+
+

F

+
+


+

+
+


+

+
+

¯

+
+

¿

+
+

Ï

+
+

ß

+
+

ï

+
+

ÿ

+
+
+
+ + + + + + + + + + + +
+

Prev

+
+

Home

+
+

Next

+
+

Legal Information

+
+

 

+
+

Appendix B

+
+



+

+ \ No newline at end of file diff --git a/docs/backend.html b/docs/backend.html index 0a6c0eb6..4651b785 100644 --- a/docs/backend.html +++ b/docs/backend.html @@ -5,7 +5,7 @@ Using the API - + - - - - - - - - - - - -
-

Zint Barcode Generator

-
-

Prev

-
-

Next

-
-
-

5.6 Two-Dimensional Symbols

-

5.6.1 Data Matrix (ISO -16022)

-

Also known as Semacode this symbology was developed in 1989 by -Acuity CiMatrix in partnership with the US DoD and NASA. The symbol -can encode a large amount of data in a small area. Zint supports all -versions of the standard from ISO 16022 as shown in the following -table. ECC200 uses Reed-Solomon error correction and is recommended -for new applications. The different modes are accessed using the -mode= option or by setting -option_1.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Input

-
-

Mode

-
-

Error Correction Capacity

-
-

Recovery Capacity

-
-

1 (default)

-
-

ECC 200

-
-

28 - 62%

-
-

30 - 40%

-
-

2

-
-

ECC 000

-
-

0%

-
-

0%

-
-

3

-
-

ECC 050

-
-

25%

-
-

2.8%

-
-

4

-
-

ECC 080

-
-

33%

-
-

5.5%

-
-

5

-
-

ECC 100

-
-

50%

-
-

12.6%

-
-

6

-
-

ECC 140

-
-

75%

-
-

25%

-
-
-



-

-




-

-

5.6.2 QR Code (ISO 18004)

-

Also known as Quick Response Code this symbology was developed by -Denso. QR Code support in Zint relies on libqrencode (version -2.0.0 or later) which is available from -http://megaui.net/fukuchi/works/qrencode/index.en.html. -Support for QR Code through libzint means that developers only -need to write handlers for one API which covers QR Code as well as -all of the other code symbologies provided by libzint. Four -levels of error correction are available using the security= -option or setting option_1 as -shown in the following table.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Input

-
-

ECC Level

-
-

Error Correction Capacity

-
-

Recovery Capacity

-
-

1

-
-

L (default)

-
-

Approx 20% of symbol

-
-

Approx 7%

-
-

2

-
-

M

-
-

Approx 37% of symbol

-
-

Approx 15%

-
-

3

-
-

Q

-
-

Approx 55% of symbol

-
-

Approx 25%

-
-

4

-
-

H

-
-

Approx 65% of symbol

-
-

Approx 30%

-
-
-



-

-

The size of the symbol can be set by using the vers= -option or setting option_2 to -the QR Code version required (1-40). The maximum capacity of a -(version 40) QR Code symbol is 7089 numeric digits, 4296 alphanumeric -characters or 2953 bytes of data.

-




-

-

5.6.3 Micro QR Code (ISO -18004)

-

A miniature version of the QR Code symbol for short -messages. ECC levels can be selected as for QR Code (above). Micro QR -Code support does not require libqrencode.

-




-

-

5.6.4 Maxicode (ISO 16023)

-

Developed by UPS the Maxicode symbology employs a grid -of hexagons surrounding a 'bulls-eye' finder pattern. This symbology -is designed for the identification of parcels. Zint encodes Maxicode -symbols in Mode 2 or Mode 3 depending on the postcode data entered. -In these modes Maxicode symbols are composed of two parts named the -primary and secondary messages. The primary message consists of a -structured data field which includes various data about the package -being sent, the secondary message usually consists of address data in -a data structure. The format of the primary message is given in the -following table: -

-
- - - - - - - - - - - - - - - - - - - - - - - -
-

Characters

-
-

Meaning

-
-

1-9

-
-

Postcode data which can consist of up to 9 - digits (for mode 2) or up to 6 alphanumeric characters (for mode - 3). Remaining unused characters should be filled with the SPACE - character (ASCII 32).

-
-

10-12

-
-

Three digit country code according to ISO 3166 - (see Appendix B).

-
-

13-15

-
-

Three digit service code. This depends on your - parcel courier.

-
-
-



-

-

The primary message can be designated at the command -prompt using the --primary= -switch. The secondary message uses the normal data entry method. For -example:

-

zint -o test.eps -b 57 ---primary='999999999840012' -d 'Secondary Message Here'

-

When using the API the primary message must be placed -in the symbol->primary -string. The secondary is entered in the same way as described in -section 4.2.

-

Modes 4 to 6 can be encoded using the --mode= -switch or by setting option_1. -Modes 4 to 6 do not require a primary message. For example:

-

zint -o test.eps -b 57 ---mode=4 -d 'A MaxiCode Message in Mode 4'

-

Mode 6 is reserved for the maintenance of scanner -hardware and should not be used to encode user data. All modes -support extended ASCII characters and number compression. The maximum -length of text which can be placed in a Maxicode symbol depends on -the type of characters used in the text. Example maximum data lengths -are given in the table below:

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Mode

-
-

Maximum Data Length for Capital Letters

-
-

Maximum Data Length for Numeric Digits

-
-

Number of Error Correction Codewords

-
-

2 (secondary only)

-
-

84

-
-

126

-
-

50

-
-

3 (secondary only)

-
-

84

-
-

126

-
-

50

-
-

4

-
-

93

-
-

135

-
-

50

-
-

5

-
-

77

-
-

110

-
-

66

-
-

6

-
-

93

-
-

135

-
-

50

-
-
-



-

-

PLEASE NOTE that due to the unique style of the -Maxicode symbol not all of the options available for other -symbologies are available. Settings for height, whitespace width, -border width and output options will be ignored. Colour options are -available as with other symbologies. PNG output is set at a -resolution of 12 pixels per millimetre (approx 300 dpi) and uses the -methods set out in Annex J of the ISO/IEC standard.

-




-

-

5.6.5 Aztec Code (ISO 24778)

-

Invented by Andrew Longacre at Welch Allyn Inc in 1995 -the Aztec Code symbol is a matrix symbol with a distinctive bulls-eye -finder pattern. Zint can generate Compact Aztec Code (sometimes -called Small Aztec Code) as well as “full-range” Aztec Code -symbols and by default will automatically select symbol type and size -dependent on the length of the data to be encoded. Error correction -codewords will normally be generated to fill at least 23% of the -symbol. Two options are available to change this behaviour:

-

The size of the symbol can be specified using the ---ver= switch followed by (or -setting option_2 to) a value -between 1 and 36 according to the following table:

-
- - - - - - - - - - - - - - - -
-

Value Entered

-
-

Symbol Generated

-
-

1-4

-
-

Compact Aztec Code with [value] layers

-
-

5-36

-
-

“Full-Range” Aztec Code with [value – - 4] layers

-
-
-



-

-

Note that in symbols which have a specified size the -amount of error correction is dependent on the length of the data -input and Zint will allow error correction capacities as low as 3 -codewords.

-

Alternatively the amount of error correction data can -be specified by use of the --mode= -switch followed by (or setting option_1 -to) a value from the following table:

-
- - - - - - - - - - - - - - - - - - - - - - - -
-

Mode

-
-

Error Correction Capacity

-
-

1

-
-

>10% + 3 codewords

-
-

2

-
-

>23% + 3 codewords

-
-

3

-
-

>36% + 3 codewords

-
-

4

-
-

>50% + 3 codewords

-
-
-



-

-

It is not possible to select both symbol size and error -correction capacity for the same symbol. If both options are selected -then the error correction capacity selection will be ignored.

-

Aztec Code is able to encode any extended ASCII -character data up to a maximum length of approximately 3823 numeric -or 3067 alphabetic characters or 1914 bytes of data.

-




-

-

5.6.6 Aztec Runes

-

A truncated version of compact Aztec Code for encoding -whole integers between 0 and 255. Includes Reed-Solomon error -correction. As defined in ISO/IEC 24778 Annex A.

-




-

-
- - - - - - - - - - - -
-

Prev

-
-

Home

-
-

Next

-
-

4-State Codes

-
-

 

-
-

Markings

-
-



-

- + + + + + Two-Dimensional Symbols + + + + + + + + + + + + + + + +
+

Zint Barcode Generator

+
+

Prev

+
+

Next

+
+
+

5.6 Two-Dimensional Symbols

+

5.6.1 Data Matrix (ISO +16022)

+

Also known as Semacode this symbology was developed in 1989 by +Acuity CiMatrix in partnership with the US DoD and NASA. The symbol +can encode a large amount of data in a small area. Zint supports all +versions of the standard from ISO 16022 as shown in the following +table. ECC200 uses Reed-Solomon error correction and is recommended +for new applications. The different modes are accessed using the +mode= option or by setting +option_1.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Input

+
+

Mode

+
+

Error Correction Capacity

+
+

Recovery Capacity

+
+

1 (default)

+
+

ECC 200

+
+

28 - 62%

+
+

30 - 40%

+
+

2

+
+

ECC 000

+
+

0%

+
+

0%

+
+

3

+
+

ECC 050

+
+

25%

+
+

2.8%

+
+

4

+
+

ECC 080

+
+

33%

+
+

5.5%

+
+

5

+
+

ECC 100

+
+

50%

+
+

12.6%

+
+

6

+
+

ECC 140

+
+

75%

+
+

25%

+
+
+



+

+

The size of the generated symbol can also be adjusted using the +--ver= option or by setting +option_1 as shown in the table +below.

+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Input

+
+

Symbol Size

+
+

Input

+
+

Symbol Size

+
+

1

+
+

10 x 10

+
+

16

+
+

64 x 64

+
+

2

+
+

12 x 12

+
+

17

+
+

72 x 72

+
+

3

+
+

14 x 14

+
+

18

+
+

80 x 80

+
+

4

+
+

16 x 16

+
+

19

+
+

88 x 88

+
+

5

+
+

18 x 18

+
+

20

+
+

96 x 96

+
+

6

+
+

20 x 20

+
+

21

+
+

104 x 104

+
+

7

+
+

22 x 22

+
+

22

+
+

120 x 120

+
+

8

+
+

24 x 24

+
+

23

+
+

132 x 132

+
+

9

+
+

26 x 26

+
+

24

+
+

144 x 144

+
+

10

+
+

32 x 32

+
+

25

+
+

8 x 18

+
+

11

+
+

36 x 36

+
+

26

+
+

8 x 32

+
+

12

+
+

40 x 40

+
+

27

+
+

12 x 26

+
+

13

+
+

44 x 44

+
+

28

+
+

12 x 36

+
+

14

+
+

48 x 48

+
+

29

+
+

16 x 36

+
+

15

+
+

52 x 52

+
+

30

+
+

16 x 48

+
+
+
+
+
+
+
+
+
+



+

+




+

+

5.6.2 QR Code (ISO 18004)

+

Also known as Quick Response Code this symbology was developed by +Denso. QR Code support in Zint relies on libqrencode (version +2.0.0 or later) which is available from +http://megaui.net/fukuchi/works/qrencode/index.en.html. +Support for QR Code through libzint means that developers only +need to write handlers for one API which covers QR Code as well as +all of the other code symbologies provided by libzint. Four +levels of error correction are available using the security= +option or setting option_1 as +shown in the following table.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Input

+
+

ECC Level

+
+

Error Correction Capacity

+
+

Recovery Capacity

+
+

1

+
+

L (default)

+
+

Approx 20% of symbol

+
+

Approx 7%

+
+

2

+
+

M

+
+

Approx 37% of symbol

+
+

Approx 15%

+
+

3

+
+

Q

+
+

Approx 55% of symbol

+
+

Approx 25%

+
+

4

+
+

H

+
+

Approx 65% of symbol

+
+

Approx 30%

+
+
+



+

+

The size of the symbol can be set by using the vers= +option or setting option_2 to +the QR Code version required (1-40). The maximum capacity of a +(version 40) QR Code symbol is 7089 numeric digits, 4296 alphanumeric +characters or 2953 bytes of data.

+




+

+

5.6.3 Micro QR Code (ISO +18004)

+

A miniature version of the QR Code symbol for short +messages. ECC levels can be selected as for QR Code (above). Micro QR +Code support does not require libqrencode.

+




+

+

5.6.4 Maxicode (ISO 16023)

+

Developed by UPS the Maxicode symbology employs a grid +of hexagons surrounding a 'bulls-eye' finder pattern. This symbology +is designed for the identification of parcels. Zint encodes Maxicode +symbols in Mode 2 or Mode 3 depending on the postcode data entered. +In these modes Maxicode symbols are composed of two parts named the +primary and secondary messages. The primary message consists of a +structured data field which includes various data about the package +being sent, the secondary message usually consists of address data in +a data structure. The format of the primary message is given in the +following table: +

+
+ + + + + + + + + + + + + + + + + + + + + + + +
+

Characters

+
+

Meaning

+
+

1-9

+
+

Postcode data which can consist of up to 9 + digits (for mode 2) or up to 6 alphanumeric characters (for mode + 3). Remaining unused characters should be filled with the SPACE + character (ASCII 32).

+
+

10-12

+
+

Three digit country code according to ISO 3166 + (see Appendix B).

+
+

13-15

+
+

Three digit service code. This depends on your + parcel courier.

+
+
+



+

+

The primary message can be designated at the command +prompt using the --primary= +switch. The secondary message uses the normal data entry method. For +example:

+

zint -o test.eps -b 57 +--primary='999999999840012' -d 'Secondary Message Here'

+

When using the API the primary message must be placed +in the symbol->primary +string. The secondary is entered in the same way as described in +section 4.2.

+

Modes 4 to 6 can be encoded using the --mode= +switch or by setting option_1. +Modes 4 to 6 do not require a primary message. For example:

+

zint -o test.eps -b 57 +--mode=4 -d 'A MaxiCode Message in Mode 4'

+

Mode 6 is reserved for the maintenance of scanner +hardware and should not be used to encode user data. All modes +support extended ASCII characters and number compression. The maximum +length of text which can be placed in a Maxicode symbol depends on +the type of characters used in the text. Example maximum data lengths +are given in the table below:

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Mode

+
+

Maximum Data Length for Capital Letters

+
+

Maximum Data Length for Numeric Digits

+
+

Number of Error Correction Codewords

+
+

2 (secondary only)

+
+

84

+
+

126

+
+

50

+
+

3 (secondary only)

+
+

84

+
+

126

+
+

50

+
+

4

+
+

93

+
+

135

+
+

50

+
+

5

+
+

77

+
+

110

+
+

66

+
+

6

+
+

93

+
+

135

+
+

50

+
+
+



+

+

PLEASE NOTE that due to the unique style of the +Maxicode symbol not all of the options available for other +symbologies are available. Settings for height, whitespace width, +border width and output options will be ignored. Colour options are +available as with other symbologies. PNG output is set at a +resolution of 12 pixels per millimetre (approx 300 dpi) and uses the +methods set out in Annex J of the ISO/IEC standard.

+




+

+

5.6.5 Aztec Code (ISO 24778)

+

Invented by Andrew Longacre at Welch Allyn Inc in 1995 +the Aztec Code symbol is a matrix symbol with a distinctive bulls-eye +finder pattern. Zint can generate Compact Aztec Code (sometimes +called Small Aztec Code) as well as “full-range” Aztec Code +symbols and by default will automatically select symbol type and size +dependent on the length of the data to be encoded. Error correction +codewords will normally be generated to fill at least 23% of the +symbol. Two options are available to change this behaviour:

+

The size of the symbol can be specified using the +--ver= switch followed by (or +setting option_2 to) a value +between 1 and 36 according to the following table:

+
+ + + + + + + + + + + + + + + +
+

Value Entered

+
+

Symbol Generated

+
+

1-4

+
+

Compact Aztec Code with [value] layers

+
+

5-36

+
+

“Full-Range” Aztec Code with [value – 4] + layers

+
+
+



+

+

Note that in symbols which have a specified size the +amount of error correction is dependent on the length of the data +input and Zint will allow error correction capacities as low as 3 +codewords.

+

Alternatively the amount of error correction data can +be specified by use of the --mode= +switch followed by (or setting option_1 +to) a value from the following table:

+
+ + + + + + + + + + + + + + + + + + + + + + + +
+

Mode

+
+

Error Correction Capacity

+
+

1

+
+

>10% + 3 codewords

+
+

2

+
+

>23% + 3 codewords

+
+

3

+
+

>36% + 3 codewords

+
+

4

+
+

>50% + 3 codewords

+
+
+



+

+

It is not possible to select both symbol size and error +correction capacity for the same symbol. If both options are selected +then the error correction capacity selection will be ignored.

+

Aztec Code is able to encode any extended ASCII +character data up to a maximum length of approximately 3823 numeric +or 3067 alphabetic characters or 1914 bytes of data.

+




+

+

5.6.6 Aztec Runes

+

A truncated version of compact Aztec Code for encoding +whole integers between 0 and 255. Includes Reed-Solomon error +correction. As defined in ISO/IEC 24778 Annex A.

+




+

+
+ + + + + + + + + + + +
+

Prev

+
+

Home

+
+

Next

+
+

4-State Codes

+
+

 

+
+

Markings

+
+



+

+ \ No newline at end of file diff --git a/frontend/main.c b/frontend/main.c index bdd52d2e..a5939740 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -82,6 +82,7 @@ void usage(void) " --secure=NUMBER (PDF417 and QR Code) Error correction level.\n" " --primary=STRING (Maxicode and Composite) Structured primary message.\n" " --mode=NUMBER (Maxicode and Composite) Set encoding mode.\n" + " --null=NUMBER Character to represent NULL.\n" , ZINT_VERSION); } @@ -153,6 +154,7 @@ int main(int argc, char **argv) {"mode=", 1, 0, 0}, {"primary=", 1, 0, 0}, {"scale=", 1, 0, 0}, + {"null=", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index); @@ -200,6 +202,18 @@ int main(int argc, char **argv) fprintf(stderr, "Border width out of range\n"); } } + if(!strcmp(long_options[option_index].name, "null=")) { + error_number = validator(NESET, optarg); + if(error_number == ERROR_INVALID_DATA) { + fprintf(stderr, "Invalid NULL replacement\n"); + exit(1); + } + if((atoi(optarg) >= 1) && (atoi(optarg) <= 128)) { + my_symbol->nullchar = atoi(optarg); + } else { + fprintf(stderr, "Invalid NULL replacement\n"); + } + } if(!strcmp(long_options[option_index].name, "height=")) { error_number = validator(NESET, optarg); if(error_number == ERROR_INVALID_DATA) {