Add option to include check digit in UPC/EAN data, and validate before encoding

Fixes #5
This commit is contained in:
Robin Stuart 2016-10-28 19:43:08 +01:00
parent 9024006ca8
commit d875318b3d
5 changed files with 253 additions and 141 deletions

View File

@ -505,6 +505,7 @@ int ZBarcode_ValidID(int symbol_id) {
case BARCODE_CODE39:
case BARCODE_EXCODE39:
case BARCODE_EANX:
case BARCODE_EANX_CHK:
case BARCODE_EAN128:
case BARCODE_CODABAR:
case BARCODE_CODE128:
@ -519,7 +520,9 @@ int ZBarcode_ValidID(int symbol_id) {
case BARCODE_RSS_EXP:
case BARCODE_TELEPEN:
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
case BARCODE_POSTNET:
case BARCODE_MSI_PLESSEY:
case BARCODE_FIM:
@ -540,6 +543,7 @@ int ZBarcode_ValidID(int symbol_id) {
case BARCODE_RM4SCC:
case BARCODE_DATAMATRIX:
case BARCODE_EAN14:
case BARCODE_EAN14_CHK:
case BARCODE_NVE18:
case BARCODE_JAPANPOST:
case BARCODE_KOREAPOST:
@ -663,11 +667,13 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
break;
case BARCODE_DPIDENT: error_number = dpident(symbol, preprocessed, in_length);
break;
case BARCODE_UPCA: error_number = eanx(symbol, preprocessed, in_length);
break;
case BARCODE_UPCE: error_number = eanx(symbol, preprocessed, in_length);
break;
case BARCODE_EANX: error_number = eanx(symbol, preprocessed, in_length);
case BARCODE_UPCA:
case BARCODE_UPCA_CHK:
case BARCODE_UPCE:
case BARCODE_UPCE_CHK:
case BARCODE_EANX:
case BARCODE_EANX_CHK:
error_number = eanx(symbol, preprocessed, in_length);
break;
case BARCODE_EAN128: error_number = ean_128(symbol, preprocessed, in_length);
break;
@ -683,9 +689,9 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
break;
case BARCODE_LOGMARS: error_number = c39(symbol, preprocessed, in_length);
break;
case BARCODE_CODE128: error_number = code_128(symbol, preprocessed, in_length);
break;
case BARCODE_CODE128B: error_number = code_128(symbol, preprocessed, in_length);
case BARCODE_CODE128:
case BARCODE_CODE128B:
error_number = code_128(symbol, preprocessed, in_length);
break;
case BARCODE_NVE18: error_number = nve_18(symbol, preprocessed, in_length);
break;
@ -713,13 +719,11 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
break;
case BARCODE_RM4SCC: error_number = royal_plot(symbol, preprocessed, in_length);
break;
case BARCODE_AUSPOST: error_number = australia_post(symbol, preprocessed, in_length);
break;
case BARCODE_AUSREPLY: error_number = australia_post(symbol, preprocessed, in_length);
break;
case BARCODE_AUSROUTE: error_number = australia_post(symbol, preprocessed, in_length);
break;
case BARCODE_AUSREDIRECT: error_number = australia_post(symbol, preprocessed, in_length);
case BARCODE_AUSPOST:
case BARCODE_AUSREPLY:
case BARCODE_AUSROUTE:
case BARCODE_AUSREDIRECT:
error_number = australia_post(symbol, preprocessed, in_length);
break;
case BARCODE_CODE16K: error_number = code16k(symbol, preprocessed, in_length);
break;
@ -729,37 +733,28 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
break;
case BARCODE_ISBNX: error_number = eanx(symbol, preprocessed, in_length);
break;
case BARCODE_RSS14: error_number = rss14(symbol, preprocessed, in_length);
break;
case BARCODE_RSS14STACK: error_number = rss14(symbol, preprocessed, in_length);
break;
case BARCODE_RSS14STACK_OMNI: error_number = rss14(symbol, preprocessed, in_length);
case BARCODE_RSS14:
case BARCODE_RSS14STACK:
case BARCODE_RSS14STACK_OMNI:
error_number = rss14(symbol, preprocessed, in_length);
break;
case BARCODE_RSS_LTD: error_number = rsslimited(symbol, preprocessed, in_length);
break;
case BARCODE_RSS_EXP: error_number = rssexpanded(symbol, preprocessed, in_length);
case BARCODE_RSS_EXP:
case BARCODE_RSS_EXPSTACK:
error_number = rssexpanded(symbol, preprocessed, in_length);
break;
case BARCODE_RSS_EXPSTACK: error_number = rssexpanded(symbol, preprocessed, in_length);
break;
case BARCODE_EANX_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_EAN128_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_RSS14_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_RSS_LTD_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_RSS_EXP_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_UPCA_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_UPCE_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_RSS14STACK_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_RSS14_OMNI_CC: error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_RSS_EXPSTACK_CC: error_number = composite(symbol, preprocessed, in_length);
case BARCODE_EANX_CC:
case BARCODE_EAN128_CC:
case BARCODE_RSS14_CC:
case BARCODE_RSS_LTD_CC:
case BARCODE_RSS_EXP_CC:
case BARCODE_UPCA_CC:
case BARCODE_UPCE_CC:
case BARCODE_RSS14STACK_CC:
case BARCODE_RSS14_OMNI_CC:
case BARCODE_RSS_EXPSTACK_CC:
error_number = composite(symbol, preprocessed, in_length);
break;
case BARCODE_KIX: error_number = kix_code(symbol, preprocessed, in_length);
break;
@ -767,27 +762,23 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
break;
case BARCODE_DAFT: error_number = daft_code(symbol, preprocessed, in_length);
break;
case BARCODE_EAN14: error_number = ean_14(symbol, preprocessed, in_length);
case BARCODE_EAN14:
case BARCODE_EAN14_CHK:
error_number = ean_14(symbol, preprocessed, in_length);
break;
case BARCODE_AZRUNE: error_number = aztec_runes(symbol, preprocessed, in_length);
break;
case BARCODE_KOREAPOST: error_number = korea_post(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_128: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_39: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_DM: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_QR: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_PDF: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_MICPDF: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_AZTEC: error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_HIBC_BLOCKF: error_number = hibc(symbol, preprocessed, in_length);
case BARCODE_HIBC_128:
case BARCODE_HIBC_39:
case BARCODE_HIBC_DM:
case BARCODE_HIBC_QR:
case BARCODE_HIBC_PDF:
case BARCODE_HIBC_MICPDF:
case BARCODE_HIBC_AZTEC:
case BARCODE_HIBC_BLOCKF:
error_number = hibc(symbol, preprocessed, in_length);
break;
case BARCODE_JAPANPOST: error_number = japan_post(symbol, preprocessed, in_length);
break;
@ -799,9 +790,9 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
break;
case BARCODE_DATAMATRIX: error_number = dmatrix(symbol, preprocessed, in_length);
break;
case BARCODE_PDF417: error_number = pdf417enc(symbol, preprocessed, in_length);
break;
case BARCODE_PDF417TRUNC: error_number = pdf417enc(symbol, preprocessed, in_length);
case BARCODE_PDF417:
case BARCODE_PDF417TRUNC:
error_number = pdf417enc(symbol, preprocessed, in_length);
break;
case BARCODE_MICROPDF417: error_number = micro_pdf417(symbol, preprocessed, in_length);
break;
@ -861,7 +852,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
if ((symbol->symbology >= 10) && (symbol->symbology <= 12)) {
symbol->symbology = BARCODE_EANX;
}
if ((symbol->symbology == 14) || (symbol->symbology == 15)) {
if (symbol->symbology == 15) {
symbol->symbology = BARCODE_EANX;
}
if (symbol->symbology == 17) {
@ -882,10 +873,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, unsigned char *source, int lengt
if (symbol->symbology == 33) {
symbol->symbology = BARCODE_EAN128;
}
if ((symbol->symbology == 35) || (symbol->symbology == 36)) {
if (symbol->symbology == 36) {
symbol->symbology = BARCODE_UPCA;
}
if ((symbol->symbology == 38) || (symbol->symbology == 39)) {
if (symbol->symbology == 38) {
symbol->symbology = BARCODE_UPCE;
}
if ((symbol->symbology >= 41) && (symbol->symbology <= 45)) {

View File

@ -124,45 +124,82 @@ void upca_draw(char source[], char dest[]) {
}
/* Make a UPC A barcode when we haven't been given the check digit */
void upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int upca(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int length;
char gtin[15];
strcpy(gtin, (char*) source);
length = strlen(gtin);
gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0';
if (length == 11) {
gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0';
} else {
gtin[length - 1] = '\0';
if (source[length - 1] != upc_check(gtin)) {
strcpy(symbol->errtxt, "Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
gtin[length - 1] = upc_check(gtin);
}
upca_draw(gtin, dest);
ustrcpy(symbol->text, (unsigned char*) gtin);
return 0;
}
/* UPC E is a zero-compressed version of UPC A */
void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int i, num_system;
char emode, equivalent[12], check_digit, parity[8], temp[8];
char hrt[9];
/* Two number systems can be used - system 0 and system 1 */
if (ustrlen(source) == 7) {
switch (source[0]) {
case '0': num_system = 0;
break;
case '1': num_system = 1;
break;
default: num_system = 0;
source[0] = '0';
break;
}
strcpy(temp, (char*) source);
strcpy(hrt, (char*) source);
for (i = 1; i <= 7; i++) {
source[i - 1] = temp[i];
if (symbol->symbology != BARCODE_UPCE_CHK) {
/* No check digit in input data */
if (ustrlen(source) == 7) {
switch (source[0]) {
case '0': num_system = 0;
break;
case '1': num_system = 1;
break;
default: num_system = 0;
source[0] = '0';
break;
}
strcpy(temp, (char*) source);
strcpy(hrt, (char*) source);
for (i = 1; i <= 7; i++) {
source[i - 1] = temp[i];
}
} else {
num_system = 0;
hrt[0] = '0';
hrt[1] = '\0';
strcat(hrt, (char*) source);
}
} else {
num_system = 0;
hrt[0] = '0';
hrt[1] = '\0';
strcat(hrt, (char*) source);
/* Check digit is included in input data */
if (ustrlen(source) == 8) {
switch (source[0]) {
case '0': num_system = 0;
break;
case '1': num_system = 1;
break;
default: num_system = 0;
source[0] = '0';
break;
}
strcpy(temp, (char*) source);
strcpy(hrt, (char*) source);
for (i = 1; i <= 7; i++) {
source[i - 1] = temp[i];
}
} else {
num_system = 0;
hrt[0] = '0';
hrt[1] = '\0';
strcat(hrt, (char*) source);
}
}
/* Expand the zero-compressed UPCE code to make a UPCA equivalent (EN Table 5) */
@ -193,6 +230,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
if (((source[2] == '0') || (source[2] == '1')) || (source[2] == '2')) {
/* Note 1 - "X3 shall not be equal to 0, 1 or 2" */
strcpy(symbol->errtxt, "Invalid UPC-E data");
return ZINT_ERROR_INVALID_DATA;
}
break;
case '4':
@ -202,6 +240,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
if (source[3] == '0') {
/* Note 2 - "X4 shall not be equal to 0" */
strcpy(symbol->errtxt, "Invalid UPC-E data");
return ZINT_ERROR_INVALID_DATA;
}
break;
case '5':
@ -216,6 +255,7 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
if (source[4] == '0') {
/* Note 3 - "X5 shall not be equal to 0" */
strcpy(symbol->errtxt, "Invalid UPC-E data");
return ZINT_ERROR_INVALID_DATA;
}
break;
}
@ -248,9 +288,17 @@ void upce(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* stop character */
strcat(dest, "111111");
hrt[7] = check_digit;
hrt[8] = '\0';
if (symbol->symbology != BARCODE_UPCE_CHK) {
hrt[7] = check_digit;
hrt[8] = '\0';
} else {
if (hrt[7] != check_digit) {
strcpy(symbol->errtxt, "Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
}
ustrcpy(symbol->text, (unsigned char*) hrt);
return 0;
}
/* EAN-2 and EAN-5 add-on codes */
@ -335,7 +383,7 @@ char ean_check(char source[]) {
return itoc(check_digit);
}
void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
unsigned int length, i, half_way;
char parity[6];
char gtin[15];
@ -345,8 +393,18 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* Add the appropriate check digit */
length = strlen(gtin);
gtin[length] = ean_check(gtin);
gtin[length + 1] = '\0';
if (length == 12) {
gtin[length] = ean_check(gtin);
gtin[length + 1] = '\0';
} else {
gtin[length - 1] = '\0';
if (source[length - 1] != ean_check(gtin)) {
strcpy(symbol->errtxt, "Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
gtin[length - 1] = ean_check(gtin);
}
/* Get parity for first half of the symbol */
lookup(SODIUM, EAN13Parity, gtin[0], parity);
@ -375,20 +433,33 @@ void ean13(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
strcat(dest, "111");
ustrcpy(symbol->text, (unsigned char*) gtin);
return 0;
}
/* Make an EAN-8 barcode when we haven't been given the check digit */
void ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
int ean8(struct zint_symbol *symbol, unsigned char source[], char dest[]) {
/* EAN-8 is basically the same as UPC-A but with fewer digits */
int length;
char gtin[10];
strcpy(gtin, (char*) source);
length = strlen(gtin);
gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0';
if (length == 7) {
gtin[length] = upc_check(gtin);
gtin[length + 1] = '\0';
} else {
gtin[length - 1] = '\0';
if (source[length - 1] != upc_check(gtin)) {
strcpy(symbol->errtxt, "Invalid check digit");
return ZINT_ERROR_INVALID_DATA;
}
gtin[length - 1] = upc_check(gtin);
}
upca_draw(gtin, dest);
ustrcpy(symbol->text, (unsigned char*) gtin);
return 0;
}
/* For ISBN(13) only */
@ -577,10 +648,29 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi
}
}
break;
case BARCODE_EANX_CHK:
if (first_len <= 13) {
zfirst_len = 13;
}
if (first_len <= 8) {
zfirst_len = 8;
}
if (second_len == 0) {
if (first_len <= 5) {
zfirst_len = 5;
}
if (first_len <= 2) {
zfirst_len = 2;
}
}
break;
case BARCODE_UPCA:
case BARCODE_UPCA_CC:
zfirst_len = 11;
break;
case BARCODE_UPCA_CHK:
zfirst_len = 12;
break;
case BARCODE_UPCE:
case BARCODE_UPCE_CC:
if (first_len == 7) {
@ -590,6 +680,14 @@ void ean_leading_zeroes(struct zint_symbol *symbol, unsigned char source[], unsi
zfirst_len = 6;
}
break;
case BARCODE_UPCE_CHK:
if (first_len == 8) {
zfirst_len = 8;
}
if (first_len <= 7) {
zfirst_len = 7;
}
break;
case BARCODE_ISBNX:
if (first_len <= 9) {
zfirst_len = 9;
@ -687,6 +785,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
switch (symbol->symbology) {
case BARCODE_EANX:
case BARCODE_EANX_CHK:
switch (ustrlen(first_part)) {
case 2: add_on(first_part, (char*) dest, 0);
ustrcpy(symbol->text, first_part);
@ -694,9 +793,11 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
case 5: add_on(first_part, (char*) dest, 0);
ustrcpy(symbol->text, first_part);
break;
case 7: ean8(symbol, first_part, (char*) dest);
case 7:
case 8: error_number = ean8(symbol, first_part, (char*) dest);
break;
case 12: ean13(symbol, first_part, (char*) dest);
case 12:
case 13: error_number = ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "Invalid length input");
return ZINT_ERROR_TOO_LONG;
@ -714,7 +815,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
ean8(symbol, first_part, (char*) dest);
error_number = ean8(symbol, first_part, (char*) dest);
break;
case 12:set_module(symbol, symbol->rows, 1);
set_module(symbol, symbol->rows, 95);
@ -726,15 +827,16 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
ean13(symbol, first_part, (char*) dest);
error_number = ean13(symbol, first_part, (char*) dest);
break;
default: strcpy(symbol->errtxt, "Invalid length EAN input");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCA:
if (ustrlen(first_part) == 11) {
upca(symbol, first_part, (char*) dest);
case BARCODE_UPCA_CHK:
if ((ustrlen(first_part) == 11) || (ustrlen(first_part) == 12)) {
error_number = upca(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "Input wrong length");
return ZINT_ERROR_TOO_LONG;
@ -752,15 +854,16 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
upca(symbol, first_part, (char*) dest);
error_number = upca(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "UPCA input wrong length");
return ZINT_ERROR_TOO_LONG;
}
break;
case BARCODE_UPCE:
if ((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 7)) {
upce(symbol, first_part, (char*) dest);
case BARCODE_UPCE_CHK:
if ((ustrlen(first_part) >= 6) && (ustrlen(first_part) <= 8)) {
error_number = upce(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "Input wrong length");
return ZINT_ERROR_TOO_LONG;
@ -778,7 +881,7 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
symbol->row_height[symbol->rows + 1] = 2;
symbol->row_height[symbol->rows + 2] = 2;
symbol->rows += 3;
upce(symbol, first_part, (char*) dest);
error_number = upce(symbol, first_part, (char*) dest);
} else {
strcpy(symbol->errtxt, "UPCE input wrong length");
return ZINT_ERROR_TOO_LONG;
@ -786,11 +889,13 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
break;
case BARCODE_ISBNX:
error_number = isbn(symbol, first_part, ustrlen(first_part), (char*) dest);
if (error_number > 4) {
return error_number;
}
break;
}
if (error_number > 4) {
return error_number;
}
switch (ustrlen(second_part)) {
case 0: break;
case 2:
@ -827,9 +932,5 @@ int eanx(struct zint_symbol *symbol, unsigned char source[], int src_len) {
break;
}
if ((symbol->errtxt[0] == 'w') && (error_number == 0)) {
error_number = 1; /* flag UPC-E warnings */
}
return error_number;
return 0;
}

View File

@ -109,6 +109,7 @@ extern "C" {
#define BARCODE_CODE39 8
#define BARCODE_EXCODE39 9
#define BARCODE_EANX 13
#define BARCODE_EANX_CHK 14
#define BARCODE_EAN128 16
#define BARCODE_CODABAR 18
#define BARCODE_CODE128 20
@ -123,7 +124,9 @@ extern "C" {
#define BARCODE_RSS_EXP 31
#define BARCODE_TELEPEN 32
#define BARCODE_UPCA 34
#define BARCODE_UPCA_CHK 35
#define BARCODE_UPCE 37
#define BARCODE_UPCE_CHK 38
#define BARCODE_POSTNET 40
#define BARCODE_MSI_PLESSEY 47
#define BARCODE_FIM 49

View File

@ -236,6 +236,7 @@ Numeric Value | Barcode Name
8 | Code 3 of 9 (Code 39)
9 | Extended Code 3 of 9 (Code 39+)
13 | EAN (Including EAN-8 and EAN-13)
14 | EAN + Check Digit
16 | GS1-128 (UCC.EAN-128)
18 | Codabar
20 | Code 128 (automatic subset switching)
@ -250,7 +251,9 @@ Numeric Value | Barcode Name
31 | GS1 DataBar Extended
32 | Telepen Alpha
34 | UPC A
35 | UPC A + Check Digit
37 | UPC E
38 | UPC E + Check Digit
40 | PostNet
47 | MSI Plessey
49 | FIM
@ -893,6 +896,7 @@ Value |
8 | BARCODE_CODE39 | Code 3 of 9 (Code 39)
9 | BARCODE_EXCODE39 | Extended Code 3 of 9 (Code 39+)
13 | BARCODE_EANX | EAN
14 | BARCODE_EANX_CHK | EAN + Check Digit
16 | BARCODE_EAN128 | GS1-128 (UCC.EAN-128)
18 | BARCODE_CODABAR | Codabar
20 | BARCODE_CODE128 | Code 128 (automatic subset switching)
@ -907,7 +911,9 @@ Value |
31 | BARCODE_RSS_EXP | GS1 DataBar Extended
32 | BARCODE_TELEPEN | Telepen Alpha
34 | BARCODE_UPCA | UPC A
35 | BARCODE_UPCA_CHK | UPC A + Check Digit
37 | BARCODE_UPCE | UPC E
38 | BARCODE_UPCE | UPC E + Check Digit
40 | BARCODE_POSTNET | PostNet
47 | BARCODE_MSI_PLESSEY | MSI Plessey
49 | BARCODE_FIM | FIM
@ -1123,6 +1129,9 @@ my_symbol->symbology = BARCODE_UPCA;
error = ZBarcode_Encode_and_Print(my_symbol, "72527270270+12345");
If your input data already includes the check digit symbology 35 can be used
which takes a 12 digit input and validates the check digit before encoding.
6.1.3.2 UPC Version E
---------------------
UPC-E is a zero-compressed version of UPC-A developed for smaller packages. The
@ -1140,6 +1149,9 @@ my_symbol->symbology = BARCODE_UPCE;
error = ZBarcode_Encode_and_Print(my_symbol, "1123456");
If your input data already includes the check digit symbology 38 can be used
which takes a 7 or 8 digit input and validates the check digit before encoding.
6.1.4 European Article Number (EN 797)
--------------------------------------
6.1.4.1 EAN-2, EAN-5, EAN-8 and EAN-13
@ -1167,6 +1179,10 @@ error = ZBarcode_Encode_and_Print(my_symbol, "7432365+54321");
All of the EAN symbols include check digits which are added by Zint.
If you are encoding an EAN-8 or EAN-13 symbol and your data already includes
the check digit then you can use symbology 14 which takes an 8 or 13 digit input
and validates the check digit before encoding.
6.1.4.2 SBN, ISBN and ISBN-13
-----------------------------
EAN-13 symbols (also known as Bookland EAN-13) can also be produced from

View File

@ -37,35 +37,36 @@
/* Print list of supported symbologies */
void types(void) {
printf( " 1: Code 11 52: PZN 92: Aztec Code\n"
" 2: Standard 2of5 53: Pharma Two-Track 93: DAFT Code\n"
" 3: Interleaved 2of5 55: PDF417 97: Micro QR Code\n"
" 4: IATA 2of5 56: PDF417 Trunc 98: HIBC Code 128\n"
" 6: Data Logic 57: Maxicode 99: HIBC Code 39\n"
" 7: Industrial 2of5 58: QR Code 102: HIBC Data Matrix\n"
" 8: Code 39 60: Code 128-B 104: HIBC QR Code\n"
" 9: Extended Code 39 63: AP Standard Customer 106: HIBC PDF417\n"
"13: EAN 66: AP Reply Paid 108: HIBC MicroPDF417\n"
"16: GS1-128 67: AP Routing 110: HIBC Codablock-F\n"
"18: Codabar 68: AP Redirection 112: HIBC Aztec Code\n"
"20: Code 128 69: ISBN 115: DotCode\n"
"21: Leitcode 70: RM4SCC 116: Han Xin Code\n"
"22: Identcode 71: Data Matrix 128: Aztec Runes\n"
"23: Code 16k 72: EAN-14 129: Code 32\n"
"24: Code 49 74: Codablock-F 130: Comp EAN\n"
"25: Code 93 75: NVE-18 131: Comp GS1-128\n"
"28: Flattermarken 76: Japanese Post 132: Comp DataBar Omni\n"
"29: GS1 DataBar Omni 77: Korea Post 133: Comp DataBar Ltd\n"
"30: GS1 DataBar Ltd 79: GS1 DataBar Stack 134: Comp DataBar ExpOm\n"
"31: GS1 DataBar ExpOm 80: GS1 DataBar Stack Omni 135: Comp UPC-A\n"
"32: Telepen Alpha 81: GS1 DataBar ESO 136: Comp UPC-E\n"
"34: UPC-A 82: Planet 137: Comp DataBar Stack\n"
"37: UPC-E 84: MicroPDF 138: Comp DataBar Stack Omni\n"
"40: Postnet 85: USPS OneCode 139: Comp DataBar ESO\n"
"47: MSI Plessey 86: UK Plessey 140: Channel Code\n"
"49: FIM 87: Telepen Numeric 141: Code One\n"
"50: Logmars 89: ITF-14 142: Grid Matrix\n"
"51: Pharma One-Track 90: KIX Code\n"
printf( " 1: Code 11 50: Logmars 90: KIX Code\n"
" 2: Standard 2of5 51: Pharma One-Track 92: Aztec Code\n"
" 3: Interleaved 2of5 52: PZN 93: DAFT Code\n"
" 4: IATA 2of5 53: Pharma Two-Track 97: Micro QR Code\n"
" 6: Data Logic 55: PDF417 98: HIBC Code 128\n"
" 7: Industrial 2of5 56: PDF417 Trunc 99: HIBC Code 39\n"
" 8: Code 39 57: Maxicode 102: HIBC Data Matrix\n"
" 9: Extended Code 39 58: QR Code 104: HIBC QR Code\n"
"13: EAN 60: Code 128-B 106: HIBC PDF417\n"
"14: EAN + Check 63: AP Standard Customer 108: HIBC MicroPDF417"
"16: GS1-128 66: AP Reply Paid 110: HIBC Codablock-F\n"
"18: Codabar 67: AP Routing 112: HIBC Aztec Code\n"
"20: Code 128 68: AP Redirection 115: DotCode\n"
"21: Leitcode 69: ISBN 116: Han Xin Code\n"
"22: Identcode 70: RM4SCC 128: Aztec Runes\n"
"23: Code 16k 71: Data Matrix 129: Code 32\n"
"24: Code 49 72: EAN-14 130: Comp EAN\n"
"25: Code 93 74: Codablock-F 131: Comp GS1-128\n"
"28: Flattermarken 75: NVE-18 132: Comp DataBar Omni\n"
"29: GS1 DataBar Omni 76: Japanese Post 133: Comp DataBar Ltd\n"
"30: GS1 DataBar Ltd 77: Korea Post 134: Comp DataBar ExpOm\n"
"31: GS1 DataBar ExpOm 79: GS1 DataBar Stack 135: Comp UPC-A\n"
"32: Telepen Alpha 80: GS1 DataBar Stack Omni 136: Comp UPC-E\n"
"34: UPC-A 81: GS1 DataBar ESO 137: Comp DataBar Stack\n"
"35: UPC-A + Check 82: Planet 138: Comp DataBar Stack Omni\n"
"37: UPC-E 84: MicroPDF 139: Comp DataBar ESO\n"
"38: UPC-E + Check 85: USPS OneCode 140: Channel Code\n"
"40: Postnet 86: UK Plessey 141: Code One\n"
"47: MSI Plessey 87: Telepen Numeric 142: Grid Matrix\n"
"49: FIM 89: ITF-14\n"
);
}