mirror of
https://git.code.sf.net/p/zint/code
synced 2026-05-14 18:13:53 +00:00
AUSPOST: support Null FCC (DPID all zeroes); TODO: BWIPP support
CODE128: properly fix not switching before FNC1 in 2nd position after alpha (commit [7b0767]) PLANET/KIX: adapt POSTNET to cater for both general: use static strings to save a few bytes (start/stop in particular); various other code fiddles postal: move tables into funcs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* upcean.c - Handles UPC, EAN and ISBN */
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2025 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2008-2026 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@@ -85,6 +85,8 @@ static const char EANsetB[10][4] = {
|
||||
{'1','3','2','1'}, {'4','1','1','1'}, {'2','1','3','1'}, {'3','1','2','1'}, {'2','1','1','3'}
|
||||
};
|
||||
|
||||
static const char EANones[6] = { '1','1','1','1','1','1' }; /* Various lengths used for start/stop/separators */
|
||||
|
||||
/* Write UPC-A or EAN-8 encodation to destination `d` */
|
||||
static void upca_set_dest(const unsigned char source[], const int length, char *d) {
|
||||
int i, half_way;
|
||||
@@ -92,13 +94,13 @@ static void upca_set_dest(const unsigned char source[], const int length, char *
|
||||
half_way = length / 2;
|
||||
|
||||
/* Start character */
|
||||
memcpy(d, "111", 3);
|
||||
memcpy(d, EANones, 3);
|
||||
d += 3;
|
||||
|
||||
for (i = 0; i < length; i++, d += 4) {
|
||||
if (i == half_way) {
|
||||
/* Middle character - separates manufacturer no. from product no. - also inverts right hand characters */
|
||||
memcpy(d, "11111", 5);
|
||||
memcpy(d, EANones, 5);
|
||||
d += 5;
|
||||
}
|
||||
|
||||
@@ -106,7 +108,9 @@ static void upca_set_dest(const unsigned char source[], const int length, char *
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
memcpy(d, "111", 4); /* Include terminating NUL */
|
||||
memcpy(d, EANones, 3);
|
||||
d += 3;
|
||||
*d = '\0'; /* Need to NUL-terminate */
|
||||
}
|
||||
|
||||
/* Make a UPC-A barcode, allowing for composite if `cc_rows` set */
|
||||
@@ -278,7 +282,7 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
/* Take all this information and make the barcode pattern */
|
||||
|
||||
/* Start character */
|
||||
memcpy(d, "111", 3);
|
||||
memcpy(d, EANones, 3);
|
||||
d += 3;
|
||||
|
||||
for (i = 0; i < length; i++, d += 4) {
|
||||
@@ -293,7 +297,9 @@ static int upce_cc(struct zint_symbol *symbol, unsigned char source[], int lengt
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
memcpy(d, "111111", 7); /* Include terminating NUL */
|
||||
memcpy(d, EANones, 6);
|
||||
d += 6;
|
||||
*d = '\0'; /* Need to NUL-terminate */
|
||||
|
||||
z_hrt_cat_chr_nochk(symbol, check_digit);
|
||||
|
||||
@@ -333,6 +339,7 @@ static int upce(struct zint_symbol *symbol, unsigned char source[], int length,
|
||||
|
||||
/* EAN-2 and EAN-5 add-on codes */
|
||||
static void ean_add_on(const unsigned char source[], const int length, char dest[], const int addon_gap) {
|
||||
static const char start[3] = { '1','1','2' };
|
||||
const char *parity;
|
||||
int i;
|
||||
char *d = dest + strlen(dest);
|
||||
@@ -343,7 +350,7 @@ static void ean_add_on(const unsigned char source[], const int length, char dest
|
||||
}
|
||||
|
||||
/* Start character */
|
||||
memcpy(d, "112", 3);
|
||||
memcpy(d, start, 3);
|
||||
d += 3;
|
||||
|
||||
/* Calculate parity */
|
||||
@@ -381,7 +388,7 @@ static void ean_add_on(const unsigned char source[], const int length, char dest
|
||||
|
||||
/* Glyph separator */
|
||||
if (i != (length - 1)) {
|
||||
memcpy(d, "11", 2);
|
||||
memcpy(d, EANones, 2);
|
||||
d += 2;
|
||||
}
|
||||
}
|
||||
@@ -422,13 +429,13 @@ static int ean13_cc(struct zint_symbol *symbol, const unsigned char source[], in
|
||||
half_way = 7;
|
||||
|
||||
/* Start character */
|
||||
memcpy(d, "111", 3);
|
||||
memcpy(d, EANones, 3);
|
||||
d += 3;
|
||||
|
||||
for (i = 1; i < symbol->text_length; i++, d += 4) {
|
||||
if (i == half_way) {
|
||||
/* Middle character - separates manufacturer no. from product no. - also inverts right hand characters */
|
||||
memcpy(d, "11111", 5);
|
||||
memcpy(d, EANones, 5);
|
||||
d += 5;
|
||||
}
|
||||
|
||||
@@ -440,7 +447,9 @@ static int ean13_cc(struct zint_symbol *symbol, const unsigned char source[], in
|
||||
}
|
||||
|
||||
/* Stop character */
|
||||
memcpy(d, "111", 4); /* Include terminating NUL */
|
||||
memcpy(d, EANones, 3);
|
||||
d += 3;
|
||||
*d = '\0'; /* Need to NUL-terminate */
|
||||
|
||||
if (symbol->output_options & COMPLIANT_HEIGHT) {
|
||||
/* ISO/IEC 15420:2009 4.3.3 Bar height EAN-13 22.85mm / 0.33mm (X) ~ 69.24,
|
||||
|
||||
Reference in New Issue
Block a user