mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-28 05:54:19 -04:00
UPU_S10/GS1: properly expose iso3166_alpha2()
; add UPU_S10 to tcl
This commit is contained in:
parent
53769c6ed1
commit
ab7da62a3a
5 changed files with 12 additions and 4 deletions
|
@ -1180,8 +1180,6 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
|
|||
return error_number;
|
||||
}
|
||||
|
||||
INTERNAL int iso3166_alpha2(const char *cc); /* In "iso3166.h" which is included by "gs1.c" */
|
||||
|
||||
/* Universal Postal Union S10 */
|
||||
/* https://www.upu.int/UPU/media/upu/files/postalSolutions/programmesAndServices/standards/S10-12.pdf */
|
||||
INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
|
@ -1247,7 +1245,7 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
|
|||
} else if (strchr("FHIOXY", local_source[0]) != NULL) { /* These aren't allocated as of spec Oct 2017 */
|
||||
strcpy(symbol->errtxt, "840: Non-standard Service Indicator (first 2 characters)");
|
||||
error_number = ZINT_WARN_NONCOMPLIANT;
|
||||
} else if (!iso3166_alpha2((const char *) (local_source + 11))) {
|
||||
} else if (!gs1_iso3166_alpha2(local_source + 11)) {
|
||||
strcpy(symbol->errtxt, "841: Country code (last two characters) is not ISO 3166-1");
|
||||
error_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
|
|
|
@ -1428,4 +1428,9 @@ INTERNAL char gs1_check_digit(const unsigned char source[], const int length) {
|
|||
return itoc((10 - (count % 10)) % 10);
|
||||
}
|
||||
|
||||
/* Helper to expose `iso3166_alpha2()` */
|
||||
INTERNAL int gs1_iso3166_alpha2(const unsigned char *cc) {
|
||||
return iso3166_alpha2((const char *) cc);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
|||
INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const int src_len,
|
||||
unsigned char reduced[]);
|
||||
INTERNAL char gs1_check_digit(const unsigned char source[], const int src_len);
|
||||
INTERNAL int gs1_iso3166_alpha2(const unsigned char *cc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ static int iso3166_numeric(int cc) {
|
|||
}
|
||||
|
||||
/* Whether ISO 3166-1 alpha2 */
|
||||
INTERNAL int iso3166_alpha2(const char *cc) {
|
||||
static int iso3166_alpha2(const char *cc) {
|
||||
static const unsigned char codes[85] = {
|
||||
0x78, 0x59, 0xDF, 0xEE, 0xEF, 0xBD, 0xDD, 0xDE,
|
||||
0x27, 0x3F, 0x84, 0x15, 0x80, 0xD4, 0x00, 0x0E,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue