GUI: remove sizeConstraint so squashable again (sigh)

- make Sequence Format textbox bigger (on own line)
  - suppress question mark in Windows dialogs
AUSPOST: more standard error messages
backend: add & use z_isdigit/upper/lower() macros
docs: 20-bit Unicode -> 21-bit Unicode
This commit is contained in:
gitlost 2022-06-24 14:38:48 +01:00
parent 07772094d5
commit 0b3fe8db93
40 changed files with 200 additions and 186 deletions

View file

@ -1,8 +1,7 @@
/* auspost.c - Handles Australia Post 4-State Barcode */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -29,7 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
static const char GDSET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz #";
#define GDSET_F (IS_NUM_F | IS_UPR_F | IS_LWR_F | IS_SPC_F | IS_HSH_F)
@ -124,11 +123,11 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
/* Do all of the length checking first to avoid stack smashing */
if (symbol->symbology == BARCODE_AUSPOST) {
if (length != 8 && length != 13 && length != 16 && length != 18 && length != 23) {
strcpy(symbol->errtxt, "401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)");
strcpy(symbol->errtxt, "401: Input wrong length (8, 13, 16, 18 or 23 characters only)");
return ZINT_ERROR_TOO_LONG;
}
} else if (length > 8) {
strcpy(symbol->errtxt, "403: Auspost input is too long (8 character maximum)");
strcpy(symbol->errtxt, "403: Input too long (8 character maximum)");
return ZINT_ERROR_TOO_LONG;
}
@ -280,3 +279,5 @@ INTERNAL int auspost(struct zint_symbol *symbol, unsigned char source[], int len
return error_number;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1,6 +1,5 @@
/* big5.h - tables for Unicode to Big5,
generated by "backend/tools/gen_eci_mb_h.php" from
"https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT" */
/* big5.h - tables for Unicode to Big5, generated by "backend/tools/gen_eci_mb_h.php"
from "https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/OTHER/BIG5.TXT" */
/*
libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>

View file

@ -1,8 +1,7 @@
/* codablock.c - Handles Codablock-F and Codablock-E */
/*
libzint - the open source barcode library
Copyright (C) 2016 - 2021 Harald Oehlmann
Copyright (C) 2016-2022 Harald Oehlmann
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -29,7 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
#include <math.h>
@ -81,7 +80,7 @@ static int GetPossibleCharacterSet(unsigned char C)
{
if (C<='\x1f') /* Control chars */
return CodeA;
if (C>='0' && C<='9')
if (z_isdigit(C))
return ZTNum; /* ZTNum=CodeA+CodeB+CodeC */
if (C==aFNC1) /* FNC1s (GS1) not used */
return ZTFNC1; /* ZTFNC1=CodeA+CodeB+CodeC+CodeFNC1 */ /* Not reached */
@ -965,3 +964,5 @@ INTERNAL int codablockf(struct zint_symbol *symbol, unsigned char source[], int
return error_number;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1,5 +1,4 @@
/* code1.c - USS Code One */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
@ -29,6 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include "common.h"
#include "code1.h"
@ -101,7 +101,7 @@ static void c1_spigot(struct zint_symbol *symbol, const int row_no) {
/* Is basic (non-shifted) C40? */
static int c1_isc40(const unsigned char input) {
if ((input >= '0' && input <= '9') || (input >= 'A' && input <= 'Z') || input == ' ') {
if (z_isdigit(input) || z_isupper(input) || input == ' ') {
return 1;
}
return 0;
@ -109,7 +109,7 @@ static int c1_isc40(const unsigned char input) {
/* Is basic (non-shifted) TEXT? */
static int c1_istext(const unsigned char input) {
if ((input >= '0' && input <= '9') || (input >= 'a' && input <= 'z') || input == ' ') {
if (z_isdigit(input) || z_islower(input) || input == ' ') {
return 1;
}
return 0;
@ -201,7 +201,7 @@ static int c1_look_ahead_test(const unsigned char source[], const int length, co
const int is_extended = c & 0x80;
/* Step L */
if ((c >= '0') && (c <= '9')) {
if (z_isdigit(c)) {
ascii_count += C1_MULT_1_DIV_2; /* Step L1 */
} else {
if (is_extended) {
@ -328,7 +328,7 @@ static int c1_is_last_single_ascii(const unsigned char source[], const int lengt
static void c1_set_num_digits(const unsigned char source[], const int length, int num_digits[]) {
int i;
for (i = length - 1; i >= 0; i--) {
if (source[i] >= '0' && source[i] <= '9') {
if (z_isdigit(source[i])) {
num_digits[i] = num_digits[i + 1] + 1;
}
}
@ -743,9 +743,9 @@ static int c1_encode(struct zint_symbol *symbol, unsigned char source[], int len
if (debug_print) printf("EDI ");
if ((source[sp] >= '0') && (source[sp] <= '9')) {
if (z_isdigit(source[sp])) {
cte_buffer[cte_p++] = source[sp] - '0' + 4;
} else if ((source[sp] >= 'A') && (source[sp] <= 'Z')) {
} else if (z_isupper(source[sp])) {
cte_buffer[cte_p++] = source[sp] - 'A' + 14;
} else {
cte_buffer[cte_p++] = posn(edi_nonalphanum_chars, source[sp]);

View file

@ -1,8 +1,7 @@
/* code49.c - Handles Code 49 */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -29,7 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
#include "common.h"
@ -82,9 +81,9 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
i = 0;
h = d - intermediate;
do {
if ((intermediate[i] >= '0') && (intermediate[i] <= '9')) {
if (z_isdigit(intermediate[i])) {
/* Numeric data */
for (j = 0; (intermediate[i + j] >= '0') && (intermediate[i + j] <= '9'); j++);
for (j = 0; z_isdigit(intermediate[i + j]); j++);
if (j >= 5) {
/* Use Numeric Encodation Method */
int block_count, c;
@ -389,3 +388,5 @@ INTERNAL int code49(struct zint_symbol *symbol, unsigned char source[], int leng
return error_number;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1,5 +1,4 @@
/* common.c - Contains functions needed for a number of barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
@ -29,6 +28,8 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include <assert.h>
#ifdef ZINT_TEST
#include <stdio.h>
@ -40,7 +41,7 @@
/* Converts a character 0-9, A-F to its equivalent integer value */
INTERNAL int ctoi(const char source) {
if ((source >= '0') && (source <= '9'))
if (z_isdigit(source))
return (source - '0');
if ((source >= 'A') && (source <= 'F'))
return (source - 'A' + 10);
@ -64,7 +65,7 @@ INTERNAL int to_int(const unsigned char source[], const int length) {
int i;
for (i = 0; i < length; i++) {
if (source[i] < '0' || source[i] > '9') {
if (!z_isdigit(source[i])) {
return -1;
}
val *= 10;
@ -79,7 +80,7 @@ INTERNAL void to_upper(unsigned char source[], const int length) {
int i;
for (i = 0; i < length; i++) {
if ((source[i] >= 'a') && (source[i] <= 'z')) {
if (z_islower(source[i])) {
source[i] = (source[i] - 'a') + 'A';
}
}
@ -353,8 +354,7 @@ INTERNAL int is_fixed_ratio(const int symbology) {
/* Whether next two characters are digits */
INTERNAL int is_twodigits(const unsigned char source[], const int length, const int position) {
if ((position + 1 < length) && (source[position] >= '0') && (source[position] <= '9')
&& (source[position + 1] >= '0') && (source[position + 1] <= '9')) {
if ((position + 1 < length) && z_isdigit(source[position]) && z_isdigit(source[position + 1])) {
return 1;
}

View file

@ -1,5 +1,4 @@
/* common.h - Header for all common functions in common.c */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
@ -70,6 +69,11 @@
/* The most commonly used set */
#define NEON_F IS_NUM_F /* NEON "0123456789" */
/* Simple versions of <cctype> functions with no dependence on locale */
#define z_isdigit(c) ((c) <= '9' && (c) >= '0')
#define z_isupper(c) ((c) >= 'A' && (c) <= 'Z')
#define z_islower(c) ((c) >= 'a' && (c) <= 'z')
#include "zint.h"
#include "zintconfig.h"
#include <stdlib.h>

View file

@ -979,10 +979,10 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
for (i = 0; i < ninety_len; i++) {
if ((ninety[i] >= 'A') && (ninety[i] <= 'Z')) {
if (z_isupper(ninety[i])) {
/* Character is alphabetic */
alpha += 1;
} else if ((ninety[i] >= '0') && (ninety[i] <= '9')) {
} else if (z_isdigit(ninety[i])) {
/* Character is numeric */
numeric += 1;
} else {
@ -993,15 +993,16 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
/* must start with 0, 1, 2 or 3 digits followed by an uppercase character */
test1 = -1;
for (i = 3; i >= 0; i--) {
if ((ninety[i] >= 'A') && (ninety[i] <= 'Z')) {
if (z_isupper(ninety[i])) {
test1 = i;
}
}
test2 = 0;
for (i = 0; i < test1; i++) {
if (!((ninety[i] >= '0') && (ninety[i] <= '9'))) {
if (!z_isdigit(ninety[i])) {
test2 = 1;
break;
}
}
@ -1108,10 +1109,10 @@ static int cc_binary_string(struct zint_symbol *symbol, const unsigned char sour
if (ai90_mode == 2) {
/* Alpha encodation (section 5.3.3) */
do {
if ((source[read_posn] >= 'A') && (source[read_posn] <= 'Z')) {
if (z_isupper(source[read_posn])) {
bp = bin_append_posn(source[read_posn] - 65, 5, binary_string, bp);
} else if ((source[read_posn] >= '0') && (source[read_posn] <= '9')) {
} else if (z_isdigit(source[read_posn])) {
bp = bin_append_posn(source[read_posn] + 4, 6, binary_string, bp);
} else if (source[read_posn] == '[') {

View file

@ -207,7 +207,7 @@ static int dm_isc40(const unsigned char input) {
if (input <= '9') {
return input >= '0' || input == ' ';
}
return input >= 'A' && input <= 'Z';
return z_isupper(input);
}
/* Is basic (non-shifted) TEXT? */
@ -215,7 +215,7 @@ static int dm_istext(const unsigned char input) {
if (input <= '9') {
return input >= '0' || input == ' ';
}
return input >= 'a' && input <= 'z';
return z_islower(input);
}
/* Is basic (non-shifted) C40/TEXT? */
@ -328,7 +328,7 @@ static int dm_look_ahead_test(const unsigned char source[], const int length, co
const int is_extended = c & 0x80;
/* ascii ... step (l) */
if ((c <= '9') && (c >= '0')) {
if (z_isdigit(c)) {
ascii_count += DM_MULT_1_DIV_2; // (l)(1)
} else {
if (is_extended) {
@ -721,26 +721,22 @@ static int dm_last_ascii(const unsigned char source[], const int length, const i
if ((source[from] & 0x80) || (source[from + 1] & 0x80)) {
return 0;
}
if (source[from] <= '9' && source[from] >= '0' && source[from + 1] <= '9' && source[from + 1] >= '0') {
if (z_isdigit(source[from]) && z_isdigit(source[from + 1])) {
return 1;
}
return 2;
}
if (length - from == 3) {
if (source[from] <= '9' && source[from] >= '0'
&& source[from + 1] <= '9' && source[from + 1] >= '0' && !(source[from + 2] & 0x80)) {
if (z_isdigit(source[from]) && z_isdigit(source[from + 1]) && !(source[from + 2] & 0x80)) {
return 2;
}
if (source[from + 1] <= '9' && source[from + 1] >= '0'
&& source[from + 2] <= '9' && source[from + 2] >= '0' && !(source[from] & 0x80)) {
if (z_isdigit(source[from + 1]) && z_isdigit(source[from + 2]) && !(source[from] & 0x80)) {
return 2;
}
return 0;
}
if (source[from] <= '9' && source[from] >= '0'
&& source[from + 1] <= '9' && source[from + 1] >= '0'
&& source[from + 2] <= '9' && source[from + 2] >= '0'
&& source[from + 3] <= '9' && source[from + 3] >= '0') {
if (z_isdigit(source[from]) && z_isdigit(source[from + 1]) && z_isdigit(source[from + 2])
&& z_isdigit(source[from + 3])) {
return 2;
}
return 0;
@ -939,8 +935,7 @@ static void dm_addEdges(struct zint_symbol *symbol, const unsigned char source[]
static const int c40text_modes[] = { DM_C40, DM_TEXT };
if (source[from] <= '9' && source[from] >= '0' && from + 1 < length
&& source[from + 1] <= '9' && source[from + 1] >= '0') {
if (z_isdigit(source[from]) && from + 1 < length && z_isdigit(source[from + 1])) {
dm_addEdge(symbol, source, length, edges, DM_ASCII, from, 2, previous, 0);
/* If ASCII vertex, don't bother adding other edges as this will be optimal; suggested by Alex Geller */
if (previous && previous->mode == DM_ASCII) {
@ -1191,9 +1186,9 @@ static int dm_minimalenc(struct zint_symbol *symbol, const unsigned char source[
static const char x12_nonalphanum_chars[] = "\015*> ";
int value = 0;
if ((source[sp] >= '0') && (source[sp] <= '9')) {
if (z_isdigit(source[sp])) {
value = (source[sp] - '0') + 4;
} else if ((source[sp] >= 'A') && (source[sp] <= 'Z')) {
} else if (z_isupper(source[sp])) {
value = (source[sp] - 'A') + 14;
} else {
value = posn(x12_nonalphanum_chars, source[sp]);
@ -1379,9 +1374,9 @@ static int dm_isoenc(struct zint_symbol *symbol, const unsigned char source[], c
static const char x12_nonalphanum_chars[] = "\015*> ";
int value = 0;
if ((source[sp] <= '9') && (source[sp] >= '0')) {
if (z_isdigit(source[sp])) {
value = (source[sp] - '0') + 4;
} else if ((source[sp] >= 'A') && (source[sp] <= 'Z')) {
} else if (z_isupper(source[sp])) {
value = (source[sp] - 'A') + 14;
} else {
value = posn(x12_nonalphanum_chars, source[sp]);

View file

@ -419,7 +419,7 @@ static int dc_datum_c(const unsigned char source[], const int length, const int
static int dc_n_digits(const unsigned char source[], const int length, const int position, const int max) {
int i;
for (i = position; (i < length) && ((source[i] >= '0') && (source[i] <= '9') && i < position + max); i++);
for (i = position; (i < length) && z_isdigit(source[i]) && (i < position + max); i++);
return i - position;
}
@ -453,7 +453,7 @@ static int dc_ahead_c(const unsigned char source[], const int length, const int
/* Annex F.II.F */
static int dc_try_c(const unsigned char source[], const int length, const int position) {
if (position < length && source[position] >= '0' && source[position] <= '9') { /* dc_n_digits(position) > 0 */
if (position < length && z_isdigit(source[position])) { /* dc_n_digits(position) > 0 */
const int ahead_c_position = dc_ahead_c(source, length, position);
if (ahead_c_position > dc_ahead_c(source, length, position + 1)) {
return ahead_c_position;
@ -688,7 +688,7 @@ static int dc_encode_message(struct zint_symbol *symbol, const unsigned char sou
/* Step C3 */
if (dc_binary(source, length, position)) {
/* dc_n_digits(position + 1) > 0 */
if (position + 1 < length && source[position + 1] >= '0' && source[position + 1] <= '9') {
if (position + 1 < length && z_isdigit(source[position + 1])) {
if ((source[position] - 128) < 32) {
codeword_array[ap++] = 110; // Upper Shift A
codeword_array[ap++] = source[position] - 128 + 64;

View file

@ -1,8 +1,8 @@
/* eci_sb.h - Extended Channel Interpretations single-byte,
generated by "backend/tools/gen_eci_sb_h.php" from
"https://unicode.org/Public/MAPPINGS/ISO8859/8859-*.TXT" and
"https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP125*.TXT" */
/* libzint - the open source barcode library
/* eci_sb.h - Extended Channel Interpretations single-byte, generated by "backend/tools/gen_eci_sb_h.php"
from "https://unicode.org/Public/MAPPINGS/ISO8859/8859-*.TXT"
and "https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP125*.TXT" */
/*
libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without

View file

@ -1,6 +1,5 @@
/* gb18030.h - tables for Unicode to GB 18030-2005,
generated by "backend/tools/gen_eci_mb_h.php" from
"jdk-1.4.2/GB18030.TXT"
/* gb18030.h - tables for Unicode to GB 18030-2005, generated by "backend/tools/gen_eci_mb_h.php"
from "jdk-1.4.2/GB18030.TXT"
(see https://haible.de/bruno/charsets/conversion-tables/GB18030.tar.bz2) */
/*
libzint - the open source barcode library

View file

@ -1,6 +1,5 @@
/* gb2312.h - tables for Unicode to GB 2312-1980 (EUC-CN),
generated by "backend/tools/gen_eci_mb_h.php" from
"unicode.org-mappings/EASTASIA/GB/GB2312.TXT"
/* gb2312.h - tables for Unicode to GB 2312-1980 (EUC-CN), generated by "backend/tools/gen_eci_mb_h.php"
from "unicode.org-mappings/EASTASIA/GB/GB2312.TXT"
(see https://haible.de/bruno/charsets/conversion-tables/GB2312.tar.bz2) */
/*
libzint - the open source barcode library

View file

@ -1,6 +1,5 @@
/* gbk.h - tables for Unicode to GBK, excluding mappings in GB 2312,
generated by "backend/tools/gen_eci_mb_h.php" from
"https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT" */
/* gbk.h - tables for Unicode to GBK, excluding mappings in GB 2312, generated by "backend/tools/gen_eci_mb_h.php"
from "https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT" */
/*
libzint - the open source barcode library
Copyright (C) 2022 Robin Stuart <rstuart114@gmail.com>

View file

@ -1,5 +1,4 @@
/* general_field.c - Handles general field compaction (GS1 DataBar and composites) */
/*
libzint - the open source barcode library
Copyright (C) 2019-2022 Robin Stuart <rstuart114@gmail.com>
@ -29,6 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include "common.h"
#include "general_field.h"
@ -39,10 +39,10 @@ static const char isoiec_puncs[] = "!\"%&'()*+,-./:;<=>?_ "; /* Note contains sp
/* Returns type of char at `i`. FNC1 counted as NUMERIC. Returns 0 if invalid char */
static int general_field_type(const char *general_field, const int i) {
if (general_field[i] == '[' || (general_field[i] >= '0' && general_field[i] <= '9')) {
if (general_field[i] == '[' || z_isdigit(general_field[i])) {
return NUMERIC;
}
if ((general_field[i] >= 'A' && general_field[i] <= 'Z') || posn(alphanum_puncs, general_field[i]) != -1) {
if (z_isupper(general_field[i]) || posn(alphanum_puncs, general_field[i]) != -1) {
return ALPHANUMERIC;
}
if (is_sane(IS_ISOIEC_F, (const unsigned char *) general_field + i, 1)) {
@ -150,10 +150,10 @@ INTERNAL int general_field_encode(const char *general_field, const int general_f
/* 7.2.5.5.2/5.4.2 d) */
bp = bin_append_posn(0, 3, binary_string, bp); /* Numeric latch "000" */
mode = NUMERIC;
} else if ((general_field[i] >= '0') && (general_field[i] <= '9')) {
} else if (z_isdigit(general_field[i])) {
bp = bin_append_posn(general_field[i] - 43, 5, binary_string, bp);
i++;
} else if ((general_field[i] >= 'A') && (general_field[i] <= 'Z')) {
} else if (z_isupper(general_field[i])) {
bp = bin_append_posn(general_field[i] - 33, 6, binary_string, bp);
i++;
} else {
@ -180,13 +180,13 @@ INTERNAL int general_field_encode(const char *general_field, const int general_f
/* Note this rule can produce longer bitstreams if most of the alphanumerics are numeric */
bp = bin_append_posn(4, 5, binary_string, bp); /* Alphanumeric latch "00100" */
mode = ALPHANUMERIC;
} else if ((general_field[i] >= '0') && (general_field[i] <= '9')) {
} else if (z_isdigit(general_field[i])) {
bp = bin_append_posn(general_field[i] - 43, 5, binary_string, bp);
i++;
} else if ((general_field[i] >= 'A') && (general_field[i] <= 'Z')) {
} else if (z_isupper(general_field[i])) {
bp = bin_append_posn(general_field[i] - 1, 7, binary_string, bp);
i++;
} else if ((general_field[i] >= 'a') && (general_field[i] <= 'z')) {
} else if (z_islower(general_field[i])) {
bp = bin_append_posn(general_field[i] - 7, 7, binary_string, bp);
i++;
} else {

View file

@ -28,6 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
/* This file implements Grid Matrix as specified in
AIM Global Document Number AIMD014 Rev. 1.63 Revised 9 Dec 2008 */
@ -69,7 +70,7 @@ static int gm_in_numeral(const unsigned int ddata[], const int length, const int
block of three numeric characters) */
for (i = in_posn, digit_cnt = 0, nondigit = 0, nondigit_posn = 0; i < length && i < in_posn + 4 && digit_cnt < 3;
i++) {
if (ddata[i] >= '0' && ddata[i] <= '9') {
if (z_isdigit(ddata[i])) {
digit_cnt++;
} else if (posn(gm_numeral_nondigits, (const char) ddata[i]) != -1) {
if (nondigit) {
@ -187,11 +188,11 @@ static void gm_define_mode(char *mode, const unsigned int ddata[], const int len
if (!double_byte) {
space = ddata[i] == ' ';
if (!space) {
numeric = ddata[i] >= '0' && ddata[i] <= '9';
numeric = z_isdigit(ddata[i]);
if (!numeric) {
lower = ddata[i] >= 'a' && ddata[i] <= 'z';
lower = z_islower(ddata[i]);
if (!lower) {
upper = ddata[i] >= 'A' && ddata[i] <= 'Z';
upper = z_isupper(ddata[i]);
if (!upper) {
control = ddata[i] < 0x7F; /* Exclude DEL */
if (control && i + 1 < length) {
@ -200,7 +201,7 @@ static void gm_define_mode(char *mode, const unsigned int ddata[], const int len
}
}
} else if (i + 1 < length) {
double_digit = ddata[i + 1] >= '0' && ddata[i + 1] <= '9';
double_digit = z_isdigit(ddata[i + 1]);
}
}
}
@ -523,8 +524,7 @@ static int gm_encode(unsigned int ddata[], const int length, char binary[], cons
}
if (!(done)) {
if (sp != (length - 1)) {
if (((ddata[sp] >= '0') && (ddata[sp] <= '9')) &&
((ddata[sp + 1] >= '0') && (ddata[sp + 1] <= '9'))) {
if (z_isdigit(ddata[sp]) && z_isdigit(ddata[sp + 1])) {
/* Two digits */
glyph = 8033 + (10 * (ddata[sp] - '0')) + (ddata[sp + 1] - '0');
sp++;
@ -561,7 +561,7 @@ static int gm_encode(unsigned int ddata[], const int length, char binary[], cons
numbuf[1] = '0';
numbuf[2] = '0';
do {
if ((ddata[sp] >= '0') && (ddata[sp] <= '9')) {
if (z_isdigit(ddata[sp])) {
numbuf[p] = ddata[sp];
p++;
} else if (posn(gm_numeral_nondigits, (const char) ddata[sp]) != -1) {
@ -651,11 +651,11 @@ static int gm_encode(unsigned int ddata[], const int length, char binary[], cons
case GM_MIXED:
shift = 1;
if ((ddata[sp] >= '0') && (ddata[sp] <= '9')) {
if (z_isdigit(ddata[sp])) {
shift = 0;
} else if ((ddata[sp] >= 'A') && (ddata[sp] <= 'Z')) {
} else if (z_isupper(ddata[sp])) {
shift = 0;
} else if ((ddata[sp] >= 'a') && (ddata[sp] <= 'z')) {
} else if (z_islower(ddata[sp])) {
shift = 0;
} else if (ddata[sp] == ' ') {
shift = 0;
@ -680,7 +680,7 @@ static int gm_encode(unsigned int ddata[], const int length, char binary[], cons
case GM_UPPER:
shift = 1;
if ((ddata[sp] >= 'A') && (ddata[sp] <= 'Z')) {
if (z_isupper(ddata[sp])) {
shift = 0;
} else if (ddata[sp] == ' ') {
shift = 0;
@ -705,7 +705,7 @@ static int gm_encode(unsigned int ddata[], const int length, char binary[], cons
case GM_LOWER:
shift = 1;
if ((ddata[sp] >= 'a') && (ddata[sp] <= 'z')) {
if (z_islower(ddata[sp])) {
shift = 0;
} else if (ddata[sp] == ' ') {
shift = 0;

View file

@ -1,8 +1,7 @@
/* gs1.c - Verifies GS1 data */
/*
libzint - the open source barcode library
Copyright (C) 2009 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -29,7 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
#ifdef _MSC_VER
@ -55,7 +54,7 @@ static int numeric(const unsigned char *data, int data_len, int offset, int min,
const unsigned char *const de = d + (data_len > max ? max : data_len);
for (; d < de; d++) {
if (*d < '0' || *d > '9') {
if (!z_isdigit(*d)) {
*p_err_no = 3;
*p_err_posn = d - data + 1;
sprintf(err_msg, "Non-numeric character '%c'", *d);
@ -233,10 +232,10 @@ static int key(const unsigned char *data, int data_len, int offset, int min, int
if (!length_only && data_len) {
data += offset;
if (data[0] < '0' || data[0] > '9' || data[1] < '0' || data[1] > '9') {
if (!z_isdigit(data[0]) || !z_isdigit(data[1])) {
*p_err_no = 3;
*p_err_posn = offset + (data[0] < '0' || data[0] > '9' ? 0 : 1) + 1;
sprintf(err_msg, "Non-numeric company prefix '%c'", data[0] < '0' || data[0] > '9' ? data[0] : data[1]);
*p_err_posn = offset + z_isdigit(data[0]) + 1;
sprintf(err_msg, "Non-numeric company prefix '%c'", data[z_isdigit(data[0])]);
return 0;
}
}
@ -750,7 +749,7 @@ static int iban(const unsigned char *data, int data_len, int offset, int min, in
int checksum = 0;
int given_checksum;
if (d[0] < 'A' || d[0] > 'Z' || d[1] < 'A' || d[1] > 'Z') { /* 1st 2 chars alphabetic country code */
if (!z_isupper(d[0]) || !z_isupper(d[1])) { /* 1st 2 chars alphabetic country code */
*p_err_no = 3;
*p_err_posn = d - data + 1;
sprintf(err_msg, "Non-alphabetic IBAN country code '%.2s'", d);
@ -763,7 +762,7 @@ static int iban(const unsigned char *data, int data_len, int offset, int min, in
return 0;
}
d += 2;
if (d[0] < '0' || d[0] > '9' || d[1] < '0' || d[1] > '9') { /* 2nd 2 chars numeric checksum */
if (!z_isdigit(d[0]) || !z_isdigit(d[1])) { /* 2nd 2 chars numeric checksum */
*p_err_no = 3;
*p_err_posn = d - data + 1;
sprintf(err_msg, "Non-numeric IBAN checksum '%.2s'", d);
@ -863,7 +862,7 @@ static const unsigned char *coupon_vli(const unsigned char *data, const int data
}
de = d + vli + vli_offset;
for (; d < de; d++) {
if (*d < '0' || *d > '9') {
if (!z_isdigit(*d)) {
*p_err_no = 3;
*p_err_posn = d - data + 1;
sprintf(err_msg, "Non-numeric %s '%c'", name, *d);
@ -1256,7 +1255,7 @@ INTERNAL int gs1_verify(struct zint_symbol *symbol, const unsigned char source[]
ai_latch = 0;
} else if (ai_latch) {
ai_length++;
if ((source[i] < '0') || (source[i] > '9')) {
if (!z_isdigit(source[i])) {
ai_nonnumeric = 1;
}
}
@ -1399,3 +1398,5 @@ INTERNAL char gs1_check_digit(const unsigned char source[], const int length) {
return itoc((10 - (count % 10)) % 10);
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1,5 +1,5 @@
/* hanxin.c - Han Xin Code
/* hanxin.c - Han Xin Code */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>
@ -28,6 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
/* This code attempts to implement Han Xin Code according to ISO/IEC 20830:2021
* (previously ISO/IEC 20830 (draft 2019-10-10) and AIMD-015:2010 (Rev 0.8)) */
@ -45,15 +46,15 @@
/* Find which submode to use for a text character */
static int hx_getsubmode(const unsigned int input) {
if ((input >= '0') && (input <= '9')) {
if (z_isdigit(input)) {
return 1;
}
if ((input >= 'A') && (input <= 'Z')) {
if (z_isupper(input)) {
return 1;
}
if ((input >= 'a') && (input <= 'z')) {
if (z_islower(input)) {
return 1;
}
@ -253,15 +254,15 @@ static int hx_isFourByte(const unsigned int glyph, const unsigned int glyph2) {
/* Convert Text 1 sub-mode character to encoding value, as given in table 3 */
static int hx_lookup_text1(const unsigned int input) {
if ((input >= '0') && (input <= '9')) {
if (z_isdigit(input)) {
return input - '0';
}
if ((input >= 'A') && (input <= 'Z')) {
if (z_isupper(input)) {
return input - 'A' + 10;
}
if ((input >= 'a') && (input <= 'z')) {
if (z_islower(input)) {
return input - 'a' + 36;
}
@ -310,7 +311,7 @@ static int hx_in_numeric(const unsigned int ddata[], const int length, const int
}
/* Attempt to calculate the average 'cost' of using numeric mode in number of bits (times HX_MULT) */
for (i = in_posn; i < length && i < in_posn + 4 && ddata[i] >= '0' && ddata[i] <= '9'; i++);
for (i = in_posn; i < length && i < in_posn + 4 && z_isdigit(ddata[i]); i++);
digit_cnt = i - in_posn;

View file

@ -1,6 +1,5 @@
/* ksx1001.h - tables for Unicode to EUC-KR (KS X 1001),
generated by "backend/tools/gen_eci_mb_h.php" from
"https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/KSX1001.TXT" */
/* ksx1001.h - tables for Unicode to EUC-KR (KS X 1001), generated by "backend/tools/gen_eci_mb_h.php"
from "https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/KSX1001.TXT" */
/*
libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>

View file

@ -1,5 +1,4 @@
/* large.c - Handles binary manipulation of large numbers */
/*
libzint - the open source barcode library
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
@ -59,7 +58,7 @@
INTERNAL void large_load_str_u64(large_int *t, const unsigned char *s, const int length) {
uint64_t val = 0;
const unsigned char *const se = s + length;
for (; s < se && *s >= '0' && *s <= '9'; s++) {
for (; s < se && z_isdigit(*s); s++) {
val *= 10;
val += *s - '0';
}

View file

@ -1,8 +1,7 @@
/* mailmark.c - Royal Mail 4-state Mailmark barcodes */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -29,7 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* Developed in accordance with "Royal Mail Mailmark barcode C encoding and deconding instructions"
@ -206,7 +205,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
// Supply Chain ID is 2 digits for barcode C and 6 digits for barcode L
supply_chain_id = 0;
for (i = 3; i < (length - 17); i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
if (z_isdigit(local_source[i])) {
supply_chain_id *= 10;
supply_chain_id += ctoi(local_source[i]);
} else {
@ -218,7 +217,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
// Item ID is 8 digits
item_id = 0;
for (i = length - 17; i < (length - 9); i++) {
if ((local_source[i] >= '0') && (local_source[i] <= '9')) {
if (z_isdigit(local_source[i])) {
item_id *= 10;
item_id += ctoi(local_source[i]);
} else {
@ -253,8 +252,8 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
} else {
if (postcode[8] == ' ') {
// Types 1, 2 and 6
if ((postcode[1] >= '0') && (postcode[1] <= '9')) {
if ((postcode[2] >= '0') && (postcode[2] <= '9')) {
if (z_isdigit(postcode[1])) {
if (z_isdigit(postcode[2])) {
postcode_type = 6;
} else {
postcode_type = 1;
@ -264,7 +263,7 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
}
} else {
// Types 3 and 4
if ((postcode[3] >= '0') && (postcode[3] <= '9')) {
if (z_isdigit(postcode[3])) {
postcode_type = 3;
} else {
postcode_type = 4;
@ -510,3 +509,5 @@ INTERNAL int mailmark(struct zint_symbol *symbol, unsigned char source[], int le
return error_number;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -1,5 +1,4 @@
/* maxicode.c - Handles MaxiCode */
/*
libzint - the open source barcode library
Copyright (C) 2010-2022 Robin Stuart <rstuart114@gmail.com>
@ -29,6 +28,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
/* Includes corrections thanks to Monica Swanson @ Source Technologies */
#include <stdio.h>
@ -571,7 +571,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
} else {
mode = 2;
for (i = 0; i < lp - 6; i++) {
if (((symbol->primary[i] < '0') || (symbol->primary[i] > '9')) && (symbol->primary[i] != ' ')) {
if (!z_isdigit(symbol->primary[i]) && (symbol->primary[i] != ' ')) {
mode = 3;
break;
}
@ -615,7 +615,7 @@ INTERNAL int maxicode(struct zint_symbol *symbol, struct zint_seg segs[], const
postcode[i] = '\0';
postcode_len = i;
break;
} else if (postcode[i] < '0' || postcode[i] > '9') {
} else if (!z_isdigit(postcode[i])) {
strcpy(symbol->errtxt, "555: Non-numeric postcode in Primary Message");
return ZINT_ERROR_INVALID_DATA;
}

View file

@ -1,6 +1,6 @@
/* pdf417.c - Handles PDF417 stacked symbology */
/* Zint - A barcode generating program using libpng
/*
libzint - the open source barcode library
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
Portions Copyright (C) 2004 Grandzebu
Bug Fixes thanks to KL Chin <klchin@users.sourceforge.net>
@ -30,6 +30,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
/* This code is adapted from "Code barre PDF 417 / PDF 417 barcode" v2.5.0
which is Copyright (C) 2004 (Grandzebu).
@ -99,7 +100,7 @@ static const char pdf_MicroAutosize[56] = {
/* 866 */
static int pdf_quelmode(const unsigned char codeascii) {
if ((codeascii <= '9') && (codeascii >= '0')) {
if (z_isdigit(codeascii)) {
return NUM;
}
if (codeascii < 127 && pdf_asciix[codeascii]) {

View file

@ -1,8 +1,7 @@
/* postal.c - Handles PostNet, PLANET, FIM. RM4SCC and Flattermarken */
/*
libzint - the open source barcode library
Copyright (C) 2008 - 2021 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
Including bug fixes by Bryan Hatton
Redistribution and use in source and binary forms, with or without
@ -30,7 +29,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* vim: set ts=4 sw=4 et : */
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
#ifdef _MSC_VER
@ -646,7 +645,7 @@ INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int l
i = 0;
inter_posn = 0;
do {
if (((source[i] >= '0') && (source[i] <= '9')) || (source[i] == '-')) {
if (z_isdigit(source[i]) || (source[i] == '-')) {
inter[inter_posn] = source[i];
inter_posn++;
} else {
@ -732,3 +731,5 @@ INTERNAL int japanpost(struct zint_symbol *symbol, unsigned char source[], int l
return error_number;
}
/* vim: set ts=4 sw=4 et : */

View file

@ -80,7 +80,7 @@ static int qr_in_numeric(const unsigned int ddata[], const int length, const int
}
/* Attempt to calculate the average 'cost' of using numeric mode in number of bits (times QR_MULT) */
for (i = in_posn; i < length && i < in_posn + 4 && ddata[i] >= '0' && ddata[i] <= '9'; i++);
for (i = in_posn; i < length && i < in_posn + 4 && z_isdigit(ddata[i]); i++);
digit_cnt = i - in_posn;
@ -2542,7 +2542,7 @@ INTERNAL int microqr(struct zint_symbol *symbol, unsigned char source[], int len
/* Determine if alpha (excluding numerics), byte or kanji used */
for (i = 0; i < length && (alpha_used == 0 || byte_or_kanji_used == 0); i++) {
if (ddata[i] < '0' || ddata[i] > '9') {
if (!z_isdigit(ddata[i])) {
if (qr_is_alpha(ddata[i], 0 /*gs1*/)) {
alpha_used = 1;
} else {

View file

@ -968,7 +968,7 @@ static int dbar_exp_binary_string(struct zint_symbol *symbol, const unsigned cha
/* Verify that the data to be placed in the compressed data field is all
numeric data before carrying out compression */
for (i = 0; i < read_posn; i++) {
if ((source[i] < '0') || (source[i] > '9')) {
if (!z_isdigit(source[i])) {
if (source[i] != '[') {
/* Something is wrong */
strcpy(symbol->errtxt, "385: Invalid character in Compressed Field data (digits only)");

View file

@ -1,6 +1,5 @@
/* sjis.h - tables for Unicode to Shift JIS,
generated by "backend/tools/gen_eci_mb_h.php" from
"https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT" */
/* sjis.h - tables for Unicode to Shift JIS, generated by "backend/tools/gen_eci_mb_h.php"
from "https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT" */
/*
libzint - the open source barcode library
Copyright (C) 2009-2022 Robin Stuart <rstuart114@gmail.com>

View file

@ -27,6 +27,7 @@
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/* SPDX-License-Identifier: BSD-3-Clause */
#include "testcommon.h"
@ -153,17 +154,17 @@ static void test_input(int index, int debug) {
/* 7*/ { BARCODE_AUSPOST, "12345678ABCDefgh #", 0, 3, 133, "" }, // Length 18
/* 8*/ { BARCODE_AUSPOST, "12345678901234567890123", 0, 3, 133, "" },
/* 9*/ { BARCODE_AUSPOST, "1234567890123456789012A", ZINT_ERROR_INVALID_DATA, -1, -1, "Error 406: Invalid character in data (digits only for length 23)" },
/* 10*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Auspost input is wrong length (8, 13, 16, 18 or 23 characters only)" }, // No leading zeroes added
/* 10*/ { BARCODE_AUSPOST, "1234567", ZINT_ERROR_TOO_LONG, -1, -1, "Error 401: Input wrong length (8, 13, 16, 18 or 23 characters only)" }, // No leading zeroes added
/* 11*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "" },
/* 12*/ { BARCODE_AUSREPLY, "1234567", 0, 3, 73, "" }, // Leading zeroes added
/* 13*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Auspost input is too long (8 character maximum)" },
/* 13*/ { BARCODE_AUSREPLY, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input too long (8 character maximum)" },
/* 14*/ { BARCODE_AUSROUTE, "123456", 0, 3, 73, "" },
/* 15*/ { BARCODE_AUSROUTE, "12345", 0, 3, 73, "" },
/* 16*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Auspost input is too long (8 character maximum)" },
/* 16*/ { BARCODE_AUSROUTE, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input too long (8 character maximum)" },
/* 17*/ { BARCODE_AUSREDIRECT, "1234", 0, 3, 73, "" },
/* 18*/ { BARCODE_AUSREDIRECT, "123", 0, 3, 73, "" },
/* 19*/ { BARCODE_AUSREDIRECT, "0", 0, 3, 73, "" },
/* 20*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Auspost input is too long (8 character maximum)" },
/* 20*/ { BARCODE_AUSREDIRECT, "123456789", ZINT_ERROR_TOO_LONG, -1, -1, "Error 403: Input too long (8 character maximum)" },
};
int data_size = ARRAY_SIZE(data);
int i, length, ret;
@ -195,8 +196,10 @@ static void test_input(int index, int debug) {
testFinish();
}
// Australia Post Customer Barcoding Technical Specifications (Revised Aug 2012)
// Australia Post Customer Barcoding Technical Specifications (Revised 3 Aug 2012) "AusPost Tech Specs"
// https://auspost.com.au/content/dam/auspost_corp/media/documents/customer-barcode-technical-specifications-aug2012.pdf
// Australia Post A Guide To Printing the 4-State Barcode (Revised 16 March 2012) "AusPost Guide"
// https://auspost.com.au/content/dam/auspost_corp/media/documents/a-guide-to-printing-the-4state-barcode-v31-mar2012.pdf
static void test_encode(int index, int generate, int debug) {
struct item {
@ -210,67 +213,77 @@ static void test_encode(int index, int generate, int debug) {
char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_AUSPOST, "96184209", 0, 3, 73, "Australia Post Customer Barcoding Tech Specs Diagram 1; verified manually against tec-it",
/* 0*/ { BARCODE_AUSPOST, "96184209", 0, 3, 73, "AusPost Tech Specs Diagram 1; verified manually against TEC-IT",
"1000101010100010001010100000101010001010001000001010000010001000001000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000100010000010101010001010000010101010001000101010001000100010000010000"
},
/* 1*/ { BARCODE_AUSPOST, "3221132412345678", 0, 3, 103, "59 Custom 2 N encoding",
/* 1*/ { BARCODE_AUSPOST, "39549554", 0, 3, 73, "AusPost Guide Figure 3, same; verified manually against TEC-IT",
"1000101010101010001010001010001010001000101000001000101010001010000000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000100010000010001000100000001000100010000000000010001000000000001010000"
},
/* 2*/ { BARCODE_AUSPOST, "56439111ABA 9", 0, 3, 103, "AusPost Guide Figure 4, same; verified manually against TEC-IT",
"1000100000101000001010101010001010101010101010101010101010101010100000000000001010100010101010000010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000001000100010101000000010001010001000100010101010100010101010100000101000000010001000101010000000000"
},
/* 3*/ { BARCODE_AUSPOST, "3221132412345678", 0, 3, 103, "59 Custom 2 N encoding",
"1000100000101010100010001010101010101000101010101000101010101000001000100000101000000000001000000000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000001000100010101010101000100000101010000010001010001000000010101010001010000010001010101000100000000"
},
/* 2*/ { BARCODE_AUSPOST, "32211324Ab #2", 0, 3, 103, "59 Custom 2 C encoding",
/* 4*/ { BARCODE_AUSPOST, "32211324Ab #2", 0, 3, 103, "59 Custom 2 C encoding",
"1000100000101010100010001010101010101000101010101010001010100010100000101000100000000010100000100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000001000100010101010101000100000101010000010101010001010100010000000100000001000101010000010000000000"
},
/* 3*/ { BARCODE_AUSPOST, "32211324123456789012345", 0, 3, 133, "62 Custom 3 N encoding",
/* 5*/ { BARCODE_AUSPOST, "32211324123456789012345", 0, 3, 133, "62 Custom 3 N encoding",
"1000001010001010100010001010101010101000101010101000101010101000001000100000001010101010100010101010100000100000100010101010100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010100010101010101000100000101010000010001010001000000010101010001010001010101000101000100000001000001010000010001010100010000"
},
/* 4*/ { BARCODE_AUSPOST, "32211324aBCd#F hIz", 0, 3, 133, "62 Custom 3 C encoding",
/* 6*/ { BARCODE_AUSPOST, "32211324aBCd#F hIz", 0, 3, 133, "62 Custom 3 C encoding",
"1000001010001010100010001010101010101000101010000010101010100010000010100010100010100010000010000000000000100010100010101010000000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010100010101010101000100000101010000010100010100010101010001010000010001010100000100010101000000000101000001010100000000010000"
},
/* 5*/ { BARCODE_AUSPOST, "12345678DEGHJKLMNO", 0, 3, 133, "62 Custom 3 C encoding GDSET 1st part",
/* 7*/ { BARCODE_AUSPOST, "12345678DEGHJKLMNO", 0, 3, 133, "62 Custom 3 C encoding GDSET 1st part",
"1000001010001010100010101010100000100010000010101010101010001010001010101010101010100010101010101010100000001010000010000000000010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010101000101000100000001010101000101010001010000010101010100000101000100000101000001000000000001000001010000010001010001010000"
},
/* 6*/ { BARCODE_AUSPOST, "23456789PQRSTUVWXY", 0, 3, 133, "62 Custom 3 C encoding GDSET 2nd part",
/* 8*/ { BARCODE_AUSPOST, "23456789PQRSTUVWXY", 0, 3, 133, "62 Custom 3 C encoding GDSET 2nd part",
"1000001010001000101010101000001000100000001010001010001010000000101000101000100000101000101000100000001000101000101010101000101010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010101010001000000010101010001010001000101000100000101010101010100010101010001010000010001010101000000010001000001010101000000"
},
/* 7*/ { BARCODE_AUSPOST, "34567890Zcefgijklm", 0, 3, 133, "62 Custom 3 C encoding GDSET 3rd part",
/* 9*/ { BARCODE_AUSPOST, "34567890Zcefgijklm", 0, 3, 133, "62 Custom 3 C encoding GDSET 3rd part",
"1000001010001010101010000010001000000010101000001010001010000010100010100010001010001010000010000000100000101000100000001010001010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010100010000000101010100010100010101010100010000010000000100000000000001000000000001000000010100000101000000010101010100010000"
},
/* 8*/ { BARCODE_AUSPOST, "12345678lnopqrstuv", 0, 3, 133, "62 Custom 3 C encoding GDSET 4th part",
/* 10*/ { BARCODE_AUSPOST, "12345678lnopqrstuv", 0, 3, 133, "62 Custom 3 C encoding GDSET 4th part",
"1000001010001010100010101010100000100010000010000000100000000000001000001000000000000000100000100000000000001010001010101000000010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010101000101000100000001010101000101000000010000010100010001010000010001010000000100000000000100000100000001010001000100000000"
},
/* 9*/ { BARCODE_AUSPOST, "09876543wxy# ", 0, 3, 103, "59 Custom 2 C encoding GDSET 5th part",
/* 11*/ { BARCODE_AUSPOST, "09876543wxy# ", 0, 3, 103, "59 Custom 2 C encoding GDSET 5th part",
"1000100000101010001000000010001010001010101000001000001000000010100010100000100010000000000010100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
"0000001000101010001010101000101000100000001000001000000000001010000010100000001010001000001000100000000"
},
/* 10*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "Verified manually against tec-it",
/* 12*/ { BARCODE_AUSREPLY, "12345678", 0, 3, 73, "Verified manually against tec-it",
"1000101010001010100010101010100000100010000000001000001000000000100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000000000101000101000100000001010101000101000000000100010101000101000000"
},
/* 11*/ { BARCODE_AUSROUTE, "34567890", 0, 3, 73, "Verified manually against tec-it",
/* 13*/ { BARCODE_AUSROUTE, "34567890", 0, 3, 73, "Verified manually against tec-it",
"1000000000101010101010000010001000000010101000100010101010000000101000100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000101010000010000000101010100010100010101000100010101010001010001000000"
},
/* 12*/ { BARCODE_AUSREDIRECT, "98765432", 0, 3, 73, "Verified manually against tec-it",
/* 14*/ { BARCODE_AUSREDIRECT, "98765432", 0, 3, 73, "Verified manually against tec-it",
"1000001010000010000000100010100010101010100000101010101000100010100010100"
"1010101010101010101010101010101010101010101010101010101010101010101010101"
"0000001010100010101010001010001000000010101000000000001010101000001010000"

View file

@ -2695,8 +2695,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
mode = 4;
} else {
for (i = 0; i < primary_len - 6; i++) {
if (((symbol->primary[i] < '0') || (symbol->primary[i] > '9'))
&& (symbol->primary[i] != ' ')) {
if (!z_isdigit(symbol->primary[i]) && (symbol->primary[i] != ' ')) {
mode = 3;
break;
}
@ -2821,7 +2820,7 @@ int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int
memcpy(macro_eci_buf, bwipp_data + 10, 13); /* Macro */
memcpy(bwipp_data + 13, bwipp_data, 10); /* ECI */
memcpy(bwipp_data, macro_eci_buf, 13);
} else if (data[4] >= '0' && data[4] <= '9' && data[5] >= '0' && data[5] <= '9') {
} else if (z_isdigit(data[4]) && z_isdigit(data[5])) {
memcpy(macro_eci_buf, bwipp_data, 10); /* ECI */
memcpy(bwipp_data, bwipp_data + 10, 9); /* Macro */
memcpy(bwipp_data + 9, macro_eci_buf, 10);
@ -3119,7 +3118,7 @@ int testUtilBwippCmp(const struct zint_symbol *symbol, char *msg, char *cmp_buf,
if (symbol->symbology == BARCODE_ULTRA) {
static const char map[] = { '8', '1', '2', '3', '4', '5', '6', '7', '8', '7' };
for (i = 0; i < cmp_len; i++) {
if (cmp_buf[i] >= '0' && cmp_buf[i] <= '9') {
if (z_isdigit(cmp_buf[i])) {
cmp_buf[i] = map[cmp_buf[i] - '0'];
}
}

View file

@ -6,7 +6,7 @@
*/
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* To create "backend/eci_mb.h" (from project root directory):
* To create "backend/eci_big5/gb18030/gb2312/gbk/ksx1001/sjis.h" (from project root directory):
*
* php backend/tools/gen_eci_mb_h.php
*
@ -14,7 +14,7 @@
* https://haible.de/bruno/charsets/conversion-tables/GB18030.tar.bz2
* using the version jdk-1.4.2/GB18030.TXT
*/
// 'zint.assertions' should set to 1 in php.ini
// 'zend.assertions' should set to 1 in php.ini
$copyright_text = <<<'EOD'
@ -59,13 +59,12 @@ $year = 2022;
function out_header(&$out, $name, $descr, $file, $start_year = 0, $extra_comment = '') {
global $copyright_text, $basename, $year;
$caps = strtoupper($name);
$out[] = '/* ' . $name . '.h - tables for Unicode to ' . $descr . ',';
$out[] = ' ' . 'generated by "backend/tools/' . $basename . '" from';
$out[] = '/* ' . $name . '.h - tables for Unicode to ' . $descr . ', generated by "backend/tools/' . $basename . '"';
if ($extra_comment !== '') {
$out[] = ' "' . $file . '"';
$out[] = ' from "' . $file . '"';
$out[] = ' ' . $extra_comment . ' */';
} else {
$out[] = ' "' . $file . '" */';
$out[] = ' from "' . $file . '" */';
}
$out[] = '/*';
$out[] = ' libzint - the open source barcode library';

View file

@ -4,6 +4,7 @@
libzint - the open source barcode library
Copyright (C) 2022 Robin Stuart <rstuart114@gmail.com>
*/
/* SPDX-License-Identifier: BSD-3-Clause */
/*
* To create "backend/eci_sb.h" (from project root directory):
*
@ -24,11 +25,11 @@ $out_dirname = isset($opts['o']) ? $opts['o'] : ($dirname . '/..'); // Where to
$out = array();
$head = <<<'EOD'
/* eci_sb.h - Extended Channel Interpretations single-byte,
generated by "backend/tools/gen_eci_sb_h.php" from
"https://unicode.org/Public/MAPPINGS/ISO8859/8859-*.TXT" and
"https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP125*.TXT" */
/* libzint - the open source barcode library
/* eci_sb.h - Extended Channel Interpretations single-byte, generated by "backend/tools/gen_eci_sb_h.php"
from "https://unicode.org/Public/MAPPINGS/ISO8859/8859-*.TXT"
and "https://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP125*.TXT" */
/*
libzint - the open source barcode library
Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 140 KiB

View file

@ -470,7 +470,7 @@ Sequence Equivalent
`\uNNNN` Any 16-bit Unicode BMP[^2] character where
NNNN is hexadecimal
`\UNNNNNN` Any 20-bit Unicode character where NNNNNN
`\UNNNNNN` Any 21-bit Unicode character where NNNNNN
is hexadecimal (maximum 0x10FFFF)
---------------------------------------------------------------------------

View file

@ -620,7 +620,7 @@ sequences are shown in the table below.
\uNNNN Any 16-bit Unicode BMP[2] character where
NNNN is hexadecimal
\UNNNNNN Any 20-bit Unicode character where NNNNNN
\UNNNNNN Any 21-bit Unicode character where NNNNNN
is hexadecimal (maximum 0x10FFFF)
----------------------------------------------------------------------------
@ -4246,7 +4246,7 @@ OPTIONS
hexadecimal
\uNNNN (U+NNNN) Any 16-bit Unicode BMP character
where NNNN is hexadecimal
\UNNNNNN (U+NNNNNN) Any 20-bit Unicode character
\UNNNNNN (U+NNNNNN) Any 21-bit Unicode character
where NNNNNN is hexadecimal
--fast

View file

@ -186,7 +186,7 @@ The escape sequences are:
hexadecimal
\[rs]uNNNN (U+NNNN) Any 16-bit Unicode BMP character
where NNNN is hexadecimal
\[rs]UNNNNNN (U+NNNNNN) Any 20-bit Unicode character
\[rs]UNNNNNN (U+NNNNNN) Any 21-bit Unicode character
where NNNNNN is hexadecimal
\f[R]
.fi

View file

@ -139,7 +139,7 @@ Paintbrush (`PCX`), Portable Network Format (`PNG`), Scalable Vector Graphic (`S
hexadecimal
\uNNNN (U+NNNN) Any 16-bit Unicode BMP character
where NNNN is hexadecimal
\UNNNNNN (U+NNNNNN) Any 20-bit Unicode character
\UNNNNNN (U+NNNNNN) Any 21-bit Unicode character
where NNNNNN is hexadecimal
`--fast`

View file

@ -133,7 +133,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="0" colspan="2">
<widget class="QLineEdit" name="linSeqFormat">
<property name="toolTip">
<string>Format sequence using special characters&lt;table cellspacing=&quot;3&quot;&gt;
@ -148,7 +148,7 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horzLayoutSeqCreateBtn">
<item>
<spacer name="horzSpacerSeqCreateBtn">

View file

@ -28,6 +28,10 @@ int main(int argc, char *argv[])
/* Suppresses "Qt WebEngine seems to be initialized from a plugin" warning */
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
#endif
#if defined(_WIN32) && QT_VERSION >= 0x50A01
/* Suppresses help question mark in dialogs */
QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
#endif
QApplication app(argc, argv);

View file

@ -25,9 +25,6 @@
<locale language="English" country="UnitedStates"/>
</property>
<layout class="QVBoxLayout" name="vLayoutMain">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<widget class="QGraphicsView" name="view">
<property name="minimumSize">
@ -1535,7 +1532,7 @@ or import from file</string>
&lt;tr&gt;&lt;td&gt;\dNNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;8-bit character (N decimal)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\xNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;8-bit character (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\uNNNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;16-bit Unicode BMP (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\UNNNNNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;20-bit Unicode (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;\UNNNNNN&amp;nbsp;&lt;/td&gt;&lt;td&gt;21-bit Unicode (N hex)&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</string>
</property>
<property name="text">