NULL character support

This commit is contained in:
hooper114 2009-01-02 21:09:16 +00:00
parent 1015a11b5a
commit d6df698918
20 changed files with 2286 additions and 1849 deletions

View File

@ -57,12 +57,13 @@ static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322",
"411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232", "411113", "411311", "113141", "114131", "311141", "411131", "211412", "211214", "211232",
"2331112"}; "2331112"};
int parunmodd(unsigned char llyth); int parunmodd(unsigned char llyth, char nullchar);
void grwp(int *indexliste); void grwp(int *indexliste);
void dxsmooth(int *indexliste); void dxsmooth(int *indexliste);
int a3_convert(unsigned char source) { int a3_convert(unsigned char source, char nullchar) {
/* Annex A section 3 */ /* Annex A section 3 */
if(source == nullchar) { return 64; }
if(source < 32) { return source + 64; } if(source < 32) { return source + 64; }
if((source >= 32) && (source <= 127)) { return source - 32; } if((source >= 32) && (source <= 127)) { return source - 32; }
if((source >= 128) && (source <= 159)) { return (source - 128) + 64; } if((source >= 128) && (source <= 159)) { return (source - 128) + 64; }
@ -70,8 +71,13 @@ int a3_convert(unsigned char source) {
return (source - 128) - 32; 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 */ /* 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')) { if((source[input_position] >= '0') && (source[input_position + 1] <= '9')) {
/* Rule 1 */ /* Rule 1 */
return MODEC; return MODEC;
@ -91,7 +97,7 @@ int character_subset_select(unsigned char source[], int input_position) {
return MODEB; 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 i, input_position, input_length, current_mode, current_row, error_number;
int column_position, c, done, exit_status; 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) { if(column_position == 0) {
/* The Beginning of a row */ /* The Beginning of a row */
c = (*columns_needed); 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; 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). */ /* Ensure that there is sufficient encodation capacity to continue (using the rules of Annex B.2). */
switch(current_mode) { switch(current_mode) {
case MODEA: /* Table B1 applies */ case MODEA: /* Table B1 applies */
if(parunmodd(source[input_position]) == ABORC) { if(parunmodd(source[input_position], nullchar) == ABORC) {
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
done = 1; done = 1;
} }
if((parunmodd(source[input_position]) == SHIFTB) && (c == 1)) { if((parunmodd(source[input_position], nullchar) == SHIFTB) && (c == 1)) {
/* Needs two symbols */ /* Needs two symbols */
blockmatrix[current_row][column_position] = 100; /* Code B */ blockmatrix[current_row][column_position] = 100; /* Code B */
column_position++; column_position++;
@ -161,15 +167,15 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
break; break;
case MODEB: /* Table B2 applies */ case MODEB: /* Table B2 applies */
if(parunmodd(source[input_position]) == ABORC) { if(parunmodd(source[input_position], nullchar) == ABORC) {
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
done = 1; done = 1;
} }
if((parunmodd(source[input_position]) == SHIFTA) && (c == 1)) { if((parunmodd(source[input_position], nullchar) == SHIFTA) && (c == 1)) {
/* Needs two symbols */ /* Needs two symbols */
blockmatrix[current_row][column_position] = 101; /* Code A */ blockmatrix[current_row][column_position] = 101; /* Code A */
column_position++; column_position++;
@ -201,7 +207,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
break; break;
case MODEC: /* Table B3 applies */ 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 */ /* Needs two symbols */
blockmatrix[current_row][column_position] = 101; /* Code A */ blockmatrix[current_row][column_position] = 101; /* Code A */
column_position++; column_position++;
@ -209,7 +215,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
done = 1; 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)) { && (c == 1)) {
/* Needs two symbols */ /* Needs two symbols */
blockmatrix[current_row][column_position] = 101; /* Code A */ 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(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 */ /* 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 /* If in Code Subset A and the next data character can be encoded in Subset A encode the next
character. */ character. */
@ -244,7 +250,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -253,7 +259,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
if(done == 0) { 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 */ /* 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 /* If in Code Subset B and the next data character can be encoded in subset B, encode the next
character. */ character. */
@ -263,7 +269,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -272,7 +278,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
if(done == 0) { 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 */ /* Annex B section 1 rule 4 */
/* If in Code Subset C and the next data are 2 digits, encode them. */ /* 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]); 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(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 */ /* Count the number of numeric digits */
/* If 4 or more numeric data characters occur together when in subsets A or B: /* 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 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- 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. */ ately after the first numeric digit to change to subset C. */
i = 0; i = 0;
do { i++; } while(parunmodd(source[input_position + i]) == ABORC); do { i++; } while(parunmodd(source[input_position + i], nullchar) == ABORC);
i--; i--;
if(i >= 4) { if(i >= 4) {
@ -309,14 +315,14 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
current_mode = MODEC; current_mode = MODEC;
} else { } else {
/* Annex B section 1 rule 5b */ /* 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++; column_position++;
c--; c--;
input_position++; input_position++;
} }
done = 1; done = 1;
} else { } else {
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -326,7 +332,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
if(done == 0) { 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 */ /* Annex B section 1 rule 6 */
/* When in subset B and an ASCII control character occurs in the data: /* 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 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++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -358,7 +364,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -369,14 +375,14 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
if(done == 0) { 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 */ /* Annex B section 1 rule 7 */
/* When in subset A and a lower case character occurs in the data: /* 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 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. 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. */ b. Otherwise, insert a Code B character before the lower case character to change to subset B. */
if((parunmodd(source[input_position + 1]) == SHIFTA) && if((parunmodd(source[input_position + 1], nullchar) == SHIFTA) &&
(parunmodd(source[input_position + 2]) == SHIFTB)) { (parunmodd(source[input_position + 2], nullchar) == SHIFTB)) {
/* Annex B section 1 rule 7a */ /* Annex B section 1 rule 7a */
blockmatrix[current_row][column_position] = 98; /* Shift */ blockmatrix[current_row][column_position] = 98; /* Shift */
column_position++; column_position++;
@ -387,7 +393,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -402,7 +408,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -413,8 +419,8 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
} }
if(done == 0) { if(done == 0) {
if((current_mode == MODEC) && ((parunmodd(source[input_position]) != ABORC) || if((current_mode == MODEC) && ((parunmodd(source[input_position], nullchar) != ABORC) ||
(parunmodd(source[input_position + 1]) != ABORC))) { (parunmodd(source[input_position + 1], nullchar) != ABORC))) {
/* Annex B section 1 rule 8 */ /* 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 /* 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 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 a. If an ASCII control character (eg NUL) occurs in the data before any lower case character, use
Code A. Code A.
b. Otherwise use Code B. */ b. Otherwise use Code B. */
if(parunmodd(source[input_position]) == SHIFTA) { if(parunmodd(source[input_position], nullchar) == SHIFTA) {
/* Annex B section 1 rule 8a */ /* Annex B section 1 rule 8a */
blockmatrix[current_row][column_position] = 101; /* Code A */ blockmatrix[current_row][column_position] = 101; /* Code A */
column_position++; column_position++;
@ -433,7 +439,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -449,7 +455,7 @@ int data_encode_blockf(unsigned char source[], int subset_selector[], int blockm
column_position++; column_position++;
c--; c--;
} }
blockmatrix[current_row][column_position] = a3_convert(source[input_position]); blockmatrix[current_row][column_position] = a3_convert(source[input_position], nullchar);
column_position++; column_position++;
c--; c--;
input_position++; input_position++;
@ -570,7 +576,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
estimate_codelength = 0.0; estimate_codelength = 0.0;
last_mode = AORB; /* Codablock always starts with Code A */ last_mode = AORB; /* Codablock always starts with Code A */
for(i = 0; i < input_length; i++) { for(i = 0; i < input_length; i++) {
this_mode = parunmodd(source[i]); this_mode = parunmodd(source[i], symbol->nullchar);
if(this_mode != last_mode) { if(this_mode != last_mode) {
estimate_codelength += 1.0; estimate_codelength += 1.0;
} }
@ -597,7 +603,7 @@ int codablock(struct zint_symbol *symbol, unsigned char source[])
} }
/* Encode the data */ /* 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 > 0) {
if(error_number == ERROR_TOO_LONG) { if(error_number == ERROR_TOO_LONG) {
strcpy(symbol->errtxt, "Input data too long [743]"); strcpy(symbol->errtxt, "Input data too long [743]");

View File

@ -326,13 +326,22 @@ int ec39(struct zint_symbol *symbol, unsigned char source[])
/* Creates a buffer string and places control characters into it */ /* Creates a buffer string and places control characters into it */
for(i = 0; i < ustrlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
ascii_value = 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 */ /* Then sends the buffer to the C39 function */
error_number = c39(symbol, buffer); error_number = c39(symbol, buffer);
strcpy(symbol->text, (char*)source); 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; return error_number;
} }
@ -377,7 +386,11 @@ int c93(struct zint_symbol *symbol, unsigned char source[])
/* Message Content */ /* Message Content */
for(i = 0; i < ustrlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
ascii_value = 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 */ /* 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'; source[h + 2] = '\0';
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); 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; return error_number;
} }

View File

@ -57,11 +57,12 @@ static char *C128Table[107] = {"212222", "222122", "222221", "121223", "121322",
"2331112"}; "2331112"};
/* Code 128 character encodation - Table 1 */ /* Code 128 character encodation - Table 1 */
int parunmodd(unsigned char llyth) int parunmodd(unsigned char llyth, char nullchar)
{ {
int modd; int modd;
modd = 0; modd = 0;
if(llyth == nullchar) { return SHIFTA; }
if(llyth <= 31) { modd = SHIFTA; } if(llyth <= 31) { modd = SHIFTA; }
if((llyth >= 32) && (llyth <= 95)) { modd = AORB; } if((llyth >= 32) && (llyth <= 95)) { modd = AORB; }
if((llyth >= 48) && (llyth <= 57)) { modd = ABORC; } 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 */ { /* Translate Code 128 Set A characters into barcodes */
/* This set handles all control characters NULL to US */ /* 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 > 127) {
if(source < 160) { if(source < 160) {
concat(dest, C128Table[(source - 128) + 64]); concat(dest, C128Table[(source - 128) + 64]);
@ -252,7 +260,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
indexliste = 0; indexliste = 0;
indexchaine = 0; indexchaine = 0;
mode = parunmodd(source[indexchaine]); mode = parunmodd(source[indexchaine], symbol->nullchar);
if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) { if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) {
mode = AORB; mode = AORB;
} }
@ -266,7 +274,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
while ((list[1][indexliste] == mode) && (indexchaine < sourcelen)) { while ((list[1][indexliste] == mode) && (indexchaine < sourcelen)) {
list[0][indexliste]++; list[0][indexliste]++;
indexchaine++; indexchaine++;
mode = parunmodd(source[indexchaine]); mode = parunmodd(source[indexchaine], symbol->nullchar);
if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) { if((symbol->symbology == BARCODE_CODE128B) && (mode == ABORC)) {
mode = AORB; mode = AORB;
} }
@ -507,7 +515,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
switch(set[read]) switch(set[read])
{ /* Encode data characters */ { /* Encode data characters */
case 'a': 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++; read++;
break; break;
case 'b': case 'b':
@ -523,12 +531,15 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
/* check digit calculation */ /* check digit calculation */
total_sum = 0; total_sum = 0;
/*for(i = 0; i < bar_characters; i++) {
printf("%d\n", values[i]);
}*/
for(i = 0; i < bar_characters; i++) for(i = 0; i < bar_characters; i++)
{ {
if(i > 0) if(i > 0)
{ {
values[i] *= i; values[i] *= i;
} }
total_sum += values[i]; total_sum += values[i];
} }
@ -538,6 +549,11 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
concat(dest, C128Table[106]); concat(dest, C128Table[106]);
expand(symbol, dest); expand(symbol, dest);
strcpy(symbol->text, (char*)source); strcpy(symbol->text, (char*)source);
for(i = 0; i < strlen(symbol->text); i++) {
if(symbol->text[i] == symbol->nullchar) {
symbol->text[i] = ' ';
}
}
return errornum; return errornum;
} }
@ -634,7 +650,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
indexliste = 0; indexliste = 0;
indexchaine = 0; indexchaine = 0;
mode = parunmodd(reduced[indexchaine]); mode = parunmodd(reduced[indexchaine], 0x00);
if(reduced[indexchaine] == '[') { if(reduced[indexchaine] == '[') {
mode = ABORC; mode = ABORC;
} }
@ -648,7 +664,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
while ((list[1][indexliste] == mode) && (indexchaine < strlen(reduced))) { while ((list[1][indexliste] == mode) && (indexchaine < strlen(reduced))) {
list[0][indexliste]++; list[0][indexliste]++;
indexchaine++; indexchaine++;
mode = parunmodd(reduced[indexchaine]); mode = parunmodd(reduced[indexchaine], 0x00);
if(reduced[indexchaine] == '[') { if(reduced[indexchaine] == '[') {
if(indexchaine % 2 == 0) { if(indexchaine % 2 == 0) {
mode = ABORC; mode = ABORC;
@ -780,7 +796,7 @@ int ean_128(struct zint_symbol *symbol, unsigned char source[])
if(reduced[read] != '[') { if(reduced[read] != '[') {
switch(set[read]) switch(set[read])
{ /* Encode data characters */ { /* 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++; read++;
break; break;
case 'B': c128_set_b(reduced[read], dest, values, &bar_characters); case 'B': c128_set_b(reduced[read], dest, values, &bar_characters);

View File

@ -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 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}; 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 grwp(int *indexliste);
void dxsmooth(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 > 127) {
if(source < 160) { if(source < 160) {
values[(*bar_chars)] = source + 64 - 128; values[(*bar_chars)] = source + 64 - 128;
@ -164,7 +170,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
indexliste = 0; indexliste = 0;
indexchaine = 0; indexchaine = 0;
mode = parunmodd(source[indexchaine]); mode = parunmodd(source[indexchaine], symbol->nullchar);
for(i = 0; i < 160; i++) { for(i = 0; i < 160; i++) {
list[0][i] = 0; 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)) { while ((list[1][indexliste] == mode) && (indexchaine < input_length)) {
list[0][indexliste]++; list[0][indexliste]++;
indexchaine++; indexchaine++;
mode = parunmodd(source[indexchaine]); mode = parunmodd(source[indexchaine], symbol->nullchar);
} }
indexliste++; indexliste++;
} while (indexchaine < input_length); } while (indexchaine < input_length);
@ -385,7 +391,7 @@ int code16k(struct zint_symbol *symbol, unsigned char source[])
switch(set[read]) switch(set[read])
{ /* Encode data characters */ { /* 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++; read++;
break; break;
case 'B': c16k_set_b(source[read], values, &bar_characters); case 'B': c16k_set_b(source[read], values, &bar_characters);

View File

@ -360,7 +360,7 @@ int cc_b(struct zint_symbol *symbol, unsigned char source[], int cc_width)
chainemc[mclength] = 920; chainemc[mclength] = 920;
mclength++; 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 */ /* 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 */ chainemc[mclength] = 920; /* CC-C identifier */
mclength++; mclength++;
byteprocess(chainemc, &mclength, data_string, 0, length, 0); byteprocess(chainemc, &mclength, data_string, 0, length, 0, 0x00);
chainemc[0] = mclength; chainemc[0] = mclength;

View File

@ -326,8 +326,8 @@ char ecc200encode(unsigned char *t, int tl, unsigned char *s, int sl, char *enco
t[tp++] = 238; t[tp++] = 238;
enc = newenc; enc = newenc;
} }
t[tp++] = (v >> 8); t[tp++] = (int)(v / 256);
t[tp++] = (v & 0xFF); t[tp++] = v % 256;
p -= 3; p -= 3;
out[0] = out[3]; out[0] = out[3];
out[1] = out[4]; 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) if (bl && b == E_BINARY)
enc[p][(int)b].s += enc[p + 1][(int)b].s; enc[p][(int)b].s += enc[p + 1][(int)b].s;
/* /*
* fprintf (stderr, "%d:", p); for (e = 0; e < E_MAX; e++) fprintf \ 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); \ (stderr, " %c*%d/%d", encchr[e], enc[p][e].s, enc[p][e].t); \
* fprintf (stderr, "\n"); fprintf (stderr, "\n");
*/ */
} }
encoding = safemalloc(l + 1); encoding = safemalloc(l + 1);
p = 0; p = 0;
@ -752,6 +752,8 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s
int lend, *lenp; int lend, *lenp;
struct ecc200matrix_s *matrix; struct ecc200matrix_s *matrix;
memset(binary, 0, sizeof(binary)); memset(binary, 0, sizeof(binary));
unsigned char adjusted[barcodelen];
int i;
lend = 0; lend = 0;
lenp = &lend; lenp = &lend;
@ -789,6 +791,15 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s
case 30: W = 48; H = 16; break; case 30: W = 48; H = 16; break;
default: W = 0; H = 0; 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 // encoding
if (W) { // known size if (W) { // known size
@ -799,10 +810,10 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s
} }
if (!encoding) { if (!encoding) {
int len; 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 if (e && len != matrix->bytes) { // try not an exact fit
free(e); free(e);
e = encmake(barcodelen, barcode, &len, 0); e = encmake(barcodelen, adjusted, &len, 0);
if (len > matrix->bytes) { if (len > matrix->bytes) {
strcpy(symbol->errtxt, "Cannot make barcode fit"); strcpy(symbol->errtxt, "Cannot make barcode fit");
if (e) free (e); if (e) free (e);
@ -814,21 +825,22 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s
} else { } else {
// find a suitable encoding // find a suitable encoding
if (encoding == NULL) if (encoding == NULL)
encoding = encmake(barcodelen, barcode, NULL, 1); encoding = encmake(barcodelen, adjusted, NULL, 1);
if (encoding) { // find one that fits chosen encoding if (encoding) { // find one that fits chosen encoding
for (matrix = ecc200matrix; matrix->W; matrix++) 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; break;
}
} else { } else {
int len; int len;
char *e; char *e;
e = encmake(barcodelen, barcode, &len, 1); e = encmake(barcodelen, adjusted, &len, 1);
for (matrix = ecc200matrix; for (matrix = ecc200matrix;
matrix->W && matrix->bytes != len; matrix++) ; matrix->W && matrix->bytes != len; matrix++) ;
if (e && !matrix->W) { // try for non exact fit if (e && !matrix->W) { // try for non exact fit
free(e); free(e);
e = encmake(barcodelen, barcode, &len, 0); e = encmake(barcodelen, adjusted, &len, 0);
for (matrix = ecc200matrix; matrix->W && matrix->bytes < len; matrix++) ; for (matrix = ecc200matrix; matrix->W && matrix->bytes < len; matrix++) ;
} }
encoding = e; encoding = e;
@ -840,11 +852,12 @@ int iec16022ecc200(unsigned char *barcode, int barcodelen, struct zint_symbol *s
W = matrix->W; W = matrix->W;
H = matrix->H; 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"); strcpy(symbol->errtxt, "Barcode too long");
free(encoding); free(encoding);
return ERROR_INVALID_OPTION; return ERROR_INVALID_OPTION;
} }
// ecc code // ecc code
ecc200(binary, matrix->bytes, matrix->datablock, matrix->rsblock); ecc200(binary, matrix->bytes, matrix->datablock, matrix->rsblock);
{ // placement { // placement

View File

@ -54,6 +54,7 @@ struct zint_symbol *ZBarcode_Create()
symbol->row_height[i] = 0; symbol->row_height[i] = 0;
} }
return symbol; return symbol;
symbol->nullchar = 0x00;
} }

View File

@ -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 */ /* 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++) { for (i = 0; i < length; i++) {
/* Look up characters in table from Appendix A - this gives /* Look up characters in table from Appendix A - this gives
value and code set for most characters */ value and code set for most characters */
set[i] = maxiCodeSet[source[i]]; if(source[i] == nullchar) {
character[i] = maxiSymbolChar[source[i]]; 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, /* 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; maxi_codeword[0] = mode;
} }
i = maxi_text_process(mode, source); i = maxi_text_process(mode, source, symbol->nullchar);
if(i == ERROR_TOO_LONG ) { if(i == ERROR_TOO_LONG ) {
strcpy(symbol->errtxt, "Input data too long [574]"); strcpy(symbol->errtxt, "Input data too long [574]");
return i; return i;

View File

@ -63,11 +63,15 @@ static int MicroAutosize[56] =
int liste[2][1000]; /* global - okay, so I got _almost_ everything local! */ int liste[2][1000]; /* global - okay, so I got _almost_ everything local! */
/* 866 */ /* 866 */
int quelmode(char codeascii) int quelmode(char codeascii, char nullchar)
{ {
int mode; int mode;
mode = BYT; mode = BYT;
if(codeascii == nullchar) {
return BYT;
}
if((codeascii >= ' ') && (codeascii <= '~')) { mode = TEX; } if((codeascii >= ' ') && (codeascii <= '~')) { mode = TEX; }
if(codeascii == '\t') { mode = TEX; } if(codeascii == '\t') { mode = TEX; }
if(codeascii == '\n') { mode = TEX; } if(codeascii == '\n') { mode = TEX; }
@ -304,7 +308,7 @@ void textprocess(int *chainemc, int *mclength, char chaine[], int start, int len
} }
/* 671 */ /* 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; 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++) { for(i = 0; i < 8; i++) {
shiftup(y_reg); 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++) { for(l = 0; l < 4; l++) {
@ -481,7 +495,7 @@ int pdf417(struct zint_symbol *symbol, unsigned char chaine[])
indexliste = 0; indexliste = 0;
indexchaine = 0; indexchaine = 0;
mode = quelmode(chaine[indexchaine]); mode = quelmode(chaine[indexchaine], symbol->nullchar);
for(i = 0; i < 1000; i++) { for(i = 0; i < 1000; i++) {
liste[0][i] = 0; 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))) { while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) {
liste[0][indexliste]++; liste[0][indexliste]++;
indexchaine++; indexchaine++;
mode = quelmode(chaine[indexchaine]); mode = quelmode(chaine[indexchaine], symbol->nullchar);
} }
indexliste++; indexliste++;
} while (indexchaine < ustrlen(chaine)); } 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); textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
break; break;
case BYT: /* 670 - octet stream mode */ 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; break;
case NUM: /* 712 - numeric mode */ case NUM: /* 712 - numeric mode */
numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i); 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; indexliste = 0;
indexchaine = 0; indexchaine = 0;
mode = quelmode(chaine[indexchaine]); mode = quelmode(chaine[indexchaine], symbol->nullchar);
for(i = 0; i < 1000; i++) { for(i = 0; i < 1000; i++) {
liste[0][i] = 0; 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))) { while ((liste[1][indexliste] == mode) && (indexchaine < ustrlen(chaine))) {
liste[0][indexliste]++; liste[0][indexliste]++;
indexchaine++; indexchaine++;
mode = quelmode(chaine[indexchaine]); mode = quelmode(chaine[indexchaine], symbol->nullchar);
} }
indexliste++; indexliste++;
} while (indexchaine < ustrlen(chaine)); } 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); textprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);
break; break;
case BYT: /* 670 - octet stream mode */ 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; break;
case NUM: /* 712 - numeric mode */ case NUM: /* 712 - numeric mode */
numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i); numbprocess(chainemc, &mclength, (char*)chaine, indexchaine, liste[0][i], i);

View File

@ -435,4 +435,4 @@ static char *RAPC[53] = {"", "112231", "121231", "122131", "131131", "131221", "
"112213", "112222", "112312", "112321", "111421", "111331", "111322", "111232", "111223", "112213", "112222", "112312", "112321", "111421", "111331", "111322", "111232", "111223",
"111133", "111124", "111214", "112114", "121114", "121123", "121132", "112132", "112141" }; "111133", "111124", "111214", "112114", "121114", "121123", "121132", "112132", "112141" };
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);

View File

@ -80,7 +80,11 @@ int telepen(struct zint_symbol *symbol, unsigned char source[])
for (i=0; i < ustrlen(source); i++) for (i=0; i < ustrlen(source); i++)
{ {
ascii_value = 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]; count += source[i];
} }

View File

@ -46,6 +46,7 @@ struct zint_symbol {
char encoded_data[178][1000]; char encoded_data[178][1000];
int row_height[155]; int row_height[155];
char errtxt[100]; char errtxt[100];
char nullchar;
}; };
/* Tbarcode 7 codes */ /* Tbarcode 7 codes */

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
<TITLE>Using the API</TITLE> <TITLE>Using the API</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)"> <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)">
<META NAME="CREATED" CONTENT="20070730;21081900"> <META NAME="CREATED" CONTENT="20070730;21081900">
<META NAME="CHANGED" CONTENT="20081109;9211000"> <META NAME="CHANGED" CONTENT="20090101;16002700">
<STYLE TYPE="text/css"> <STYLE TYPE="text/css">
<!-- <!--
TD P { color: #000000 } TD P { color: #000000 }
@ -92,8 +92,7 @@ char **argv)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;struct zint_symbol
ZBarcode_Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ZBarcode_Encode_and_Print(my_symbol, ZBarcode_Create();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ZBarcode_Encode_and_Print(my_symbol,
argv[1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;ZBarcode_Delete(my_symbol);<BR>&nbsp;&nbsp;&nbsp;&nbsp;return argv[1]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;ZBarcode_Delete(my_symbol);<BR>&nbsp;&nbsp;&nbsp;&nbsp;return
0;<BR>}</FONT></FONT></P> 0;<BR>}</FONT></FONT></P>
<P><BR><BR> <P>Input strings should be Unicode formatted.</P>
</P>
<P><A NAME="OPTIONS"></A><FONT SIZE=5><B>4.3 Setting Options</B></FONT></P> <P><A NAME="OPTIONS"></A><FONT SIZE=5><B>4.3 Setting Options</B></FONT></P>
<P>So far our application is not very useful unless we plan to only <P>So far our application is not very useful unless we plan to only
make Code 128 barcodes and we don't mind that they only save to make Code 128 barcodes and we don't mind that they only save to
@ -270,6 +269,34 @@ structure consists of the following variables:</P>
<P ALIGN=CENTER>(automatic)</P> <P ALIGN=CENTER>(automatic)</P>
</TD> </TD>
</TR> </TR>
<TR VALIGN=TOP>
<TD WIDTH=151>
<P ALIGN=CENTER><FONT FACE="Courier">scale</FONT></P>
</TD>
<TD WIDTH=162>
<P ALIGN=CENTER>float</P>
</TD>
<TD WIDTH=334>
<P ALIGN=CENTER>Scale factor for adjusting size of image.</P>
</TD>
<TD WIDTH=175>
<P ALIGN=CENTER>1.0</P>
</TD>
</TR>
<TR VALIGN=TOP>
<TD WIDTH=151>
<P ALIGN=CENTER><FONT FACE="Courier">nullchar</FONT></P>
</TD>
<TD WIDTH=162>
<P ALIGN=CENTER>char</P>
</TD>
<TD WIDTH=334>
<P ALIGN=CENTER>Character to substitute for NULL</P>
</TD>
<TD WIDTH=175>
<P ALIGN=CENTER>NULL</P>
</TD>
</TR>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD WIDTH=151> <TD WIDTH=151>
<P ALIGN=CENTER><FONT FACE="Courier">primary</FONT></P> <P ALIGN=CENTER><FONT FACE="Courier">primary</FONT></P>
@ -1026,6 +1053,17 @@ following table. For example</P>
<P ALIGN=CENTER>NVE-18</P> <P ALIGN=CENTER>NVE-18</P>
</TD> </TD>
</TR> </TR>
<TR VALIGN=TOP>
<TD WIDTH=150>
<P ALIGN=CENTER>77</P>
</TD>
<TD WIDTH=382>
<P ALIGN=CENTER><FONT FACE="Courier, monospace">BARCODE_KOREAPOST</FONT></P>
</TD>
<TD WIDTH=366>
<P ALIGN=CENTER>Korea Post</P>
</TD>
</TR>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD WIDTH=150> <TD WIDTH=150>
<P ALIGN=CENTER>79</P> <P ALIGN=CENTER>79</P>

View File

@ -42,7 +42,8 @@ describes how to encode data using the command line front end
program.</P> program.</P>
<P><BR><BR> <P><BR><BR>
</P> </P>
<H1><A NAME="INPUT"></A><FONT SIZE=5><B>3.1 Inputting data</B></FONT></H1> <P><A NAME="INPUT"></A><FONT SIZE=5><B>3.1 Inputting data</B></FONT>
</P>
<P STYLE="font-style: normal">The data to encode can be entered at <P STYLE="font-style: normal">The data to encode can be entered at
the command line using the -d option, for example:</P> the command line using the -d option, for example:</P>
<P STYLE="font-style: normal"><FONT FACE="Courier, monospace"><FONT SIZE=2>zint <P STYLE="font-style: normal"><FONT FACE="Courier, monospace"><FONT SIZE=2>zint
@ -64,6 +65,9 @@ here.png. If an encapsulated Post Script file is needed simply append
the file name with .eps:</P> the file name with .eps:</P>
<P STYLE="font-style: normal"><FONT FACE="Courier, monospace"><FONT SIZE=2>zint <P STYLE="font-style: normal"><FONT FACE="Courier, monospace"><FONT SIZE=2>zint
-o there.eps -d 'This Text'</FONT></FONT></P> -o there.eps -d 'This Text'</FONT></FONT></P>
<P>Output can also be directed to stdout using the --<FONT FACE="Courier, monospace">directeps</FONT>
and --<FONT FACE="Courier, monospace">directpng</FONT> switches for
EPS and PNG output respectively.</P>
<P><BR><BR> <P><BR><BR>
</P> </P>
<P STYLE="font-style: normal"><A NAME="BARTYPE"></A><FONT SIZE=5><B>3.3 <P STYLE="font-style: normal"><A NAME="BARTYPE"></A><FONT SIZE=5><B>3.3
@ -449,6 +453,14 @@ appropriate integer value in the following table.</P>
<P ALIGN=CENTER>NVE-18</P> <P ALIGN=CENTER>NVE-18</P>
</TD> </TD>
</TR> </TR>
<TR VALIGN=TOP>
<TD WIDTH=139>
<P ALIGN=CENTER>77</P>
</TD>
<TD WIDTH=643>
<P ALIGN=CENTER>Korea Post</P>
</TD>
</TR>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD WIDTH=139> <TD WIDTH=139>
<P ALIGN=CENTER>79</P> <P ALIGN=CENTER>79</P>
@ -758,27 +770,23 @@ is only available with PNG output.</FONT></P>
<COL WIDTH=480> <COL WIDTH=480>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD WIDTH=501> <TD WIDTH=501>
<P ALIGN=CENTER><IMG SRC="bar38n.png" NAME="graphics5" ALIGN=BOTTOM WIDTH=200 HEIGHT=118 BORDER=0><BR><BR><BR> <P ALIGN=CENTER><IMG SRC="bar38n.png" NAME="graphics5" ALIGN=BOTTOM WIDTH=200 HEIGHT=118 BORDER=0>
</P> <BR><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=0</FONT></FONT><FONT SIZE=3>
<P ALIGN=CENTER><FONT SIZE=3><FONT FACE="Courier, monospace">--rotate=0</FONT>
(default)</FONT></P> (default)</FONT></P>
</TD> </TD>
<TD WIDTH=480> <TD WIDTH=480>
<P ALIGN=CENTER><IMG SRC="bar38u.png" NAME="graphics6" ALIGN=BOTTOM WIDTH=200 HEIGHT=118 BORDER=0><BR><BR><BR> <P ALIGN=CENTER><IMG SRC="bar38u.png" NAME="graphics6" ALIGN=BOTTOM WIDTH=200 HEIGHT=118 BORDER=0>
</P> <BR><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=180</FONT></FONT></P>
<P ALIGN=CENTER><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=180</FONT></FONT></P>
</TD> </TD>
</TR> </TR>
<TR VALIGN=TOP> <TR VALIGN=TOP>
<TD WIDTH=501> <TD WIDTH=501>
<P ALIGN=CENTER><IMG SRC="bar38l.png" NAME="graphics7" ALIGN=BOTTOM WIDTH=118 HEIGHT=200 BORDER=0><BR><BR><BR> <P ALIGN=CENTER><IMG SRC="bar38l.png" NAME="graphics7" ALIGN=BOTTOM WIDTH=118 HEIGHT=200 BORDER=0>
</P> <BR><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=270</FONT></FONT></P>
<P ALIGN=CENTER><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=270</FONT></FONT></P>
</TD> </TD>
<TD WIDTH=480> <TD WIDTH=480>
<P ALIGN=CENTER><IMG SRC="bar38r.png" NAME="graphics8" ALIGN=BOTTOM WIDTH=118 HEIGHT=200 BORDER=0><BR><BR><BR> <P ALIGN=CENTER><IMG SRC="bar38r.png" NAME="graphics8" ALIGN=BOTTOM WIDTH=118 HEIGHT=200 BORDER=0>
</P> <BR><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=90</FONT></FONT></P>
<P ALIGN=CENTER><FONT FACE="Courier, monospace"><FONT SIZE=3>--rotate=90</FONT></FONT></P>
</TD> </TD>
</TR> </TR>
</TABLE> </TABLE>
@ -787,9 +795,29 @@ is only available with PNG output.</FONT></P>
</DL> </DL>
<P><BR><BR> <P><BR><BR>
</P> </P>
<P><BR><BR> <P STYLE="font-style: normal"><A NAME="SCALE"></A><FONT SIZE=5><B>3.9
Adjusting image size</B></FONT></P>
<P STYLE="font-style: normal">The scale of the image can be altered
using the <FONT FACE="Courier, monospace">--scale=</FONT> option
followed by a multiple of the default x-dimension. For example for
PNG images a scale of 5 will increase the x-dimension to 10 pixels.
Note that Maxicode symbols output as PNG images cannot be scaled in
this way and that text added to a barcode in PNG images does not
change size.
</P> </P>
<P STYLE="font-style: normal"><A NAME="OTHER"></A><FONT SIZE=5><B>3.9 <P STYLE="font-style: normal"><A NAME="NULL"></A><FONT SIZE=5><B>3.10
Handling NULL Characters</B></FONT></P>
<P STYLE="font-style: normal">Some symbologies support encoding of
the NULL character (ASCII 0) normally used to indicate the end of a
character string. To support this functionality the <FONT FACE="Courier, monospace">--null=</FONT>
option allows you to substitute another character for NULL. Enter the
decimal number for the character you wish to substitute. For example
<FONT FACE="Courier, monospace">--null=21</FONT> instructs Zint to
treat the NAK control character as a NULL character. Values between 1
and 128 are valid. This currently applies to Codablock-F, Code 128,
Code 16k, Extended Code 39, Code 93, Maxicode, PDF417, MicroPDF417
and Telepen.</P>
<P STYLE="font-style: normal"><A NAME="OTHER"></A><FONT SIZE=5><B>3.11
Other options</B></FONT></P> Other options</B></FONT></P>
<P STYLE="font-style: normal">Additional options are available which <P STYLE="font-style: normal">Additional options are available which
are specific to certain symbologies. These may, for example, control are specific to certain symbologies. These may, for example, control

View File

@ -59,7 +59,11 @@ the barcode symbologies supported by them.</P>
</DT><DT> </DT><DT>
3.8 <A HREF="frontend.html#ROTATE">Rotating the Symbol</A> 3.8 <A HREF="frontend.html#ROTATE">Rotating the Symbol</A>
</DT><DT> </DT><DT>
3.9 <A HREF="frontend.html#OTHER">Other Options</A> 3.9 <A HREF="frontend.html#SCALE">Adjusting Image Size</A>
</DT><DT>
3.10 <A HREF="frontend.html#NULL">Handling NULL Characters</A>
</DT><DT>
3.11 <A HREF="frontend.html#OTHER">Other Options</A>
</DT></DL> </DT></DL>
<DT> <DT>
4. <A HREF="backend.html">Using the API</A> 4. <A HREF="backend.html">Using the API</A>
@ -179,6 +183,8 @@ the barcode symbologies supported by them.</P>
Truncated</A></DT><DT> Truncated</A></DT><DT>
5.1.12.2 <A HREF="onedim.html#RSSLTD">DataBar Limited</A></DT><DT> 5.1.12.2 <A HREF="onedim.html#RSSLTD">DataBar Limited</A></DT><DT>
5.1.12.3 <A HREF="onedim.html#RSSEXP">DataBar Expanded</A></DT></DL> 5.1.12.3 <A HREF="onedim.html#RSSEXP">DataBar Expanded</A></DT></DL>
<DT>
5.1.13 <A HREF="onedim.html#KOREA">Korea Post</A></DT>
</DL> </DL>
<DT> <DT>
5.2 <A HREF="stacked.html">Stacked Symbologies</A> 5.2 <A HREF="stacked.html">Stacked Symbologies</A>
@ -338,4 +344,4 @@ the barcode symbologies supported by them.</P>
<P><BR><BR> <P><BR><BR>
</P> </P>
</BODY> </BODY>
</HTML> </HTML>

View File

@ -5,7 +5,7 @@
<TITLE>Legal and Version Information</TITLE> <TITLE>Legal and Version Information</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)"> <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)">
<META NAME="CREATED" CONTENT="20070730;21081900"> <META NAME="CREATED" CONTENT="20070730;21081900">
<META NAME="CHANGED" CONTENT="20081118;8481000"> <META NAME="CHANGED" CONTENT="20090101;17540500">
<STYLE TYPE="text/css"> <STYLE TYPE="text/css">
<!-- <!--
TD P { color: #000000 } TD P { color: #000000 }
@ -175,6 +175,12 @@ NVE-18, PZN, Data Matrix, Maxicode and QR Code)</P>
<P>v2.0 - Made corrections to Aztec Code and tested output with <P>v2.0 - Made corrections to Aztec Code and tested output with
bcTester. Added Aztec Runes, Micro QR Code and Data Matrix ECC bcTester. Added Aztec Runes, Micro QR Code and Data Matrix ECC
000-140. Updated e-mail information. 18/11/2008</P> 000-140. Updated e-mail information. 18/11/2008</P>
<P>v2.1 Reinstated Korea Post barcodes, harmonised bind and box
options, moved Unicode handling into backend, added size options to
Data Matrix, added NULL character handling for Codablock-F, Code 128,
Code 16k, Extended Code 39, Code 93, Telepen, Maxicode, PDF417 and
MicroPDF417. Added scale and direct to <FONT FACE="Courier, monospace">stdout</FONT>
options.</P>
<P><A NAME="CREDITS"></A><FONT SIZE=5><B>6.4 Sources of Information</B></FONT></P> <P><A NAME="CREDITS"></A><FONT SIZE=5><B>6.4 Sources of Information</B></FONT></P>
<P>Below is a list of some of the sources used in rough chronological <P>Below is a list of some of the sources used in rough chronological
order:</P> order:</P>

View File

@ -5,7 +5,7 @@
<TITLE>One-Dimensional Symbols</TITLE> <TITLE>One-Dimensional Symbols</TITLE>
<META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)"> <META NAME="GENERATOR" CONTENT="OpenOffice.org 2.4 (Unix)">
<META NAME="CREATED" CONTENT="20070730;21081900"> <META NAME="CREATED" CONTENT="20070730;21081900">
<META NAME="CHANGED" CONTENT="20081019;9043400"> <META NAME="CHANGED" CONTENT="20090101;17585200">
<STYLE TYPE="text/css"> <STYLE TYPE="text/css">
<!-- <!--
TD P { color: #000000 } TD P { color: #000000 }
@ -378,20 +378,22 @@ C</A>). </SPAN><FONT SIZE=3><SPAN STYLE="font-weight: medium">The
following is an example of a valid DataBar Expanded input</SPAN></FONT></P> following is an example of a valid DataBar Expanded input</SPAN></FONT></P>
<P ALIGN=LEFT STYLE="font-weight: medium"><FONT FACE="Courier, monospace"><FONT SIZE=2>zint <P ALIGN=LEFT STYLE="font-weight: medium"><FONT FACE="Courier, monospace"><FONT SIZE=2>zint
--barcode=31 -d &quot;[01]98898765432106[3202]012345[15]991231&quot;</FONT></FONT></P> --barcode=31 -d &quot;[01]98898765432106[3202]012345[15]991231&quot;</FONT></FONT></P>
<P ALIGN=CENTER><IMG SRC="databar.png" NAME="graphics12" ALIGN=LEFT WIDTH=302 HEIGHT=118 BORDER=0><BR CLEAR=LEFT><BR><BR> <P ALIGN=LEFT><IMG SRC="databar.png" NAME="graphics12" ALIGN=LEFT WIDTH=302 HEIGHT=118 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P> </P>
<P ALIGN=LEFT>[1] The zint command line program requires Latin-1 <P ALIGN=LEFT><A NAME="KOREA"></A><FONT SIZE=5><B>5.1.13 Korea Post
characters to be encoded using the UTF-8 system. These are converted Barcode</B></FONT></P>
by the front-end into an extended ASCII string. When using the API <P ALIGN=LEFT>The Korean Postal Barcode is used to encode a six-digit
this type conversion will need to be done before invoking the library number and includes one check digit.</P>
otherwise the data will become corrupted. An example program <P><IMG SRC="korea.png" NAME="korea post" ALIGN=LEFT WIDTH=334 HEIGHT=118 BORDER=0><BR><BR>
<FONT FACE="Courier, monospace">exttest.c</FONT> is included in the
/<FONT FACE="Courier, monospace">frontend</FONT> folder to show how
extended ASCII can be used to produce the following symbol. Extended
ASCII characters may not display properly in EPS due to the
restrictions of the EPS format.</P>
<P ALIGN=LEFT><IMG SRC="barext.png" NAME="graphics13" ALIGN=LEFT WIDTH=246 HEIGHT=118 BORDER=0><BR CLEAR=LEFT><BR><BR>
</P> </P>
<P ALIGN=LEFT><BR><BR>
</P>
<P ALIGN=LEFT><BR><BR>
</P>
<P ALIGN=LEFT>[1] Zint requires input data to be encoded in UTF-8
format. <B>Note this now applies to both frontend and backend input
text</B>. Extended ASCII characters may not display properly in EPS
due to the restrictions of the EPS format.</P>
<HR> <HR>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0> <TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR VALIGN=TOP> <TR VALIGN=TOP>

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,7 @@ void usage(void)
" --secure=NUMBER (PDF417 and QR Code) Error correction level.\n" " --secure=NUMBER (PDF417 and QR Code) Error correction level.\n"
" --primary=STRING (Maxicode and Composite) Structured primary message.\n" " --primary=STRING (Maxicode and Composite) Structured primary message.\n"
" --mode=NUMBER (Maxicode and Composite) Set encoding mode.\n" " --mode=NUMBER (Maxicode and Composite) Set encoding mode.\n"
" --null=NUMBER Character to represent NULL.\n"
, ZINT_VERSION); , ZINT_VERSION);
} }
@ -153,6 +154,7 @@ int main(int argc, char **argv)
{"mode=", 1, 0, 0}, {"mode=", 1, 0, 0},
{"primary=", 1, 0, 0}, {"primary=", 1, 0, 0},
{"scale=", 1, 0, 0}, {"scale=", 1, 0, 0},
{"null=", 1, 0, 0},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index); 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"); 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=")) { if(!strcmp(long_options[option_index].name, "height=")) {
error_number = validator(NESET, optarg); error_number = validator(NESET, optarg);
if(error_number == ERROR_INVALID_DATA) { if(error_number == ERROR_INVALID_DATA) {