Add GS1 support to Code 49

This commit is contained in:
hooper114 2009-07-09 08:28:00 +00:00
parent aa1c9afc66
commit 063ac4ce4f
2 changed files with 16 additions and 5 deletions

View File

@ -25,8 +25,8 @@
#include "common.h" #include "common.h"
#include "code49.h" #include "code49.h"
#define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&" #define INSET "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%!&*"
/* "!" represents Shift 1 and "&" represents Shift 2 */ /* "!" represents Shift 1 and "&" represents Shift 2, "*" represents FNC1 */
int code_49(struct zint_symbol *symbol, unsigned char source[]) int code_49(struct zint_symbol *symbol, unsigned char source[])
{ {
@ -37,11 +37,13 @@ int code_49(struct zint_symbol *symbol, unsigned char source[])
int w_grid[8][4]; /* Refets to table 2 */ int w_grid[8][4]; /* Refets to table 2 */
int pad_count = 0; int pad_count = 0;
char pattern[40]; char pattern[40];
int gs1;
if(ustrlen(source) > 81) { if(ustrlen(source) > 81) {
strcpy(symbol->errtxt, "Input too long"); strcpy(symbol->errtxt, "Input too long");
return ERROR_TOO_LONG; return ERROR_TOO_LONG;
} }
if(symbol->input_mode == GS1_MODE) { gs1 = 1; } else { gs1 = 0; }
strcpy(intermediate, ""); strcpy(intermediate, "");
for(i = 0; i < ustrlen(source); i++) { for(i = 0; i < ustrlen(source); i++) {
@ -49,10 +51,17 @@ int code_49(struct zint_symbol *symbol, unsigned char source[])
strcpy(symbol->errtxt, "Invalid characters in input data"); strcpy(symbol->errtxt, "Invalid characters in input data");
return ERROR_INVALID_DATA; return ERROR_INVALID_DATA;
} }
if(gs1 && (i = 0)) {
concat(intermediate, "*"); /* FNC1 */
}
if(source[i] == symbol->nullchar) { if(source[i] == symbol->nullchar) {
concat(intermediate, c49_table7[0]); concat(intermediate, c49_table7[0]);
} else { } else {
concat(intermediate, c49_table7[source[i]]); if(gs1 && (source[i] == '[')) {
concat(intermediate, "*"); /* FNC1 */
} else {
concat(intermediate, c49_table7[source[i]]);
}
} }
} }

View File

@ -376,6 +376,8 @@ int gs1_compliant(int symbology)
case BARCODE_AZTEC: case BARCODE_AZTEC:
case BARCODE_DATAMATRIX: case BARCODE_DATAMATRIX:
case BARCODE_CODABLOCKF: case BARCODE_CODABLOCKF:
case BARCODE_CODEONE:
case BARCODE_CODE49:
result = 1; result = 1;
break; break;
} }
@ -595,14 +597,14 @@ int ZBarcode_Print(struct zint_symbol *symbol)
int error_number; int error_number;
char output[4]; char output[4];
/* int i, j; /*int i, j;
for(i = 0; i < symbol->rows; i++) { for(i = 0; i < symbol->rows; i++) {
for(j = 0; j <= symbol->width / 7; j++) { for(j = 0; j <= symbol->width / 7; j++) {
printf("%2.2X ", symbol->encoded_data[i][j]); printf("%2.2X ", symbol->encoded_data[i][j]);
} }
printf("\n"); printf("\n");
} */ }*/
if(strlen(symbol->outfile) > 3) { if(strlen(symbol->outfile) > 3) {
output[0] = symbol->outfile[strlen(symbol->outfile) - 3]; output[0] = symbol->outfile[strlen(symbol->outfile) - 3];