mirror of
https://github.com/woo-j/zint.git
synced 2024-12-23 01:33:55 +03:00
Merge /u/gitlost/zint/ branch eci_part3_2022 into master
https://sourceforge.net/p/zint/code/merge-requests/149/
This commit is contained in:
commit
3b9d989894
@ -16,6 +16,10 @@ Version 2.10.0.9 (dev) not released yet
|
||||
- Matrix symbols: horizontal boundary bars appear outside any vertical
|
||||
whitespace
|
||||
NOTE: previously appeared inside vertical whitespace
|
||||
- ECI 29 now GB 2312 only; GB 18030 is new ECI 32
|
||||
NOTE: previously ECI 29 was GB 18030 for HANXIN, GB 2312 otherwise
|
||||
- GRIDMATRIX, HANXIN, QRCODE/RMQR now warn when convert to GB 2312, GB 18030,
|
||||
Shift JIS resp. and no ECI given
|
||||
|
||||
Changes
|
||||
-------
|
||||
@ -53,6 +57,10 @@ Changes
|
||||
- Matrix symbols: change horizontal boundary bars to appear outside any
|
||||
vertical whitespace, as they're decorative rather than functional (#247)
|
||||
- FIM: Add support for FIM E
|
||||
- Updated ECIs to AIM ITS/04-023:2022 (ECI Part 3: Register)
|
||||
- HANXIN: removed alternating filler in function information
|
||||
- GRIDMATRIX/HANXIN/QRCODE/RMQR: warn if auto-conversion (i.e. no ECI given)
|
||||
occurs to resp. specialized char sets (GB 2312/GB 18030/Shift JIS)
|
||||
|
||||
Bugs
|
||||
----
|
||||
@ -76,6 +84,7 @@ Bugs
|
||||
props Alex Geller
|
||||
- DATAMATRIX: fix mis-encoding of FNC1/GS in EDIFACT in GS1 mode
|
||||
- Allow for dot overspill in height of vertical box sides (dotty mode)
|
||||
- HANXIN: fix gate-posts on codeword limits
|
||||
|
||||
|
||||
Version 2.10.0 2021-08-14
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* eci.c - Extended Channel Interpretations
|
||||
|
||||
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
|
||||
@ -28,7 +28,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
@ -40,6 +39,7 @@
|
||||
#include "big5.h"
|
||||
#include "gb2312.h"
|
||||
#include "ksx1001.h"
|
||||
#include "gb18030.h"
|
||||
|
||||
/* ECI 20 Shift JIS */
|
||||
static int sjis_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
@ -126,6 +126,47 @@ static int euc_kr_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ECI 31 GBK Chinese */
|
||||
static int gbk_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
unsigned int c;
|
||||
|
||||
if (wc < 0x80) {
|
||||
*r = (unsigned char) wc;
|
||||
return 1;
|
||||
}
|
||||
if (gbk_wctomb_zint(&c, wc)) {
|
||||
r[0] = (unsigned char) (c >> 8);
|
||||
r[1] = (unsigned char) (c & 0xff);
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ECI 32 GB 18030 Chinese */
|
||||
static int gb18030_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
unsigned int c1, c2;
|
||||
int ret;
|
||||
|
||||
if (wc < 0x80) {
|
||||
*r = (unsigned char) wc;
|
||||
return 1;
|
||||
}
|
||||
ret = gb18030_wctomb_zint(&c1, &c2, wc);
|
||||
if (ret == 2) {
|
||||
r[0] = (unsigned char) (c1 >> 8);
|
||||
r[1] = (unsigned char) (c1 & 0xff);
|
||||
return 2;
|
||||
}
|
||||
if (ret == 4) {
|
||||
r[0] = (unsigned char) (c1 >> 8);
|
||||
r[1] = (unsigned char) (c1 & 0xff);
|
||||
r[2] = (unsigned char) (c2 >> 8);
|
||||
r[3] = (unsigned char) (c2 & 0xff);
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper to count the number of chars in a string within a range */
|
||||
static int chr_range_cnt(const unsigned char string[], const int length, const unsigned char c1,
|
||||
const unsigned char c2) {
|
||||
@ -149,8 +190,8 @@ static int chr_range_cnt(const unsigned char string[], const int length, const u
|
||||
|
||||
/* Is ECI convertible from UTF-8? */
|
||||
INTERNAL int is_eci_convertible(const int eci) {
|
||||
if (eci == 26 || (eci > 30 && eci != 170)) { /* Exclude ECI 170 - ASCII Invariant */
|
||||
/* UTF-8 (26) or 8-bit binary data (899) or undefined (> 30 and < 899) or not character set (> 899) */
|
||||
if (eci == 26 || (eci > 35 && eci != 170)) { /* Exclude ECI 170 - ASCII Invariant */
|
||||
/* UTF-8 (26) or 8-bit binary data (899) or undefined (> 35 and < 899) or not character set (> 899) */
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -162,16 +203,21 @@ INTERNAL int get_eci_length(const int eci, const unsigned char source[], int len
|
||||
/* Only ASCII backslash (reverse solidus) exceeds UTF-8 length */
|
||||
length += chr_cnt(source, length, '\\');
|
||||
|
||||
} else if (eci == 25) { /* UCS-2BE */
|
||||
} else if (eci == 25 || eci == 33) { /* UTF-16 */
|
||||
/* All ASCII chars take 2 bytes */
|
||||
length += chr_range_cnt(source, length, 0, 0x7F);
|
||||
/* Surrogate pairs are 4 UTF-8 bytes long so fit */
|
||||
|
||||
} else if (eci == 29) { /* GB 2312 (and GB 18030 if Han Xin) */
|
||||
/* Not needed for GB 2312 but allow for GB 18030 4 byters */
|
||||
} else if (eci == 32) { /* GB 18030 */
|
||||
/* Allow for GB 18030 4 byters */
|
||||
length *= 2;
|
||||
|
||||
} else if (eci == 34 || eci == 35) { /* UTF-32 */
|
||||
/* Quadruple-up ASCII and double-up non-ASCII */
|
||||
length += chr_range_cnt(source, length, 0, 0x7F) * 2 + length;
|
||||
}
|
||||
|
||||
/* Big5 and EUC-KR fit in UTF-8 length */
|
||||
/* Big5, GB 2312, EUC-KR and GBK fit in UTF-8 length */
|
||||
|
||||
return length;
|
||||
}
|
||||
@ -180,14 +226,15 @@ INTERNAL int get_eci_length(const int eci, const unsigned char source[], int len
|
||||
INTERNAL int utf8_to_eci(const int eci, const unsigned char source[], unsigned char dest[], int *p_length) {
|
||||
|
||||
typedef int (*eci_func_t)(unsigned char *r, const unsigned int wc);
|
||||
static const eci_func_t eci_funcs[31] = {
|
||||
NULL, NULL, NULL, NULL, iso8859_2_wctosb,
|
||||
iso8859_3_wctosb, iso8859_4_wctosb, iso8859_5_wctosb, iso8859_6_wctosb, iso8859_7_wctosb,
|
||||
iso8859_8_wctosb, iso8859_9_wctosb, iso8859_10_wctosb, iso8859_11_wctosb, NULL,
|
||||
iso8859_13_wctosb, iso8859_14_wctosb, iso8859_15_wctosb, iso8859_16_wctosb, NULL,
|
||||
sjis_wctomb, cp1250_wctosb, cp1251_wctosb, cp1252_wctosb, cp1256_wctosb,
|
||||
ucs2be_wctomb, NULL, ascii_wctosb, big5_wctomb, gb2312_wctomb,
|
||||
euc_kr_wctomb,
|
||||
static const eci_func_t eci_funcs[36] = {
|
||||
NULL, NULL, NULL, NULL, iso8859_2_wctosb, /*0-4*/
|
||||
iso8859_3_wctosb, iso8859_4_wctosb, iso8859_5_wctosb, iso8859_6_wctosb, iso8859_7_wctosb, /*5-9*/
|
||||
iso8859_8_wctosb, iso8859_9_wctosb, iso8859_10_wctosb, iso8859_11_wctosb, NULL, /*10-14*/
|
||||
iso8859_13_wctosb, iso8859_14_wctosb, iso8859_15_wctosb, iso8859_16_wctosb, NULL, /*15-19*/
|
||||
sjis_wctomb, cp1250_wctosb, cp1251_wctosb, cp1252_wctosb, cp1256_wctosb, /*20-24*/
|
||||
utf16be_wctomb, NULL, ascii_wctosb, big5_wctomb, gb2312_wctomb, /*25-29*/
|
||||
euc_kr_wctomb, gbk_wctomb, gb18030_wctomb, utf16le_wctomb, utf32be_wctomb, /*30-34*/
|
||||
utf32le_wctomb,
|
||||
};
|
||||
eci_func_t eci_func;
|
||||
unsigned int codepoint, state;
|
||||
@ -277,3 +324,5 @@ INTERNAL int get_best_eci(const unsigned char source[], int length) {
|
||||
|
||||
return 26; // If all of these fail, use Unicode!
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* eci_sb.h - Extended Channel Interpretations single-byte and UCS-2 BE
|
||||
/* eci_sb.h - Extended Channel Interpretations single-byte and UTF-16/32
|
||||
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2021-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
|
||||
@ -28,10 +28,9 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#ifndef ECI_SB_H
|
||||
#define ECI_SB_H
|
||||
#ifndef Z_ECI_SB_H
|
||||
#define Z_ECI_SB_H
|
||||
|
||||
/*
|
||||
* Adapted from GNU LIBICONV library */
|
||||
@ -1116,17 +1115,84 @@ static int cp1256_wctosb(unsigned char *r, const unsigned int wc) {
|
||||
}
|
||||
|
||||
/*
|
||||
* UCS-2 (libiconv-1.16/lib/ucs2.h)
|
||||
* UTF-16BE (libiconv-1.16/lib/utf16be.h)
|
||||
*/
|
||||
|
||||
/* ECI 25 UC2-2 Big Endian (ISO/IEC 10646) */
|
||||
static int ucs2be_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
if (wc < 0x10000 && wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) {
|
||||
r[0] = (unsigned char) (wc >> 8);
|
||||
r[1] = (unsigned char) (wc & 0xff);
|
||||
return 2;
|
||||
/* ECI 25 UTF-16 Big Endian (ISO/IEC 10646) */
|
||||
static int utf16be_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
if (!(wc >= 0xd800 && wc < 0xe000)) {
|
||||
if (wc < 0x10000) {
|
||||
r[0] = (unsigned char) (wc >> 8);
|
||||
r[1] = (unsigned char) (wc & 0xff);
|
||||
return 2;
|
||||
} else if (wc < 0x110000) {
|
||||
unsigned int wc1 = 0xd800 + ((wc - 0x10000) >> 10);
|
||||
unsigned int wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
|
||||
r[0] = (unsigned char) (wc1 >> 8);
|
||||
r[1] = (unsigned char) (wc1 & 0xff);
|
||||
r[2] = (unsigned char) (wc2 >> 8);
|
||||
r[3] = (unsigned char) (wc2 & 0xff);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* ECI_SB_H */
|
||||
/*
|
||||
* UTF-16LE (libiconv-1.16/lib/utf16le.h)
|
||||
*/
|
||||
|
||||
/* ECI 33 UTF-16 Little Endian (ISO/IEC 10646) */
|
||||
static int utf16le_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
if (!(wc >= 0xd800 && wc < 0xe000)) {
|
||||
if (wc < 0x10000) {
|
||||
r[0] = (unsigned char) (wc & 0xff);
|
||||
r[1] = (unsigned char) (wc >> 8);
|
||||
return 2;
|
||||
} else if (wc < 0x110000) {
|
||||
unsigned int wc1 = 0xd800 + ((wc - 0x10000) >> 10);
|
||||
unsigned int wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff);
|
||||
r[0] = (unsigned char) (wc1 & 0xff);
|
||||
r[1] = (unsigned char) (wc1 >> 8);
|
||||
r[2] = (unsigned char) (wc2 & 0xff);
|
||||
r[3] = (unsigned char) (wc2 >> 8);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* UTF-32BE (libiconv-1.16/lib/utf32be.h)
|
||||
*/
|
||||
|
||||
/* ECI 34 UTF-32 Big Endian (ISO/IEC 10646) */
|
||||
static int utf32be_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
|
||||
r[0] = 0;
|
||||
r[1] = (unsigned char) (wc >> 16);
|
||||
r[2] = (unsigned char) (wc >> 8);
|
||||
r[3] = (unsigned char) (wc & 0xff);
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* UTF-32LE (libiconv-1.16/lib/utf32le.h)
|
||||
*/
|
||||
|
||||
/* ECI 35 UTF-32 Little Endian (ISO/IEC 10646) */
|
||||
static int utf32le_wctomb(unsigned char *r, const unsigned int wc) {
|
||||
if (wc < 0x110000 && !(wc >= 0xd800 && wc < 0xe000)) {
|
||||
r[0] = (unsigned char) (wc & 0xff);
|
||||
r[1] = (unsigned char) (wc >> 8);
|
||||
r[2] = (unsigned char) (wc >> 16);
|
||||
r[3] = 0;
|
||||
return 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
#endif /* Z_ECI_SB_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019-2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
/*
|
||||
* Adapted from GNU LIBICONV library and patched to allow 2 duplicate mappings
|
||||
* for compatibility with GB 2312 (GB2312.TXT):
|
||||
@ -2422,7 +2421,7 @@ static int gbkext_inv_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
* GBK (libiconv-1.16/lib/gbk.h)
|
||||
*/
|
||||
|
||||
static int gbk_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
INTERNAL int gbk_wctomb_zint(unsigned int *r, const unsigned int wc) {
|
||||
int ret;
|
||||
|
||||
/* ZINT: Note these mappings U+30FB and U+2015 different from GB 2312 */
|
||||
@ -2551,7 +2550,7 @@ static const unsigned short gb18030ext_pagefe[16] = {
|
||||
0xa6ed, 0xa6f3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*0x18-0x1f*/
|
||||
};
|
||||
|
||||
static int gb18030ext_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
STATIC_UNLESS_ZINT_TEST int gb18030ext_wctomb(unsigned int *r, const unsigned int wc) {
|
||||
unsigned short c = 0;
|
||||
if (wc == 0x01f9) {
|
||||
c = 0xa8bf;
|
||||
@ -2725,7 +2724,7 @@ static const unsigned short gb18030uni_ranges[206] = {
|
||||
25994, 25998, 26012, 26016, 26110, 26116
|
||||
};
|
||||
|
||||
static int gb18030uni_wctomb(unsigned int *r1, unsigned int *r2, const unsigned int wc) {
|
||||
STATIC_UNLESS_ZINT_TEST int gb18030uni_wctomb(unsigned int *r1, unsigned int *r2, const unsigned int wc) {
|
||||
unsigned int i = wc;
|
||||
if (i >= 0x0080 && i <= 0xffff) {
|
||||
if (i == 0xe7c7) {
|
||||
@ -2806,7 +2805,7 @@ INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, const unsig
|
||||
}
|
||||
|
||||
/* Code set 1 (GBK extended) */
|
||||
ret = gbk_wctomb(r1, wc);
|
||||
ret = gbk_wctomb_zint(r1, wc);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
@ -2973,3 +2972,5 @@ INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* gb18030.h - Unicode to GB 18030
|
||||
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009-2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -28,15 +28,15 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#ifndef GB18030_H
|
||||
#define GB18030_H
|
||||
#ifndef Z_GB18030_H
|
||||
#define Z_GB18030_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INTERNAL int gbk_wctomb_zint(unsigned int *r, const unsigned int wc);
|
||||
INTERNAL int gb18030_wctomb_zint(unsigned int *r1, unsigned int *r2, const unsigned int wc);
|
||||
INTERNAL int gb18030_utf8(struct zint_symbol *symbol, const unsigned char source[], int *p_length,
|
||||
unsigned int *gbdata);
|
||||
@ -49,4 +49,5 @@ INTERNAL void gb18030_cpy(const unsigned char source[], int *p_length, unsigned
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* GB18030_H */
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
#endif /* Z_GB18030_H */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* gridmtx.c - Grid Matrix
|
||||
|
||||
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
|
||||
@ -28,7 +28,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
/* This file implements Grid Matrix as specified in
|
||||
AIM Global Document Number AIMD014 Rev. 1.63 Revised 9 Dec 2008 */
|
||||
@ -1011,6 +1010,7 @@ static void place_layer_id(char *grid, int size, int layers, int modules, int ec
|
||||
}
|
||||
|
||||
INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int warn_number = 0;
|
||||
int size, modules, error_number;
|
||||
int auto_layers, min_layers, layers, auto_ecc_level, min_ecc_level, ecc_level;
|
||||
int x, y, i;
|
||||
@ -1038,7 +1038,7 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int
|
||||
gb2312_cpy(source, &length, gbdata, full_multibyte);
|
||||
} else {
|
||||
int done = 0;
|
||||
if (symbol->eci != 29) { /* Unless ECI 29 (GB) */
|
||||
if (symbol->eci != 29) { /* Unless ECI 29 (GB 2312) */
|
||||
/* Try other conversions (ECI 0 defaults to ISO/IEC 8859-1) */
|
||||
error_number = gb2312_utf8_to_eci(symbol->eci, source, &length, gbdata, full_multibyte);
|
||||
if (error_number == 0) {
|
||||
@ -1054,6 +1054,10 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
if (symbol->eci != 29) {
|
||||
strcpy(symbol->errtxt, "540: Converted to GB 2312 but no ECI specified");
|
||||
warn_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1237,5 +1241,7 @@ INTERNAL int gridmatrix(struct zint_symbol *symbol, unsigned char source[], int
|
||||
}
|
||||
symbol->height = size;
|
||||
|
||||
return 0;
|
||||
return warn_number;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* hanxin.c - Han Xin Code
|
||||
|
||||
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
|
||||
@ -28,10 +28,9 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
/* This code attempts to implement Han Xin Code according to ISO/IEC 20830 (draft 2019-10-10)
|
||||
* (previously AIMD-015:2010 (Rev 0.8)) */
|
||||
/* 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)) */
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
@ -630,7 +629,7 @@ static void calculate_binary(char binary[], const char mode[], unsigned int sour
|
||||
bp = bin_append_posn(block_length + double_byte, 13, binary, bp);
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Binary (length %d)\n", block_length + double_byte);
|
||||
printf("Binary Mode (%d):", block_length + double_byte);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
@ -641,7 +640,7 @@ static void calculate_binary(char binary[], const char mode[], unsigned int sour
|
||||
bp = bin_append_posn(source[i + position], source[i + position] > 0xFF ? 16 : 8, binary, bp);
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
printf("%d ", (int) source[i + position]);
|
||||
printf(" %02x", (int) source[i + position]);
|
||||
}
|
||||
|
||||
i++;
|
||||
@ -1142,14 +1141,11 @@ static void hx_set_function_info(unsigned char *grid, const int size, const int
|
||||
bp = bin_append_posn(fi_ecc[i], 4, function_information, bp);
|
||||
}
|
||||
|
||||
/* This alternating filler pattern at end not mentioned in ISO/IEC 20830 (draft 2019-10-10) and does not appear
|
||||
* in Figure 1 or the figures in Annex K but does appear in Figure 2 and Figures 4-9 */
|
||||
/* Previously added alternating filler pattern here (as does BWIPP) but not mentioned in ISO/IEC 20830:2021 and
|
||||
does not appear in Figure 1 nor in the figures in Annex K (although does appear in Figure 2 and Figures 4-9)
|
||||
nor in the AIM ITS/04-023:2022 examples: so just clear */
|
||||
for (i = 28; i < 34; i++) {
|
||||
if (i & 1) {
|
||||
function_information[i] = '1';
|
||||
} else {
|
||||
function_information[i] = '0';
|
||||
}
|
||||
function_information[i] = '0';
|
||||
}
|
||||
|
||||
if (debug & ZINT_DEBUG_PRINT) {
|
||||
@ -1293,7 +1289,7 @@ static int hx_evaluate(const unsigned char *local, const int size) {
|
||||
* position of the module.” - however i being the length of the run of the
|
||||
* same colour (i.e. "block" below) in the same fashion as ISO/IEC 18004
|
||||
* makes more sense. -- Confirmed by Wang Yi */
|
||||
/* Fixed in ISO/IEC 20830 (draft 2019-10-10) section 5.8.3.2 "In Table 12 below, i refers to the modules with
|
||||
/* Fixed in ISO/IEC 20830 section 5.8.4.3 "In Table, i refers to the modules with
|
||||
same color." */
|
||||
|
||||
/* Vertical */
|
||||
@ -1341,8 +1337,8 @@ static int hx_evaluate(const unsigned char *local, const int size) {
|
||||
}
|
||||
|
||||
/* Apply the four possible bitmasks for evaluation */
|
||||
/* TODO: Haven't been able to replicate (or even get close to) the penalty scores in ISO/IEC 20830
|
||||
* (draft 2019-10-10) Annex K examples; however they don't use alternating filler pattern on structural info */
|
||||
/* TODO: Haven't been able to replicate (or even get close to) the penalty scores in ISO/IEC 20830:2021
|
||||
* Annex K examples */
|
||||
static void hx_apply_bitmask(unsigned char *grid, const int size, const int version, const int ecc_level,
|
||||
const int user_mask, const int debug) {
|
||||
int x, y;
|
||||
@ -1447,6 +1443,7 @@ static void hx_apply_bitmask(unsigned char *grid, const int size, const int vers
|
||||
|
||||
/* Han Xin Code - main */
|
||||
INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int warn_number = 0;
|
||||
int est_binlen;
|
||||
int ecc_level = symbol->option_1;
|
||||
int i, j, j_max, version;
|
||||
@ -1482,7 +1479,7 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
gb18030_cpy(source, &length, gbdata, full_multibyte);
|
||||
} else {
|
||||
int done = 0;
|
||||
if (symbol->eci != 29) { /* Unless ECI 29 (GB) */
|
||||
if (symbol->eci != 32) { /* Unless ECI 32 (GB 18030) */
|
||||
/* Try other conversions (ECI 0 defaults to ISO/IEC 8859-1) */
|
||||
int error_number = gb18030_utf8_to_eci(symbol->eci, source, &length, gbdata, full_multibyte);
|
||||
if (error_number == 0) {
|
||||
@ -1498,6 +1495,10 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
if (symbol->eci != 32) {
|
||||
strcpy(symbol->errtxt, "543: Converted to GB 18030 but no ECI specified");
|
||||
warn_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1520,30 +1521,33 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
if (bin_len & 0x07) {
|
||||
codewords++;
|
||||
}
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Num. of codewords: %d\n", codewords);
|
||||
}
|
||||
|
||||
version = 85;
|
||||
for (i = 84; i > 0; i--) {
|
||||
switch (ecc_level) {
|
||||
case 1:
|
||||
if (hx_data_codewords_L1[i - 1] > codewords) {
|
||||
if (hx_data_codewords_L1[i - 1] >= codewords) {
|
||||
version = i;
|
||||
data_codewords = hx_data_codewords_L1[i - 1];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (hx_data_codewords_L2[i - 1] > codewords) {
|
||||
if (hx_data_codewords_L2[i - 1] >= codewords) {
|
||||
version = i;
|
||||
data_codewords = hx_data_codewords_L2[i - 1];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (hx_data_codewords_L3[i - 1] > codewords) {
|
||||
if (hx_data_codewords_L3[i - 1] >= codewords) {
|
||||
version = i;
|
||||
data_codewords = hx_data_codewords_L3[i - 1];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (hx_data_codewords_L4[i - 1] > codewords) {
|
||||
if (hx_data_codewords_L4[i - 1] >= codewords) {
|
||||
version = i;
|
||||
data_codewords = hx_data_codewords_L4[i - 1];
|
||||
}
|
||||
@ -1576,17 +1580,17 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
|
||||
/* Unless explicitly specified (within min/max bounds) by user */
|
||||
if (symbol->option_1 == -1 || symbol->option_1 != ecc_level) {
|
||||
if ((ecc_level == 1) && (codewords < hx_data_codewords_L2[version - 1])) {
|
||||
if ((ecc_level == 1) && (codewords <= hx_data_codewords_L2[version - 1])) {
|
||||
ecc_level = 2;
|
||||
data_codewords = hx_data_codewords_L2[version - 1];
|
||||
}
|
||||
|
||||
if ((ecc_level == 2) && (codewords < hx_data_codewords_L3[version - 1])) {
|
||||
if ((ecc_level == 2) && (codewords <= hx_data_codewords_L3[version - 1])) {
|
||||
ecc_level = 3;
|
||||
data_codewords = hx_data_codewords_L3[version - 1];
|
||||
}
|
||||
|
||||
if ((ecc_level == 3) && (codewords < hx_data_codewords_L4[version - 1])) {
|
||||
if ((ecc_level == 3) && (codewords <= hx_data_codewords_L4[version - 1])) {
|
||||
ecc_level = 4;
|
||||
data_codewords = hx_data_codewords_L4[version - 1];
|
||||
}
|
||||
@ -1616,8 +1620,7 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Datastream length: %d\n", data_codewords);
|
||||
printf("Datastream:\n");
|
||||
printf("Datastream (%d): ", data_codewords);
|
||||
for (i = 0; i < data_codewords; i++) {
|
||||
printf("%.2x ", datastream[i]);
|
||||
}
|
||||
@ -1631,6 +1634,14 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
|
||||
hx_add_ecc(fullstream, datastream, data_codewords, version, ecc_level);
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_PRINT) {
|
||||
printf("Fullstream (%d): ", hx_total_codewords[version - 1]);
|
||||
for (i = 0; i < hx_total_codewords[version - 1]; i++) {
|
||||
printf("%.2x ", fullstream[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
make_picket_fence(fullstream, picket_fence, hx_total_codewords[version - 1]);
|
||||
|
||||
/* Populate grid */
|
||||
@ -1665,5 +1676,7 @@ INTERNAL int hanxin(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
symbol->height = size;
|
||||
|
||||
return 0;
|
||||
return warn_number;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
19
backend/qr.c
19
backend/qr.c
@ -1,7 +1,7 @@
|
||||
/* qr.c Handles QR Code, Micro QR Code, UPNQR and rMQR
|
||||
|
||||
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
|
||||
@ -28,7 +28,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <math.h>
|
||||
#ifdef _MSC_VER
|
||||
@ -1541,6 +1540,7 @@ static int getBinaryLength(const int version, char inputMode[], const unsigned i
|
||||
}
|
||||
|
||||
INTERNAL int qrcode(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int warn_number = 0;
|
||||
int i, j, est_binlen, prev_est_binlen;
|
||||
int ecc_level, autosize, version, max_cw, target_codewords, blocks, size;
|
||||
int bitmask, gs1;
|
||||
@ -1593,6 +1593,10 @@ INTERNAL int qrcode(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
if (symbol->eci != 20) {
|
||||
strcpy(symbol->errtxt, "543: Converted to Shift JIS but no ECI specified");
|
||||
warn_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1832,7 +1836,7 @@ INTERNAL int qrcode(struct zint_symbol *symbol, unsigned char source[], int leng
|
||||
}
|
||||
symbol->height = size;
|
||||
|
||||
return 0;
|
||||
return warn_number;
|
||||
}
|
||||
|
||||
static int micro_qr_m1(struct zint_symbol *symbol, char binary_data[], int bp) {
|
||||
@ -2967,6 +2971,7 @@ static void setup_rmqr_grid(unsigned char *grid, const int h_size, const int v_s
|
||||
|
||||
/* rMQR according to 2018 draft standard */
|
||||
INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int length) {
|
||||
int warn_number = 0;
|
||||
int i, j, est_binlen;
|
||||
int ecc_level, autosize, version, max_cw, target_codewords, blocks, h_size, v_size;
|
||||
int gs1;
|
||||
@ -3011,6 +3016,10 @@ INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int length
|
||||
if (error_number != 0) {
|
||||
return error_number;
|
||||
}
|
||||
if (symbol->eci != 20) {
|
||||
strcpy(symbol->errtxt, "544: Converted to Shift JIS but no ECI specified");
|
||||
warn_number = ZINT_WARN_NONCOMPLIANT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3214,5 +3223,7 @@ INTERNAL int rmqr(struct zint_symbol *symbol, unsigned char source[], int length
|
||||
}
|
||||
symbol->height = v_size;
|
||||
|
||||
return 0;
|
||||
return warn_number;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -349,11 +348,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -486,3 +485,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -2440,11 +2439,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[22801 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -3022,3 +3021,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -464,11 +463,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -605,3 +604,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
/* Note BARCODE_GS1_128, BARCODE_EAN14, BARCODE_NVE18 also tested in test_gs1.c */
|
||||
|
||||
@ -831,11 +830,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[17984 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -972,3 +971,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -1016,14 +1015,14 @@ static void test_encode(int index, int generate, int debug) {
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
if (!data[i].zxingcpp_cmp) {
|
||||
if (debug & ZINT_DEBUG_TEST_PRINT) printf("i:%d %s not ZXing-C++ compatible (%s)\n", i, testUtilBarcodeName(symbol->symbology), data[i].comment);
|
||||
} else {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[16384];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -1251,3 +1250,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et norl : */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "../eci.h"
|
||||
@ -204,7 +203,7 @@ static void test_reduced_charset_input(int index, int debug) {
|
||||
/* 64*/ { BARCODE_PDF417, UNICODE_MODE, 25, "ကက", 0, 25, "In UCS-2BE" },
|
||||
/* 65*/ { BARCODE_PDF417, UNICODE_MODE, 25, "12", 0, 25, "UCS-2BE ASCII" },
|
||||
/* 66*/ { BARCODE_PDF417, UNICODE_MODE, 0, "𐀀", ZINT_WARN_USES_ECI, 26, "Not in any single-byte page" },
|
||||
/* 67*/ { BARCODE_PDF417, UNICODE_MODE, 25, "𐀀", ZINT_ERROR_INVALID_DATA, -1, "Not in UCS-2BE (in Supplementary Plane)" },
|
||||
/* 67*/ { BARCODE_PDF417, UNICODE_MODE, 25, "𐀀", 0, 25, "UTF-16BE (in Supplementary Plane)" },
|
||||
/* 68*/ { BARCODE_PDF417, UNICODE_MODE, 0, "テ", ZINT_WARN_USES_ECI, 26, "Defaults to UTF-8 if not in any ISO 8859 or Win page" },
|
||||
/* 69*/ { BARCODE_PDF417, UNICODE_MODE, 26, "テ", 0, 26, "" },
|
||||
/* 70*/ { BARCODE_PDF417, UNICODE_MODE, 26, "テテ", 0, 26, "" },
|
||||
@ -762,29 +761,37 @@ static void test_utf8_to_eci_ascii(void) {
|
||||
assert_zero(memcmp(data[i].data, dest, length), "i:%d memcmp != 0\n", i);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_ucs2be(void) {
|
||||
static void test_utf8_to_eci_utf16be(void) {
|
||||
|
||||
struct item {
|
||||
int eci;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
int expected_length;
|
||||
char *expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 25, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 * 2 },
|
||||
/* 1*/ { 25, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 * 2 },
|
||||
/* 2*/ { 25, "\302\200\357\277\277", -1, 0, 4 }, // U+0080 U+FFFF
|
||||
/* 3*/ { 25, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 4*/ { 25, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 * 2, NULL },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 * 2, NULL },
|
||||
/* 2*/ { "\302\200\357\277\277", -1, 0, 4, "\000\200\377\377" }, // U+0080 U+FFFF
|
||||
/* 3*/ { "\357\277\276", -1, 0, 2, "\377\376" }, // U+FFFE (reversed BOM) allowed
|
||||
/* 4*/ { "\357\273\277", -1, 0, 2, "\376\377" }, // U+FEFF (BOM) allowed
|
||||
/* 5*/ { "\355\237\277", -1, 0, 2, "\327\377" }, // U+D7FF (ed9fbf)
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+D800 (eda080) surrogate half not allowed
|
||||
/* 7*/ { "\355\277\277", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+DFFF (edbfbf) surrogate half not allowed
|
||||
/* 8*/ { "\356\200\200", -1, 0, 2, "\340\000" }, // U+E000 (ee8080)
|
||||
/* 9*/ { "\360\220\200\200", -1, 0, 4, "\330\000\334\000" }, // U+10000 maps to surrogate pair
|
||||
/* 10*/ { "\364\217\277\277", -1, 0, 4, "\333\377\337\377" }, // U+10FFFF maps to surrogate pair
|
||||
/* 11*/ { "\364\220\200\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // Non-Unicode 0x110000 not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 25;
|
||||
|
||||
testStart("test_utf8_to_eci_ucs2be");
|
||||
testStart("test_utf8_to_eci_utf16be");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int out_length, eci_length;
|
||||
@ -792,22 +799,209 @@ static void test_utf8_to_eci_ucs2be(void) {
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length);
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
if (data[i].expected) {
|
||||
ret = memcmp(dest, data[i].expected, data[i].expected_length);
|
||||
assert_zero(ret, "i:%d memcmp() %d != 0\n", i, ret);
|
||||
} else {
|
||||
int j;
|
||||
for (j = 0; j < length; j++) {
|
||||
assert_zero(dest[j * 2], "i:%d dest[%d] %d != 0\n", i, j * 2, dest[j * 2]);
|
||||
assert_equal(dest[j * 2 + 1], data[i].data[j], "i:%d dest[%d] %d != data[%d] %d\n", i, j * 2 + 1, dest[j * 2 + 1], j, data[i].data[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_utf16le(void) {
|
||||
|
||||
struct item {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
int expected_length;
|
||||
char *expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 * 2, NULL },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 * 2, NULL },
|
||||
/* 2*/ { "\302\200\357\277\277", -1, 0, 4, "\200\000\377\377" }, // U+0080 U+FFFF
|
||||
/* 3*/ { "\357\277\276", -1, 0, 2, "\376\377" }, // U+FFFE (reversed BOM) allowed
|
||||
/* 4*/ { "\357\273\277", -1, 0, 2, "\377\376" }, // U+FEFF (BOM) allowed
|
||||
/* 5*/ { "\355\237\277", -1, 0, 2, "\377\327" }, // U+D7FF (ed9fbf)
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+D800 (eda080) surrogate half not allowed
|
||||
/* 7*/ { "\355\277\277", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+DFFF (edbfbf) surrogate half not allowed
|
||||
/* 8*/ { "\356\200\200", -1, 0, 2, "\000\340" }, // U+E000 (ee8080)
|
||||
/* 9*/ { "\360\220\200\200", -1, 0, 4, "\000\330\000\334" }, // U+10000 maps to surrogate pair
|
||||
/* 10*/ { "\364\217\277\277", -1, 0, 4, "\377\333\377\337" }, // U+10FFFF maps to surrogate pair
|
||||
/* 11*/ { "\364\220\200\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // Non-Unicode 0x110000 not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 33;
|
||||
|
||||
testStart("test_utf8_to_eci_utf16le");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int out_length, eci_length;
|
||||
char dest[1024];
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
if (data[i].expected) {
|
||||
ret = memcmp(dest, data[i].expected, data[i].expected_length);
|
||||
assert_zero(ret, "i:%d memcmp() %d != 0\n", i, ret);
|
||||
} else {
|
||||
int j;
|
||||
for (j = 0; j < length; j++) {
|
||||
assert_equal(dest[j * 2], data[i].data[j], "i:%d dest[%d] %d != data[%d] %d\n", i, j * 2, dest[j * 2], j, data[i].data[j]);
|
||||
assert_zero(dest[j * 2 + 1], "i:%d dest[%d] %d != 0\n", i, j * 2 + 1, dest[j * 2 + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_utf32be(void) {
|
||||
|
||||
struct item {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
int expected_length;
|
||||
char *expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 * 4, NULL },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 * 4, NULL },
|
||||
/* 2*/ { "\302\200\357\277\277", -1, 0, 8, "\000\000\000\200\000\000\377\377" }, // U+0080 U+FFFF
|
||||
/* 3*/ { "\357\277\276", -1, 0, 4, "\000\000\377\376" }, // U+FFFE (reversed BOM) allowed
|
||||
/* 4*/ { "\357\273\277", -1, 0, 4, "\000\000\376\377" }, // U+FEFF (BOM) allowed
|
||||
/* 5*/ { "\355\237\277", -1, 0, 4, "\000\000\327\377" }, // U+D7FF (ed9fbf)
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+D800 (eda080) surrogate half not allowed
|
||||
/* 7*/ { "\355\277\277", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+DFFF (edbfbf) surrogate half not allowed
|
||||
/* 8*/ { "\356\200\200", -1, 0, 4, "\000\000\340\000" }, // U+E000 (ee8080)
|
||||
/* 9*/ { "\360\220\200\200", -1, 0, 4, "\000\001\000\000" }, // U+10000
|
||||
/* 10*/ { "\364\217\277\277", -1, 0, 4, "\000\020\377\377" }, // U+10FFFF
|
||||
/* 11*/ { "\364\220\200\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // Non-Unicode 0x110000 not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 34;
|
||||
|
||||
testStart("test_utf8_to_eci_utf32be");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int out_length, eci_length;
|
||||
char dest[1024];
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
if (data[i].expected) {
|
||||
ret = memcmp(dest, data[i].expected, data[i].expected_length);
|
||||
assert_zero(ret, "i:%d memcmp() %d != 0\n", i, ret);
|
||||
} else {
|
||||
int j;
|
||||
for (j = 0; j < length; j++) {
|
||||
assert_zero(dest[j * 4], "i:%d dest[%d] %d != 0\n", i, j * 4, dest[j * 4]);
|
||||
assert_zero(dest[j * 4 + 1], "i:%d dest[%d] %d != 0\n", i, j * 4 + 1, dest[j * 4 + 1]);
|
||||
assert_zero(dest[j * 4 + 2], "i:%d dest[%d] %d != 0\n", i, j * 4 + 2, dest[j * 4 + 2]);
|
||||
assert_equal(dest[j * 4 + 3], data[i].data[j], "i:%d dest[%d] %d != data[%d] %d\n", i, j * 4 + 3, dest[j * 4 + 3], j, data[i].data[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_utf32le(void) {
|
||||
|
||||
struct item {
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
int expected_length;
|
||||
char *expected;
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 * 4, NULL },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 * 4, NULL },
|
||||
/* 2*/ { "\302\200\357\277\277", -1, 0, 8, "\200\000\000\000\377\377\000\000" }, // U+0080 U+FFFF
|
||||
/* 3*/ { "\357\277\276", -1, 0, 4, "\376\377\000\000" }, // U+FFFE (reversed BOM) allowed
|
||||
/* 4*/ { "\357\273\277", -1, 0, 4, "\377\376\000\000" }, // U+FEFF (BOM) allowed
|
||||
/* 5*/ { "\355\237\277", -1, 0, 4, "\377\327\000\000" }, // U+D7FF (ed9fbf)
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+D800 (eda080) surrogate half not allowed
|
||||
/* 7*/ { "\355\277\277", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // U+DFFF (edbfbf) surrogate half not allowed
|
||||
/* 8*/ { "\356\200\200", -1, 0, 4, "\000\340\000\000" }, // U+E000 (ee8080)
|
||||
/* 9*/ { "\360\220\200\200", -1, 0, 4, "\000\000\001\000" }, // U+10000
|
||||
/* 10*/ { "\364\217\277\277", -1, 0, 4, "\377\377\020\000" }, // U+10FFFF
|
||||
/* 11*/ { "\364\220\200\200", -1, ZINT_ERROR_INVALID_DATA, -1, NULL }, // Non-Unicode 0x110000 not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 35;
|
||||
|
||||
testStart("test_utf8_to_eci_utf32le");
|
||||
|
||||
for (i = 0; i < data_size; i++) {
|
||||
int out_length, eci_length;
|
||||
char dest[1024];
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
if (data[i].expected) {
|
||||
ret = memcmp(dest, data[i].expected, data[i].expected_length);
|
||||
assert_zero(ret, "i:%d memcmp() %d != 0\n", i, ret);
|
||||
} else {
|
||||
int j;
|
||||
for (j = 0; j < length; j++) {
|
||||
assert_equal(dest[j * 4], data[i].data[j], "i:%d dest[%d] %d != data[%d] %d\n", i, j * 4, dest[j * 4], j, data[i].data[j]);
|
||||
assert_zero(dest[j * 4 + 1], "i:%d dest[%d] %d != 0\n", i, j * 4 + 1, dest[j * 4 + 1]);
|
||||
assert_zero(dest[j * 4 + 2], "i:%d dest[%d] %d != 0\n", i, j * 4 + 2, dest[j * 4 + 2]);
|
||||
assert_zero(dest[j * 4 + 3], "i:%d dest[%d] %d != 0\n", i, j * 4 + 3, dest[j * 4 + 3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_sjis(void) {
|
||||
|
||||
struct item {
|
||||
int eci;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
@ -815,26 +1009,27 @@ static void test_utf8_to_eci_sjis(void) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 20, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { 20, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\177", 95, 0, 95 + 1 }, // Backslash goes to 2 byte
|
||||
/* 2*/ { 20, "~", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for tilde
|
||||
/* 3*/ { 20, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 4*/ { 20, "\302\241", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00A1 Inverted exclaimation mark
|
||||
/* 5*/ { 20, "\302\245", -1, 0, 1 }, // U+00A5 Yen goes to backslash
|
||||
/* 6*/ { 20, "\302\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00BF Inverted question mark
|
||||
/* 7*/ { 20, "\303\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00C0 À
|
||||
/* 8*/ { 20, "\303\251", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00E9 é
|
||||
/* 9*/ { 20, "\312\262", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+03B2 β
|
||||
/* 10*/ { 20, "\342\272\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+2E80 CJK RADICAL REPEAT
|
||||
/* 11*/ { 20, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 12*/ { 20, "\343\200\204", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+3004 JAPANESE INDUSTRIAL STANDARD SYMBOL
|
||||
/* 13*/ { 20, "\343\201\201", -1, 0, 2 }, //U+3041 HIRAGANA LETTER SMALL A
|
||||
/* 14*/ { 20, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 15*/ { 20, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 16*/ { 20, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}\177", 95, 0, 95 + 1 }, // Backslash goes to 2 byte
|
||||
/* 2*/ { "~", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for tilde
|
||||
/* 3*/ { "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 4*/ { "\302\241", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00A1 Inverted exclaimation mark
|
||||
/* 5*/ { "\302\245", -1, 0, 1 }, // U+00A5 Yen goes to backslash
|
||||
/* 6*/ { "\302\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00BF Inverted question mark
|
||||
/* 7*/ { "\303\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00C0 À
|
||||
/* 8*/ { "\303\251", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+00E9 é
|
||||
/* 9*/ { "\312\262", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+03B2 β
|
||||
/* 10*/ { "\342\272\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+2E80 CJK RADICAL REPEAT
|
||||
/* 11*/ { "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 12*/ { "\343\200\204", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+3004 JAPANESE INDUSTRIAL STANDARD SYMBOL
|
||||
/* 13*/ { "\343\201\201", -1, 0, 2 }, //U+3041 HIRAGANA LETTER SMALL A
|
||||
/* 14*/ { "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 15*/ { "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 16*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 20;
|
||||
|
||||
testStart("test_utf8_to_eci_sjis");
|
||||
|
||||
@ -844,22 +1039,21 @@ static void test_utf8_to_eci_sjis(void) {
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length);
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_big5(void) {
|
||||
|
||||
struct item {
|
||||
int eci;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
@ -867,16 +1061,17 @@ static void test_utf8_to_eci_big5(void) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 28, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { 28, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 },
|
||||
/* 2*/ { 28, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 3*/ { 28, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 4*/ { 28, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 5*/ { 28, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 6*/ { 28, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 },
|
||||
/* 2*/ { "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 3*/ { "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 4*/ { "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 5*/ { "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 28;
|
||||
|
||||
testStart("test_utf8_to_eci_big5");
|
||||
|
||||
@ -886,22 +1081,21 @@ static void test_utf8_to_eci_big5(void) {
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length);
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_gb2312(void) {
|
||||
|
||||
struct item {
|
||||
int eci;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
@ -909,16 +1103,17 @@ static void test_utf8_to_eci_gb2312(void) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 29, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { 29, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 },
|
||||
/* 2*/ { 29, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 3*/ { 29, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 4*/ { 29, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 5*/ { 29, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 6*/ { 29, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 },
|
||||
/* 2*/ { "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 3*/ { "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 4*/ { "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 5*/ { "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 29;
|
||||
|
||||
testStart("test_utf8_to_eci_gb2312");
|
||||
|
||||
@ -928,22 +1123,21 @@ static void test_utf8_to_eci_gb2312(void) {
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length);
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void test_utf8_to_eci_euc_kr(void) {
|
||||
|
||||
struct item {
|
||||
int eci;
|
||||
char *data;
|
||||
int length;
|
||||
int ret;
|
||||
@ -951,16 +1145,17 @@ static void test_utf8_to_eci_euc_kr(void) {
|
||||
};
|
||||
// s/\/\*[ 0-9]*\*\//\=printf("\/*%3d*\/", line(".") - line("'<"))
|
||||
struct item data[] = {
|
||||
/* 0*/ { 30, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { 30, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 },
|
||||
/* 2*/ { 30, "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 3*/ { 30, "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 4*/ { 30, "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 5*/ { 30, "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 6*/ { 30, "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
/* 0*/ { "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", 32, 0, 32 },
|
||||
/* 1*/ { " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177", 96, 0, 96 },
|
||||
/* 2*/ { "\302\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+0080
|
||||
/* 3*/ { "\343\200\200", -1, 0, 2 }, // U+3000 IDEOGRAPHIC SPACE
|
||||
/* 4*/ { "\357\277\277", -1, ZINT_ERROR_INVALID_DATA, -1 }, // No mapping for U+FFFF
|
||||
/* 5*/ { "\357\277\276", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+FFFE (reversed BOM) not allowed
|
||||
/* 6*/ { "\355\240\200", -1, ZINT_ERROR_INVALID_DATA, -1 }, // U+D800 surrogate not allowed
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i, length, ret;
|
||||
const int eci = 30;
|
||||
|
||||
testStart("test_utf8_to_eci_euc_kr");
|
||||
|
||||
@ -970,17 +1165,17 @@ static void test_utf8_to_eci_euc_kr(void) {
|
||||
|
||||
length = data[i].length != -1 ? data[i].length : (int) strlen(data[i].data);
|
||||
out_length = length;
|
||||
eci_length = get_eci_length(data[i].eci, (const unsigned char *) data[i].data, length);
|
||||
eci_length = get_eci_length(eci, (const unsigned char *) data[i].data, length);
|
||||
|
||||
assert_nonzero(eci_length + 1 <= 1024, "i:%d eci_length %d + 1 > 1024\n", i, eci_length);
|
||||
ret = utf8_to_eci(data[i].eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
ret = utf8_to_eci(eci, (const unsigned char *) data[i].data, (unsigned char *) dest, &out_length);
|
||||
assert_equal(ret, data[i].ret, "i:%d utf8_to_eci ret %d != %d\n", i, ret, data[i].ret);
|
||||
if (ret == 0) {
|
||||
assert_equal(out_length, data[i].expected_length, "i:%d length %d != %d\n", i, out_length, data[i].expected_length);
|
||||
assert_nonzero(out_length <= eci_length, "i:%d out_length %d > eci_length %d\n", i, out_length, eci_length);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static void test_get_best_eci(int index) {
|
||||
|
||||
@ -1026,7 +1221,10 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_reduced_charset_input", test_reduced_charset_input, 1, 0, 1 },
|
||||
{ "test_utf8_to_eci_sb", test_utf8_to_eci_sb, 1, 0, 0 },
|
||||
{ "test_utf8_to_eci_ascii", test_utf8_to_eci_ascii, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_ucs2be", test_utf8_to_eci_ucs2be, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_utf16be", test_utf8_to_eci_utf16be, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_utf16le", test_utf8_to_eci_utf16le, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_utf32be", test_utf8_to_eci_utf32be, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_utf32le", test_utf8_to_eci_utf32le, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_sjis", test_utf8_to_eci_sjis, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_big5", test_utf8_to_eci_big5, 0, 0, 0 },
|
||||
{ "test_utf8_to_eci_gb2312", test_utf8_to_eci_gb2312, 0, 0, 0 },
|
||||
@ -1040,3 +1238,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et norl : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
#include "test_gb18030_tab.h"
|
||||
@ -388,6 +387,70 @@ static void test_gb18030_cpy(int index) {
|
||||
testFinish();
|
||||
}
|
||||
|
||||
/* For testing GBK, to exclude GB 18030 extensions */
|
||||
STATIC_UNLESS_ZINT_TEST int gb18030ext_wctomb(unsigned int *r, const unsigned int wc);
|
||||
STATIC_UNLESS_ZINT_TEST int gb18030uni_wctomb(unsigned int *r1, unsigned int *r2, const unsigned int wc);
|
||||
|
||||
/* Control for GBK */
|
||||
static int gbk_wctomb_zint2(unsigned int *r, unsigned int wc) {
|
||||
unsigned int c;
|
||||
int tab_length, start_i, end_i;
|
||||
int i;
|
||||
unsigned int r1, r2;
|
||||
|
||||
if (gb18030ext_wctomb(&r1, wc)) {
|
||||
return 0;
|
||||
}
|
||||
if (wc >= 0xe000 && wc <= 0xe864) {
|
||||
return 0;
|
||||
}
|
||||
if (gb18030uni_wctomb(&r1, &r2, wc)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
tab_length = ARRAY_SIZE(test_gb18030_tab);
|
||||
start_i = test_gb18030_tab_ind[wc >> 10];
|
||||
end_i = start_i + 0x800 > tab_length ? tab_length : start_i + 0x800;
|
||||
for (i = start_i; i < end_i; i += 2) {
|
||||
if (test_gb18030_tab[i + 1] == wc) {
|
||||
c = test_gb18030_tab[i];
|
||||
if (c <= 0xFFFF) {
|
||||
*r = c;
|
||||
return c <= 0xFF ? 1 : 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_gbk_wctomb_zint(void) {
|
||||
|
||||
int ret, ret2;
|
||||
unsigned int val, val2;
|
||||
unsigned int i;
|
||||
|
||||
testStart("test_gbk_wctomb_zint");
|
||||
|
||||
for (i = 0; i < 0xFFFE; i++) {
|
||||
if (i < 0x80) { // ASCII is straight through and not dealt with by gbk_wctomb_zint()
|
||||
continue;
|
||||
}
|
||||
if (i >= 0xD800 && i <= 0xDFFF) { // UTF-16 surrogates
|
||||
continue;
|
||||
}
|
||||
val = val2 = 0;
|
||||
ret = gbk_wctomb_zint(&val, i);
|
||||
ret2 = gbk_wctomb_zint2(&val2, i);
|
||||
assert_equal(ret, ret2, "i:%d 0x%04X ret %d != ret2 %d, val 0x%04X, val2 0x%04X\n", (int) i, i, ret, ret2, val, val2);
|
||||
if (ret2) {
|
||||
assert_equal(val, val2, "i:%d 0x%04X val 0x%04X != val2 0x%04X\n", (int) i, i, val, val2);
|
||||
}
|
||||
}
|
||||
|
||||
testFinish();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
testFunction funcs[] = { /* name, func, has_index, has_generate, has_debug */
|
||||
@ -395,6 +458,7 @@ int main(int argc, char *argv[]) {
|
||||
{ "test_gb18030_utf8", test_gb18030_utf8, 1, 0, 0 },
|
||||
{ "test_gb18030_utf8_to_eci", test_gb18030_utf8_to_eci, 1, 0, 0 },
|
||||
{ "test_gb18030_cpy", test_gb18030_cpy, 1, 0, 0 },
|
||||
{ "test_gbk_wctomb_zint", test_gbk_wctomb_zint, 0, 0, 0 },
|
||||
};
|
||||
|
||||
testRun(argc, argv, funcs, ARRAY_SIZE(funcs));
|
||||
@ -403,3 +467,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019-2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et norl : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -196,7 +195,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 5*/ { DATA_MODE, 0, -1, -1, { 0, 0, "" }, "é", 0, 0, "30 03 43 54 40", "B2 (UTF-8)" },
|
||||
/* 6*/ { DATA_MODE, 0, -1, ZINT_FULL_MULTIBYTE, { 0, 0, "" }, "é", 0, 0, "0A 51 1F 78 00", "H1 (UTF-8) (full multibyte)" },
|
||||
/* 7*/ { DATA_MODE, 0, -1, -1, { 0, 0, "" }, "\351", 0, 0, "30 01 69 00", "B1 (ISO 8859-1) (0xE9)" },
|
||||
/* 8*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "β", 0, 0, "08 40 2F 78 00", "H1 (GB 2312)" },
|
||||
/* 8*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "β", ZINT_WARN_NONCOMPLIANT, 0, "Warning 08 40 2F 78 00", "H1 (GB 2312)" },
|
||||
/* 9*/ { UNICODE_MODE, 9, -1, -1, { 0, 0, "" }, "β", 0, 9, "60 04 58 00 71 00", "ECI-9 B1 (ISO 8859-7)" },
|
||||
/* 10*/ { UNICODE_MODE, 29, -1, -1, { 0, 0, "" }, "β", 0, 29, "60 0E 44 20 17 7C 00", "ECI-29 H1 (GB 2312)" },
|
||||
/* 11*/ { UNICODE_MODE, 26, -1, -1, { 0, 0, "" }, "β", 0, 26, "60 0D 18 01 67 2C 40", "ECI-26 H1 (UTF-8)" },
|
||||
@ -205,7 +204,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 14*/ { DATA_MODE, 0, -1, ZINT_FULL_MULTIBYTE, { 0, 0, "" }, "β", 0, 0, "0B 56 2F 78 00", "H1 (UTF-8) (full multibyte)" },
|
||||
/* 15*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ÿ", 0, 0, "30 01 7F 00", "B1 (ISO 8859-1)" },
|
||||
/* 16*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ÿÿÿ", 0, 0, "30 05 7F 7F 7F 60", "B3 (ISO 8859-1)" },
|
||||
/* 17*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "㈩一", 0, 0, "08 15 68 0E 7F 70 00", "H2 (GB 2312)" },
|
||||
/* 17*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "㈩一", ZINT_WARN_NONCOMPLIANT, 0, "Warning 08 15 68 0E 7F 70 00", "H2 (GB 2312)" },
|
||||
/* 18*/ { UNICODE_MODE, 29, -1, -1, { 0, 0, "" }, "㈩一", 0, 29, "60 0E 44 0A 74 07 3F 78 00", "ECI-29 H2 (GB 2312)" },
|
||||
/* 19*/ { DATA_MODE, 0, -1, -1, { 0, 0, "" }, "\177\177", 0, 0, "30 02 7F 3F 40", "B2 (ASCII)" },
|
||||
/* 20*/ { DATA_MODE, 0, -1, -1, { 0, 0, "" }, "\177\177\177", 0, 0, "30 04 7F 3F 5F 60", "B3 (ASCII)" },
|
||||
@ -227,27 +226,27 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 36*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ABCDE\011F", 0, 0, "20 01 08 32 3E 49 17 30", "U7 (ASCII)" },
|
||||
/* 37*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "1 1234ABCD12.2abcd-12", 0, 0, "13 7A 23 41 2A 3F 68 01 08 3E 4F 66 1E 5F 70 00 44 1F 2F 6E 0F 0F 74", "N6 U4 N4 L4 N3 (ASCII)" },
|
||||
/* 38*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "1 123ABCDE12.2abcd-12", 0, 0, "28 1F 40 42 06 28 59 43 27 01 05 7D 56 42 49 16 34 7F 6D 30 08 2F 60", "M21 (ASCII)" },
|
||||
/* 39*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "国外通信教材 Matlab6.5", 0, 0, "09 63 27 20 4E 24 1F 05 21 58 22 13 7E 1E 4C 78 09 56 00 3D 3F 4A 45 3F 50", "H6 U2 L5 N3 (GB 2312) (Same as D.2 example)" },
|
||||
/* 39*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "国外通信教材 Matlab6.5", ZINT_WARN_NONCOMPLIANT, 0, "Warning 09 63 27 20 4E 24 1F 05 21 58 22 13 7E 1E 4C 78 09 56 00 3D 3F 4A 45 3F 50", "H6 U2 L5 N3 (GB 2312) (Same as D.2 example)" },
|
||||
/* 40*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT", 0, 0, "20 00 4F 30", "U3 (ASCII)" },
|
||||
/* 41*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "aat", 0, 0, "18 00 4F 30", "L3 (ASCII)" },
|
||||
/* 42*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT2556", 0, 0, "20 00 4F 58 7F 65 47 7A", "U3 N4 (ASCII) (note same bit count as M7)" },
|
||||
/* 43*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT2556 ", 0, 0, "29 22 4E 42 0A 14 37 6F 60", "M8 (ASCII)" },
|
||||
/* 44*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT2556 电", 0, 0, "29 22 4E 42 0A 14 37 6F 62 2C 1F 7E 00", "M8 H1 (GB 2312)" },
|
||||
/* 44*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT2556 电", ZINT_WARN_NONCOMPLIANT, 0, "Warning 29 22 4E 42 0A 14 37 6F 62 2C 1F 7E 00", "M8 H1 (GB 2312)" },
|
||||
/* 45*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, " 200", 0, 0, "11 7A 06 23 7D 00", "N4 (ASCII)" },
|
||||
/* 46*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, " 200mA至", 0, 0, "2F 60 40 00 60 2B 78 63 41 7F 40", "M6 H1 (GB 2312)" },
|
||||
/* 46*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, " 200mA至", ZINT_WARN_NONCOMPLIANT, 0, "Warning 2F 60 40 00 60 2B 78 63 41 7F 40", "M6 H1 (GB 2312)" },
|
||||
/* 47*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "2A tel:86 019 82512738", 0, 0, "28 22 5F 4F 29 48 5F 6D 7E 6F 55 57 1F 28 63 0F 5A 11 64 0F 74", "M2 L5(with control) N15 (ASCII)" },
|
||||
/* 48*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "至2A tel:86 019 82512738", 0, 0, "30 07 56 60 4C 48 13 6A 32 17 7B 3F 5B 75 35 67 6A 18 63 76 44 39 03 7D 00", "B4 L5(with control) N15 (GB 2312)" },
|
||||
/* 49*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", 0, 0, "(62) 29 22 22 1C 4E 41 42 7E 0A 40 14 00 37 7E 6F 00 62 7E 2C 00 1C 7E 4B 00 41 7E 18 00", "M8 H11 M6 B4 L5(with control) N15 (GB 2312) (*NOT SAME* as D3 example Figure D.1, M8 H11 M6 H1 M3 L4(with control) N15, which uses a few more bits)" },
|
||||
/* 48*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "至2A tel:86 019 82512738", ZINT_WARN_NONCOMPLIANT, 0, "Warning 30 07 56 60 4C 48 13 6A 32 17 7B 3F 5B 75 35 67 6A 18 63 76 44 39 03 7D 00", "B4 L5(with control) N15 (GB 2312)" },
|
||||
/* 49*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", ZINT_WARN_NONCOMPLIANT, 0, "Warning (62) 29 22 22 1C 4E 41 42 7E 0A 40 14 00 37 7E 6F 00 62 7E 2C 00 1C 7E 4B 00 41 7E 18 00", "M8 H11 M6 B4 L5(with control) N15 (GB 2312) (*NOT SAME* as D3 example Figure D.1, M8 H11 M6 H1 M3 L4(with control) N15, which uses a few more bits)" },
|
||||
/* 50*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::", 0, 0, "(588) 37 68 68 68 68 68 74 7E 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B512 (ASCII)" },
|
||||
/* 51*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\177", 0, 0, "(591) 37 68 68 68 68 68 74 7E 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B513 (ASCII)" },
|
||||
/* 52*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::至", 0, 0, "(591) 37 68 68 68 68 68 74 7C 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B511 H1 (GB 2312)" },
|
||||
/* 53*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::至:", 0, 0, "(592) 37 68 68 68 68 68 74 7E 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B513 (GB 2312)" },
|
||||
/* 54*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电123456", 0, 0, "09 30 72 61 7F 70 41 76 72 1F 68", "H2 (GB 2312) N6" },
|
||||
/* 55*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电abcdef", 0, 0, "09 30 72 61 7F 71 00 08 43 10 5D 40", "H2 (GB 2312) L6" },
|
||||
/* 56*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电电电电\011\011\011", 0, 0, "09 30 72 61 65 43 4B 07 16 0F 7F 14 02 04 42 21 10", "H5 (GB 2312) B3" },
|
||||
/* 57*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "1234567电电", 0, 0, "14 1E 6E 22 5E 3F 59 30 72 61 7F 70 00", "N7 H2 (GB 2312)" },
|
||||
/* 52*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::至", ZINT_WARN_NONCOMPLIANT, 0, "Warning (591) 37 68 68 68 68 68 74 7C 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B511 H1 (GB 2312)" },
|
||||
/* 53*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::至:", ZINT_WARN_NONCOMPLIANT, 0, "Warning (592) 37 68 68 68 68 68 74 7E 74 74 74 74 74 3A 3A 3A 3A 3A 3A 3A 1D 1D 1D 1D 1D 1D 1D 0E", "B513 (GB 2312)" },
|
||||
/* 54*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电123456", ZINT_WARN_NONCOMPLIANT, 0, "Warning 09 30 72 61 7F 70 41 76 72 1F 68", "H2 (GB 2312) N6" },
|
||||
/* 55*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电abcdef", ZINT_WARN_NONCOMPLIANT, 0, "Warning 09 30 72 61 7F 71 00 08 43 10 5D 40", "H2 (GB 2312) L6" },
|
||||
/* 56*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电电电电\011\011\011", ZINT_WARN_NONCOMPLIANT, 0, "Warning 09 30 72 61 65 43 4B 07 16 0F 7F 14 02 04 42 21 10", "H5 (GB 2312) B3" },
|
||||
/* 57*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "1234567电电", ZINT_WARN_NONCOMPLIANT, 0, "Warning 14 1E 6E 22 5E 3F 59 30 72 61 7F 70 00", "N7 H2 (GB 2312)" },
|
||||
/* 58*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "12345678mA 2", 0, 0, "12 1E 6E 23 06 3F 76 02 5F 02 7E 00", "N8 M4" },
|
||||
/* 59*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ABCDEFG电电", 0, 0, "20 01 08 32 0A 37 05 43 4B 07 7F 40", "U7 H2 (GB 2312)" },
|
||||
/* 59*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ABCDEFG电电", ZINT_WARN_NONCOMPLIANT, 0, "Warning 20 01 08 32 0A 37 05 43 4B 07 7F 40", "U7 H2 (GB 2312)" },
|
||||
/* 60*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ABCDEFGHIJ8mA 2", 0, 0, "20 01 08 32 0A 31 68 27 70 46 02 5F 02 7E 00", "U10 M5" },
|
||||
/* 61*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "ABCDEFGHIJ\011\011\011\011", 0, 0, "20 01 08 32 0A 31 68 27 78 03 04 42 21 10 48 00", "U10 B4" },
|
||||
/* 62*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "8mA B123456789", 0, 0, "29 0C 05 3E 17 7C 40 7B 39 0C 2B 7E 40", "M5 N9" },
|
||||
@ -255,8 +254,8 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 64*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "\011\011\011\011123456", 0, 0, "30 06 09 04 42 21 12 03 6D 64 3F 50", "B4 N6" },
|
||||
/* 65*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "\011\011\011\011ABCDEF", 0, 0, "30 06 09 04 42 21 14 00 11 06 21 3B", "B4 U6" },
|
||||
/* 66*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "\011\011\011\0118mA 2", 0, 0, "30 06 09 04 42 21 15 11 40 57 60 5F 40", "B4 M5" },
|
||||
/* 67*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电电电电\015\012", 0, 0, "09 30 72 61 65 43 4B 07 16 0F 73 03 7E 00", "H7 (GB 2312)" },
|
||||
/* 68*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电电电电12", 0, 0, "09 30 72 61 65 43 4B 07 16 0F 7B 37 7E 00", "H7 (GB 2312)" },
|
||||
/* 67*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电电电电\015\012", ZINT_WARN_NONCOMPLIANT, 0, "Warning 09 30 72 61 65 43 4B 07 16 0F 73 03 7E 00", "H7 (GB 2312)" },
|
||||
/* 68*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "电电电电电12", ZINT_WARN_NONCOMPLIANT, 0, "Warning 09 30 72 61 65 43 4B 07 16 0F 7B 37 7E 00", "H7 (GB 2312)" },
|
||||
/* 69*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "1234567.8\015\012123456", 0, 0, "10 1E 6E 23 79 30 67 77 0F 37 11 7E 40", "N17" },
|
||||
/* 70*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "˘", ZINT_WARN_USES_ECI, 4, "Warning 60 02 18 00 51 00", "ECI-4 B1 (ISO 8859-2)" },
|
||||
/* 71*/ { UNICODE_MODE, 4, -1, -1, { 0, 0, "" }, "˘", 0, 4, "60 02 18 00 51 00", "ECI-4 B1 (ISO 8859-2)" },
|
||||
@ -266,11 +265,11 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 75*/ { UNICODE_MODE, 7, -1, -1, { 0, 0, "" }, "Ж", 0, 7, "60 03 58 00 5B 00", "ECI-7 B1 (ISO 8859-5)" },
|
||||
/* 76*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "Ș", ZINT_WARN_USES_ECI, 18, "Warning 60 09 18 00 55 00", "ECI-18 B1 (ISO 8859-16)" },
|
||||
/* 77*/ { UNICODE_MODE, 18, -1, -1, { 0, 0, "" }, "Ș", 0, 18, "60 09 18 00 55 00", "ECI-18 B1 (ISO 8859-16)" },
|
||||
/* 78*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "テ", 0, 0, "08 34 6F 78 00", "H1 (GB 2312)" },
|
||||
/* 78*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "テ", ZINT_WARN_NONCOMPLIANT, 0, "Warning 08 34 6F 78 00", "H1 (GB 2312)" },
|
||||
/* 79*/ { UNICODE_MODE, 20, -1, -1, { 0, 0, "" }, "テ", 0, 20, "60 0A 18 01 41 59 20", "ECI-20 B2 (SHIFT JIS)" },
|
||||
/* 80*/ { UNICODE_MODE, 20, -1, -1, { 0, 0, "" }, "テテ", 0, 20, "60 0A 18 03 41 59 30 36 28 00", "ECI-20 B4 (SHIFT JIS)" },
|
||||
/* 81*/ { UNICODE_MODE, 20, -1, -1, { 0, 0, "" }, "\\\\", 0, 20, "60 0A 18 03 40 57 70 15 78 00", "ECI-20 B4 (SHIFT JIS)" },
|
||||
/* 82*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "…", 0, 0, "08 01 5F 78 00", "H1 (GB 2312)" },
|
||||
/* 82*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "…", ZINT_WARN_NONCOMPLIANT, 0, "Warning 08 01 5F 78 00", "H1 (GB 2312)" },
|
||||
/* 83*/ { UNICODE_MODE, 21, -1, -1, { 0, 0, "" }, "…", 0, 21, "60 0A 58 00 42 40", "ECI-21 B1 (Win 1250)" },
|
||||
/* 84*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "Ґ", ZINT_WARN_USES_ECI, 22, "Warning 60 0B 18 00 52 40", "ECI-22 B1 (Win 1251)" },
|
||||
/* 85*/ { UNICODE_MODE, 22, -1, -1, { 0, 0, "" }, "Ґ", 0, 22, "60 0B 18 00 52 40", "ECI-22 B1 (Win 1251)" },
|
||||
@ -285,7 +284,7 @@ static void test_input(int index, int generate, int debug) {
|
||||
/* 94*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "龘", ZINT_WARN_USES_ECI, 26, "Warning 60 0D 18 02 74 6F 53 00", "ECI-26 B3 (UTF-8)" },
|
||||
/* 95*/ { UNICODE_MODE, 28, -1, -1, { 0, 0, "" }, "龘", 0, 28, "60 0E 18 01 7C 75 20", "ECI-28 B2 (Big5)" },
|
||||
/* 96*/ { UNICODE_MODE, 28, -1, -1, { 0, 0, "" }, "龘龘", 0, 28, "60 0E 18 03 7C 75 3F 1D 28 00", "ECI-28 B4 (Big5)" },
|
||||
/* 97*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "齄", 0, 0, "0F 4B 6F 78 00", "H1 (GB 2312)" },
|
||||
/* 97*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "齄", ZINT_WARN_NONCOMPLIANT, 0, "Warning 0F 4B 6F 78 00", "H1 (GB 2312)" },
|
||||
/* 98*/ { UNICODE_MODE, 29, -1, -1, { 0, 0, "" }, "齄", 0, 29, "60 0E 47 65 77 7C 00", "ECI-29 H1 (GB 2312)" },
|
||||
/* 99*/ { UNICODE_MODE, 29, -1, -1, { 0, 0, "" }, "齄齄", 0, 29, "60 0E 47 65 77 4B 6F 78 00", "ECI-29 H2 (GB 2312)" },
|
||||
/*100*/ { UNICODE_MODE, 0, -1, -1, { 0, 0, "" }, "가", ZINT_WARN_USES_ECI, 26, "Warning 60 0D 18 02 75 2C 10 00", "ECI-26 B3 (UTF-8)" },
|
||||
@ -416,7 +415,7 @@ static void test_encode(int index, int generate, int debug) {
|
||||
"101111010010100001010010110111"
|
||||
"111111000000111111000000111111"
|
||||
},
|
||||
/* 2*/ { "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", UNICODE_MODE, 3, 3, 0, 42, 42, "AIMD014 Figure D.1 **NOT SAME** different encodation, see test_input dataset",
|
||||
/* 2*/ { "AAT2556 电池充电器+降压转换器 200mA至2A tel:86 019 82512738", UNICODE_MODE, 3, 3, ZINT_WARN_NONCOMPLIANT, 42, 42, "AIMD014 Figure D.1 **NOT SAME** different encodation, see test_input dataset",
|
||||
"111111000000111111000000111111000000111111"
|
||||
"101101001100101111001010101011001100101101"
|
||||
"110001011010110101010000100011000000100001"
|
||||
@ -603,3 +602,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et norl : */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -937,11 +936,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[17984 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, data[i].primary, escaped, &ret_len);
|
||||
@ -1186,3 +1185,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -302,11 +301,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -337,3 +336,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -1701,11 +1700,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[2710 * 8 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -2172,3 +2171,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -173,11 +172,11 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -913,11 +912,11 @@ static void test_examples(int index, int generate, int debug) {
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -1510,3 +1509,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -129,11 +128,11 @@ static void test_upce_input(int index, int debug) {
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, modules_dump);
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].hrt, (int) strlen(data[i].hrt), NULL /*primary*/, escaped, &ret_len);
|
||||
@ -960,11 +959,11 @@ static void test_encode(int index, int generate, int debug) {
|
||||
assert_zero(ret, "i:%d %s testUtilBwippCmp %d != 0 %s\n actual: %s\nexpected: %s\n",
|
||||
i, testUtilBarcodeName(symbol->symbology), ret, cmp_msg, cmp_buf, data[i].expected);
|
||||
}
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, debug)) {
|
||||
if (do_zxingcpp && testUtilCanZXingCPP(i, symbol, data[i].data, length, debug)) {
|
||||
int cmp_len, ret_len;
|
||||
char modules_dump[8192 + 1];
|
||||
assert_notequal(testUtilModulesDump(symbol, modules_dump, sizeof(modules_dump)), -1, "i:%d testUtilModulesDump == -1\n", i);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
ret = testUtilZXingCPP(i, symbol, data[i].data, length, modules_dump, cmp_buf, sizeof(cmp_buf), &cmp_len);
|
||||
assert_zero(ret, "i:%d %s testUtilZXingCPP ret %d != 0\n", i, testUtilBarcodeName(symbol->symbology), ret);
|
||||
|
||||
ret = testUtilZXingCPPCmp(symbol, cmp_msg, cmp_buf, cmp_len, data[i].data, length, NULL /*primary*/, escaped, &ret_len);
|
||||
@ -1156,3 +1155,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
/*
|
||||
* Adapted from qrencode/tests/common.c
|
||||
* Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
|
||||
@ -1608,8 +1607,8 @@ int testUtilCmpEpss(const char *eps1, const char *eps2) {
|
||||
char buf1[1024];
|
||||
char buf2[1024];
|
||||
size_t len1 = 0, len2 = 0;
|
||||
char first_line[] = "%!PS-Adobe-3.0 EPSF-3.0\n";
|
||||
char second_line_start[] = "%%Creator: Zint ";
|
||||
static char first_line[] = "%!PS-Adobe-3.0 EPSF-3.0\n";
|
||||
static char second_line_start[] = "%%Creator: Zint ";
|
||||
|
||||
fp1 = fopen(eps1, "r");
|
||||
if (!fp1) {
|
||||
@ -2170,7 +2169,7 @@ static char *testUtilBwippEscape(char *bwipp_data, int bwipp_data_size, const ch
|
||||
while (b < be && d < de) {
|
||||
/* Have to escape double quote otherwise Ghostscript gives "Unterminated quote in @-file" for some reason */
|
||||
/* Escape single quote also to avoid having to do proper shell escaping TODO: proper shell escaping */
|
||||
if (*d < 0x20 || *d >= 0x7F || *d == '^' || *d == '"' || *d == '\'') {
|
||||
if (*d < 0x20 || *d >= 0x7F || *d == '^' || *d == '"' || *d == '\'' || (!zint_escape_mode && *d == '\\')) {
|
||||
if (b + 4 >= be) {
|
||||
fprintf(stderr, "testUtilBwippEscape: double quote bwipp_data buffer full (%d)\n", bwipp_data_size);
|
||||
return NULL;
|
||||
@ -2244,14 +2243,15 @@ static void testUtilISBNHyphenate(char *bwipp_data, int addon_posn) {
|
||||
/* Create bwipp_dump.ps command and run */
|
||||
int testUtilBwipp(int index, const struct zint_symbol *symbol, int option_1, int option_2, int option_3,
|
||||
const char *data, int length, const char *primary, char *buffer, int buffer_size) {
|
||||
const char *cmd_fmt = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' backend/tests/tools/bwipp_dump.ps";
|
||||
const char *cmd_opts_fmt = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' -so='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
static const char cmd_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
static const char cmd_opts_fmt[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%s' -so='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
// If data > 2K
|
||||
const char *cmd_fmt2 = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2043s' -sd2='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
const char *cmd_opts_fmt2 = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2043s' -sd2='%s' -so='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
static const char cmd_fmt2[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2043s' -sd2='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
static const char cmd_opts_fmt2[] = "gs -dNOPAUSE -dBATCH -dNODISPLAY -q -sb=%s -sd='%.2043s' -sd2='%s' -so='%s'"
|
||||
" backend/tests/tools/bwipp_dump.ps";
|
||||
|
||||
int symbology = symbol->symbology;
|
||||
int data_len = length == -1 ? (int) strlen(data) : length;
|
||||
@ -3052,7 +3052,7 @@ int testUtilHaveZXingCPPDecoder(void) {
|
||||
|
||||
/* Map Zint symbology to ZXing-C++ format name */
|
||||
static const char *testUtilZXingCPPName(int index, const struct zint_symbol *symbol, const char *source,
|
||||
const int debug) {
|
||||
const int length, const int debug) {
|
||||
struct item {
|
||||
const char *name;
|
||||
int define;
|
||||
@ -3175,7 +3175,7 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
|
||||
{ "", -1, 113, },
|
||||
{ "", -1, 114, },
|
||||
{ "DotCode", BARCODE_DOTCODE, 115, },
|
||||
{ "", BARCODE_HANXIN, 116, },
|
||||
{ "HanXin", BARCODE_HANXIN, 116, },
|
||||
{ "", -1, 117, },
|
||||
{ "", -1, 118, },
|
||||
{ "", -1, 119, },
|
||||
@ -3236,7 +3236,6 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
|
||||
}
|
||||
} else if (is_extendable(symbology)) {
|
||||
if (symbology == BARCODE_EANX || symbology == BARCODE_EANX_CHK) {
|
||||
const int length = (int) strlen(source);
|
||||
if (length < 9) {
|
||||
if (length < 6) {
|
||||
printf("i:%d %s not ZXing-C++ compatible, EAN-5/EAN-2 not supported\n",
|
||||
@ -3255,32 +3254,47 @@ static const char *testUtilZXingCPPName(int index, const struct zint_symbol *sym
|
||||
}
|
||||
|
||||
/* Whether can use ZXing-C++ to check a symbology with given options */
|
||||
int testUtilCanZXingCPP(int index, const struct zint_symbol *symbol, const char *source, const int debug) {
|
||||
return testUtilZXingCPPName(index, symbol, source, debug) != NULL;
|
||||
int testUtilCanZXingCPP(int index, const struct zint_symbol *symbol, const char *source, const int length,
|
||||
const int debug) {
|
||||
return testUtilZXingCPPName(index, symbol, source, length, debug) != NULL;
|
||||
}
|
||||
|
||||
int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, char *bits, char *buffer,
|
||||
const int buffer_size, int *p_cmp_len) {
|
||||
const char *cmd_fmt = "zxingcppdecoder -width %d -textonly -format %s -zint '%d,%d' -bits '%s'";
|
||||
int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, const int length, char *bits,
|
||||
char *buffer, const int buffer_size, int *p_cmp_len) {
|
||||
static const char cmd_fmt[] = "zxingcppdecoder -width %d -textonly -format %s -zint '%d,%d' -bits '%s'";
|
||||
static const char cs_cmd_fmt[] = "zxingcppdecoder -width %d -textonly -format %s -zint '%d,%d' -bits '%s'"
|
||||
" -charset %s";
|
||||
|
||||
const int length = (int) strlen(bits);
|
||||
const int bits_len = (int) strlen(bits);
|
||||
const int width = symbol->width;
|
||||
const int symbology = symbol->symbology;
|
||||
char *cmd = (char *) testutil_alloca(length + 1024);
|
||||
char *cmd = (char *) testutil_alloca(bits_len + 1024);
|
||||
const char *zxingcpp_barcode = NULL;
|
||||
const int data_mode = (symbol->input_mode & 0x07) == DATA_MODE;
|
||||
int set_charset = 0;
|
||||
|
||||
FILE *fp = NULL;
|
||||
int cnt;
|
||||
|
||||
buffer[0] = '\0';
|
||||
|
||||
zxingcpp_barcode = testUtilZXingCPPName(index, symbol, source, 0 /*debug*/);
|
||||
zxingcpp_barcode = testUtilZXingCPPName(index, symbol, source, length, 0 /*debug*/);
|
||||
if (!zxingcpp_barcode) {
|
||||
fprintf(stderr, "i:%d testUtilZXingCPP: no mapping for %s\n", index, testUtilBarcodeName(symbology));
|
||||
return -1;
|
||||
}
|
||||
sprintf(cmd, cmd_fmt, width, zxingcpp_barcode, symbology, symbol->option_2, bits);
|
||||
|
||||
if (symbol->eci == 0 && symbol->symbology == BARCODE_HANXIN) {
|
||||
int converted_len = length;
|
||||
unsigned char *converted_buf = (unsigned char *) testutil_alloca(converted_len + 1);
|
||||
set_charset = utf8_to_eci(0, (const unsigned char *) source, converted_buf, &converted_len) != 0;
|
||||
}
|
||||
if (set_charset) {
|
||||
static const char charset[] = "GB18030";
|
||||
sprintf(cmd, cs_cmd_fmt, width, zxingcpp_barcode, symbology, symbol->option_2, bits, charset);
|
||||
} else {
|
||||
sprintf(cmd, cmd_fmt, width, zxingcpp_barcode, symbology, symbol->option_2, bits);
|
||||
}
|
||||
|
||||
if (symbol->debug & ZINT_DEBUG_TEST_PRINT) {
|
||||
printf("i:%d testUtilZXingCPP: cmd %s\n", index, cmd);
|
||||
@ -3309,9 +3323,10 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
|
||||
|
||||
testutil_pclose(fp);
|
||||
|
||||
if (data_mode && is_eci_convertible(symbol->eci)) {
|
||||
if (data_mode && (is_eci_convertible(symbol->eci) || symbol->eci == 899)) {
|
||||
const int eci = symbol->eci == 899 ? 3 : symbol->eci;
|
||||
int error_number;
|
||||
const int eci_length = get_eci_length(symbol->eci, (const unsigned char *) buffer, cnt);
|
||||
const int eci_length = get_eci_length(eci, (const unsigned char *) buffer, cnt);
|
||||
unsigned char *preprocessed = (unsigned char *) testutil_alloca(eci_length + 1);
|
||||
|
||||
if (eci_length >= buffer_size) {
|
||||
@ -3319,11 +3334,11 @@ int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source,
|
||||
index, buffer_size, eci_length, cmd);
|
||||
return -1;
|
||||
}
|
||||
error_number = utf8_to_eci(symbol->eci, (const unsigned char *) buffer, preprocessed, &cnt);
|
||||
error_number = utf8_to_eci(eci, (const unsigned char *) buffer, preprocessed, &cnt);
|
||||
if (error_number == 0) {
|
||||
memcpy(buffer, preprocessed, cnt);
|
||||
} else {
|
||||
if (symbol->eci != 0) {
|
||||
if (eci != 0) {
|
||||
fprintf(stderr, "i:%d testUtilZXingCPP: utf8_to_eci == %d (%s)\n", index, error_number, cmd);
|
||||
return -1;
|
||||
} else {
|
||||
@ -3605,16 +3620,16 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
upcean[13] = ' ';
|
||||
expected = upcean;
|
||||
} else if (symbology == BARCODE_EANX && (expected_len == 7
|
||||
|| (strchr(expected, '+') != NULL && (expected_len == 10 || expected_len == 13)))) {
|
||||
|| (strchr(expected, '+') != NULL && (expected_len == 10 || expected_len == 13)))) {
|
||||
memcpy(upcean, expected, 7);
|
||||
upcean[7] = gs1_check_digit((const unsigned char *) upcean, 7);
|
||||
if (expected_len == 10) {
|
||||
if (expected_len == 10) {
|
||||
upcean[8] = ' ';
|
||||
memcpy(upcean + 9, expected + 8, 2);
|
||||
} else if (expected_len == 13) {
|
||||
} else if (expected_len == 13) {
|
||||
upcean[8] = ' ';
|
||||
memcpy(upcean + 9, expected + 8, 5);
|
||||
}
|
||||
}
|
||||
expected_len++;
|
||||
upcean[expected_len] = '\0';
|
||||
expected = upcean;
|
||||
@ -3667,3 +3682,5 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2019 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2019-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
|
||||
@ -27,14 +27,13 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
/*
|
||||
* Adapted from qrencode/tests/common.h
|
||||
* Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
|
||||
*/
|
||||
|
||||
#ifndef TESTCOMMON_H
|
||||
#define TESTCOMMON_H
|
||||
#ifndef Z_TESTCOMMON_H
|
||||
#define Z_TESTCOMMON_H
|
||||
|
||||
#define ZINT_DEBUG_TEST_PRINT 16
|
||||
#define ZINT_DEBUG_TEST_LESS_NOISY 32
|
||||
@ -177,9 +176,10 @@ int testUtilBwippCmpRow(const struct zint_symbol *symbol, int row, char *msg, co
|
||||
const char *expected);
|
||||
|
||||
int testUtilHaveZXingCPPDecoder(void);
|
||||
int testUtilCanZXingCPP(int index, const struct zint_symbol *symbol, const char *data, const int debug);
|
||||
int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, char *bits, char *buffer,
|
||||
const int buffer_size, int *p_cmp_len);
|
||||
int testUtilCanZXingCPP(int index, const struct zint_symbol *symbol, const char *data, const int length,
|
||||
const int debug);
|
||||
int testUtilZXingCPP(int index, struct zint_symbol *symbol, const char *source, const int length, char *bits,
|
||||
char *buffer, const int buffer_size, int *p_cmp_len);
|
||||
int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, int cmp_len,
|
||||
const char *expected, int expected_len, const char *primary, char *ret_buf, int *p_ret_len);
|
||||
|
||||
@ -187,4 +187,5 @@ int testUtilZXingCPPCmp(struct zint_symbol *symbol, char *msg, char *cmp_buf, in
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TESTCOMMON_H */
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
#endif /* Z_TESTCOMMON_H */
|
||||
|
@ -1,43 +1,6 @@
|
||||
--- /home/mburke/code/gitlost/postscriptbarcode/build/monolithic/barcode.ps 2022-02-10 22:21:47.533942041 +0000
|
||||
+++ backend/tests/tools/bwipp_dump.ps 2022-01-02 22:32:35.289274072 +0000
|
||||
@@ -206,8 +206,8 @@
|
||||
|
||||
% --BEGIN RESOURCE gs1lint--
|
||||
% --REQUIRES preamble raiseerror--
|
||||
-%%BeginResource: uk.co.terryburton.bwipp gs1lint 0.0 2021092800 362430 390472
|
||||
-%%BeginData: 1674 ASCII Lines
|
||||
+%%BeginResource: uk.co.terryburton.bwipp gs1lint 0.0 2021092800 362243 386853
|
||||
+%%BeginData: 1673 ASCII Lines
|
||||
/setpacking where {pop currentpacking true setpacking} if
|
||||
2 dict
|
||||
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
|
||||
@@ -409,7 +409,7 @@
|
||||
} bind def
|
||||
|
||||
/lintiban {
|
||||
- dup length 4 le { pop pop /bwipp.GS1tooShort (IBAN too short) false exit } if
|
||||
+ dup length 4 lt { pop pop /bwipp.GS1tooShort (IBAN too short) false exit } if
|
||||
dup true exch {
|
||||
1 string dup 0 4 -1 roll put
|
||||
(0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ)
|
||||
@@ -1655,7 +1655,6 @@
|
||||
(712) exch dup
|
||||
(713) exch dup
|
||||
(714) exch dup
|
||||
- (715) exch dup
|
||||
pop
|
||||
|
||||
[
|
||||
@@ -7706,7 +7705,7 @@
|
||||
% --EXAM: (01)95012345678903(3103)000123
|
||||
% --EXOP:
|
||||
% --RNDR: renlinear renmatrix
|
||||
-%%BeginResource: uk.co.terryburton.bwipp databarexpanded 0.0 2021092800 242827 244887
|
||||
+%%BeginResource: uk.co.terryburton.bwipp databarexpanded 0.0 2021092800 242723 244887
|
||||
%%BeginData: 886 ASCII Lines
|
||||
/setpacking where {pop currentpacking true setpacking} if
|
||||
1 dict
|
||||
@@ -15180,8 +15179,8 @@
|
||||
--- /home/mburke/code/bwipp/postscriptbarcode/build/monolithic/barcode.ps 2022-04-04 14:55:50.742795871 +0100
|
||||
+++ backend/tests/tools/bwipp_dump.ps 2022-04-09 18:28:15.057483295 +0100
|
||||
@@ -15187,8 +15187,8 @@
|
||||
} bind
|
||||
/fime {
|
||||
/sbs [2.25 6.75 2.25 15.75 2.25 6.75 2.25] def
|
||||
@ -48,7 +11,7 @@
|
||||
} bind
|
||||
>> def
|
||||
|
||||
@@ -26438,34 +26437,80 @@
|
||||
@@ -26445,34 +26445,80 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -148,7 +111,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -26524,7 +26569,7 @@
|
||||
@@ -26531,7 +26577,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -157,7 +120,7 @@
|
||||
|
||||
% Get the result of encoding with ean8 and gs1-cc
|
||||
options (lintype) (ean8) put
|
||||
@@ -26532,29 +26577,75 @@
|
||||
@@ -26539,29 +26585,75 @@
|
||||
options (dontdraw) true put
|
||||
|
||||
% Plot the linear part
|
||||
@ -253,7 +216,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -26613,34 +26704,80 @@
|
||||
@@ -26620,34 +26712,80 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -353,7 +316,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -26714,34 +26851,80 @@
|
||||
@@ -26721,34 +26859,80 @@
|
||||
/opt options
|
||||
>> def
|
||||
|
||||
@ -453,7 +416,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -26800,7 +26983,7 @@
|
||||
@@ -26807,7 +26991,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -462,7 +425,7 @@
|
||||
|
||||
options (lintype) (databaromni) put
|
||||
options (linkage) true put
|
||||
@@ -26811,7 +26994,7 @@
|
||||
@@ -26818,7 +27002,7 @@
|
||||
linear options //databaromni exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -471,7 +434,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -26842,20 +27025,66 @@
|
||||
@@ -26849,20 +27033,66 @@
|
||||
sep 0 [0 0 0] putinterval
|
||||
sep sep length 4 sub [0 0 0 0] putinterval
|
||||
18 sepfinder 64 sepfinder
|
||||
@ -550,7 +513,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -26913,7 +27142,7 @@
|
||||
@@ -26920,7 +27150,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -559,7 +522,7 @@
|
||||
|
||||
options (lintype) (databarstacked) put
|
||||
options (linkage) true put
|
||||
@@ -26924,7 +27153,7 @@
|
||||
@@ -26931,7 +27161,7 @@
|
||||
linear options //databarstacked exec
|
||||
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
|
||||
dup (pixy) get /linheight exch def
|
||||
@ -568,7 +531,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -26952,20 +27181,52 @@
|
||||
@@ -26959,20 +27189,52 @@
|
||||
sep 0 [ 0 0 0 0 ] putinterval
|
||||
sep sep length 4 sub [ 0 0 0 0 ] putinterval
|
||||
18 sepfinder
|
||||
@ -633,7 +596,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27023,7 +27284,7 @@
|
||||
@@ -27030,7 +27292,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -642,7 +605,7 @@
|
||||
|
||||
options (lintype) (databarstackedomni) put
|
||||
options (linkage) true put
|
||||
@@ -27034,7 +27295,7 @@
|
||||
@@ -27041,7 +27303,7 @@
|
||||
linear options //databarstackedomni exec
|
||||
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
|
||||
dup (pixy) get /linheight exch def
|
||||
@ -651,7 +614,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -27062,20 +27323,52 @@
|
||||
@@ -27069,20 +27331,52 @@
|
||||
sep 0 [ 0 0 0 0 ] putinterval
|
||||
sep sep length 4 sub [ 0 0 0 0 ] putinterval
|
||||
18 sepfinder
|
||||
@ -716,7 +679,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27248,7 +27541,7 @@
|
||||
@@ -27255,7 +27549,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -725,7 +688,7 @@
|
||||
|
||||
options (lintype) (databarlimited) put
|
||||
options (linkage) true put
|
||||
@@ -27259,7 +27552,7 @@
|
||||
@@ -27266,7 +27560,7 @@
|
||||
linear options //databarlimited exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -734,7 +697,7 @@
|
||||
|
||||
% Plot the separator
|
||||
mark
|
||||
@@ -27267,22 +27560,68 @@
|
||||
@@ -27274,22 +27568,68 @@
|
||||
counttomark 1 sub array astore /sep exch def pop pop
|
||||
sep 0 [0 0 0] putinterval
|
||||
sep sep length 9 sub [0 0 0 0 0 0 0 0 0] putinterval % 4 + 5 right guard spaces
|
||||
@ -772,8 +735,7 @@
|
||||
+ /compsym comp options //gs1-cc exec def
|
||||
+ /ccpixs compsym /pixs get def
|
||||
+ /ccpixx compsym /pixx get def
|
||||
|
||||
- grestore
|
||||
+
|
||||
+ /linpixs [ 0 % Begin with left guard space
|
||||
+ linsbs { cvi 1 index 0 eq {{1}} {{0}} ifelse repeat } forall % Alternates x 1/0's
|
||||
+ ] def
|
||||
@ -802,7 +764,8 @@
|
||||
+ ] def
|
||||
+ /pixx ccpixx 1 add def
|
||||
+ } ifelse
|
||||
+
|
||||
|
||||
- grestore
|
||||
+ /pixy pixs length pixx idiv def
|
||||
+ <<
|
||||
+ /ren //renmatrix
|
||||
@ -817,7 +780,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27341,7 +27680,7 @@
|
||||
@@ -27348,7 +27688,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -826,7 +789,7 @@
|
||||
|
||||
options (lintype) (databarexpanded) put
|
||||
options (linkage) true put
|
||||
@@ -27352,7 +27691,7 @@
|
||||
@@ -27359,7 +27699,7 @@
|
||||
linear options //databarexpanded exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -835,7 +798,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -27381,20 +27720,60 @@
|
||||
@@ -27388,20 +27728,60 @@
|
||||
18 98 bot length 13 sub {} for
|
||||
69 98 bot length 13 sub {} for
|
||||
] {sepfinder} forall
|
||||
@ -908,7 +871,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27452,7 +27831,7 @@
|
||||
@@ -27459,7 +27839,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -917,7 +880,7 @@
|
||||
|
||||
options (lintype) (databarexpandedstacked) put
|
||||
options (linkage) true put
|
||||
@@ -27463,7 +27842,7 @@
|
||||
@@ -27470,7 +27850,7 @@
|
||||
linear options //databarexpandedstacked exec
|
||||
dup (pixs) get 0 2 index (pixx) get getinterval /bot exch def
|
||||
dup (pixy) get /linheight exch def
|
||||
@ -926,7 +889,7 @@
|
||||
|
||||
% Plot the separator
|
||||
/sepfinder {
|
||||
@@ -27489,21 +27868,49 @@
|
||||
@@ -27496,21 +27876,49 @@
|
||||
19 98 bot length 13 sub {} for
|
||||
70 98 bot length 13 sub {} for
|
||||
] {sepfinder} forall
|
||||
@ -989,7 +952,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -27562,7 +27969,7 @@
|
||||
@@ -27569,7 +27977,7 @@
|
||||
pop
|
||||
} ifelse
|
||||
|
||||
@ -998,7 +961,7 @@
|
||||
|
||||
options (inkspread) (0) put
|
||||
options (dontdraw) true put
|
||||
@@ -27589,35 +27996,87 @@
|
||||
@@ -27596,35 +28004,87 @@
|
||||
linear << options {} forall >> //gs1-128 exec
|
||||
dup (sbs) get /linsbs exch def
|
||||
dup (bhs) get 0 get 72 mul /linheight exch def
|
||||
@ -1100,16 +1063,7 @@
|
||||
|
||||
end
|
||||
|
||||
@@ -28074,7 +28533,7 @@
|
||||
% --EXAM: (235)5vBZIF%!<B;?oa%(01)01234567890128(8008)19052001
|
||||
% --EXOP: rows=16
|
||||
% --RNDR: renmatrix
|
||||
-%%BeginResource: uk.co.terryburton.bwipp gs1dotcode 0.0 2021092800 77802 77819
|
||||
+%%BeginResource: uk.co.terryburton.bwipp gs1dotcode 0.0 2021092800 77802 77923
|
||||
%%BeginData: 133 ASCII Lines
|
||||
/setpacking where {pop currentpacking true setpacking} if
|
||||
1 dict
|
||||
@@ -29050,3 +29509,189 @@
|
||||
@@ -29057,3 +29517,189 @@
|
||||
% --END ENCODER hibcazteccode--
|
||||
|
||||
% --END TEMPLATE--
|
||||
|
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
# Copyright (C) 2021-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
# vim: set ts=4 sw=4 et :
|
||||
set -e
|
||||
|
||||
@ -15,6 +15,7 @@ run_zxingcpp_test "test_code128" "encode"
|
||||
run_zxingcpp_test "test_dmatrix" "input"
|
||||
run_zxingcpp_test "test_dmatrix" "encode"
|
||||
run_zxingcpp_test "test_dotcode" "encode"
|
||||
run_zxingcpp_test "test_hanxin" "encode"
|
||||
run_zxingcpp_test "test_maxicode" "encode"
|
||||
run_zxingcpp_test "test_medical" "encode"
|
||||
run_zxingcpp_test "test_pdf417" "encode"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by BogDan Vatra *
|
||||
* bogdan@licentia.eu *
|
||||
* Copyright (C) 2010-2021 Robin Stuart *
|
||||
* Copyright (C) 2010-2022 Robin Stuart *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@ -14,7 +14,6 @@
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER >= 1900 /* MSVC 2015 */
|
||||
@ -459,9 +458,11 @@ namespace Zint {
|
||||
m_eci = ECIIndex + 2;
|
||||
} else if (ECIIndex >= 12 && ECIIndex <= 15) {
|
||||
m_eci = ECIIndex + 3;
|
||||
} else if (ECIIndex >= 16 && ECIIndex <= 26) {
|
||||
} else if (ECIIndex >= 16 && ECIIndex <= 31) {
|
||||
m_eci = ECIIndex + 4;
|
||||
} else if (ECIIndex == 27) {
|
||||
} else if (ECIIndex == 32) {
|
||||
m_eci = 170; /* ISO 646 Invariant */
|
||||
} else if (ECIIndex == 33) {
|
||||
m_eci = 899; /* 8-bit binary data */
|
||||
} else {
|
||||
m_eci = 0;
|
||||
@ -469,7 +470,7 @@ namespace Zint {
|
||||
}
|
||||
|
||||
void QZint::setECIValue(int eci) { // Sets literal value
|
||||
if (eci < 3 || (eci > 30 && eci != 899) || eci == 14 || eci == 19) {
|
||||
if (eci < 3 || (eci > 35 && eci != 170 && eci != 899) || eci == 14 || eci == 19) {
|
||||
m_eci = 0;
|
||||
} else {
|
||||
m_eci = eci;
|
||||
@ -1055,3 +1056,5 @@ namespace Zint {
|
||||
}
|
||||
}
|
||||
} /* namespace Zint */
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2021 by Robin Stuart <rstuart114@gmail.com> *
|
||||
* Copyright (C) 2021-2022 by Robin Stuart <rstuart114@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@ -12,7 +12,6 @@
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include "../qzint.h" /* Don't use <qzint.h> in case it's been changed */
|
||||
@ -193,7 +192,8 @@ private slots:
|
||||
int ecis[] = {
|
||||
0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
||||
12, 13, 15, 16, 17, 18, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30, 899,
|
||||
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
|
||||
34, 35, 170, 899,
|
||||
};
|
||||
for (int i = 0; i < ARRAY_SIZE(ecis); i++) {
|
||||
bc.setECI(i);
|
||||
@ -243,7 +243,10 @@ private slots:
|
||||
QTest::newRow("2") << 2 << 0;
|
||||
QTest::newRow("14") << 14 << 0;
|
||||
QTest::newRow("19") << 19 << 0;
|
||||
QTest::newRow("31") << 31 << 0;
|
||||
QTest::newRow("31") << 31 << 31;
|
||||
QTest::newRow("36") << 36 << 0;
|
||||
QTest::newRow("169") << 169 << 0;
|
||||
QTest::newRow("171") << 171 << 0;
|
||||
QTest::newRow("898") << 898 << 0;
|
||||
QTest::newRow("900") << 900 << 0;
|
||||
QTest::newRow("1000") << 1000 << 0;
|
||||
@ -974,3 +977,5 @@ private slots:
|
||||
|
||||
QTEST_MAIN(TestQZint)
|
||||
#include "test_qzint.moc"
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* zint_tcl.c TCL binding for zint */
|
||||
/*
|
||||
zint - the open source tcl binding to the zint barcode library
|
||||
Copyright (C) 2014 Harald Oehlmann <oehhar@users.sourceforge.net>
|
||||
Copyright (C) 2014-2022 Harald Oehlmann <oehhar@users.sourceforge.net>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -28,7 +28,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
/*
|
||||
History
|
||||
|
||||
@ -139,6 +138,9 @@
|
||||
- Added DBAR_EXPSTK, CODE16K, CODE49 -rows
|
||||
2021-12-17 GL
|
||||
- Added -fast option
|
||||
2022-04-08 GL
|
||||
- Updated ECIs to AIM ITS/04-023:2022
|
||||
Note changed names "unicode" -> "utf-16be", "euc-cn" -> "gb2312"
|
||||
*/
|
||||
|
||||
#if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
||||
@ -427,18 +429,24 @@ static const char *s_eci_list[] = {
|
||||
"cp1251", /*22: Windows-1251*/
|
||||
"cp1252", /*23: Windows-1252*/
|
||||
"cp1256", /*24: Windows-1256*/
|
||||
"unicode", /*25: UCS-2BE (High order byte first) Unicode BMP*/
|
||||
"utf-16be", /*25: UTF-16BE (High order byte first) Unicode*/
|
||||
"utf-8", /*26: Unicode (UTF-8)*/
|
||||
"ascii", /*27: ISO-646:1991 7-bit character set*/
|
||||
"big5", /*28: Big5 (Taiwan) Chinese Character Set*/
|
||||
"euc-cn", /*29: GB (PRC) Chinese Character Set*/
|
||||
"gb2312", /*29: GB 2312 (PRC) Chinese Character Set*/
|
||||
"iso2022-kr", /*30: Korean Character Set EUC-KR (KS X 1001:2002)*/
|
||||
"gbk", /*31: GBK Chinese Character Set*/
|
||||
"gb18030", /*32: GB 18030 Chinese Character Set*/
|
||||
"utf-16le", /*33: UTF-16LE (Low order byte first) Unicode*/
|
||||
"utf-32be", /*34: UTF-32BE (High order byte first) Unicode*/
|
||||
"utf-32le", /*35: UTF-32BE (Low order byte first) Unicode*/
|
||||
NULL
|
||||
};
|
||||
|
||||
/* The ECI numerical number to pass to ZINT */
|
||||
static const int s_eci_number[] = {
|
||||
3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,20,21,22,23,24,25,26,27,28,29,30
|
||||
3,4,5,6,7,8,9,10,11,12,13,15,16,17,18,20,21,22,23,24,25,26,27,28,29,30,
|
||||
31,32,33,34,35
|
||||
};
|
||||
|
||||
/* Version information */
|
||||
@ -1403,3 +1411,5 @@ static int Encode(Tcl_Interp *interp, int objc,
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -670,9 +670,6 @@ The ECI value of 0 does not encode any ECI information in the code symbol. In
|
||||
this case, the default encoding applies for the data which is "ISO/IEC 8859-1 -
|
||||
Latin alphabet No. 1".
|
||||
|
||||
The row marked with an asterisk (*) translates GB 2312 codepoints, except when
|
||||
using Han Xin Code, which translates GB 18030 codepoints, a superset of GB 2312.
|
||||
|
||||
Note: the "--eci=3" specification should only be used for special purposes.
|
||||
Using this parameter, the ECI information is explicitly added to the code
|
||||
symbol. Nevertheless, for ECI Code 3, this is not required, as this is the
|
||||
@ -701,12 +698,18 @@ ECI Code | Character Encoding Scheme
|
||||
22 | Windows 1251 - Cyrillic
|
||||
23 | Windows 1252 - Latin 1
|
||||
24 | Windows 1256 - Arabic
|
||||
25 | UCS-2BE (High order byte first) (Unicode BMP)
|
||||
25 | UTF-16BE (High order byte first)
|
||||
26 | UTF-8 (Unicode)
|
||||
27 | ISO/IEC 646:1991 7-bit character set (ASCII)
|
||||
28 | Big5 (Taiwan) Chinese Character Set
|
||||
29 * | GB (PRC) Chinese Character Set
|
||||
29 | GB 2312 (PRC) Chinese Character Set
|
||||
30 | Korean Character Set EUC-KR (KS X 1001:2002)
|
||||
31 | GBK Chinese Character Set
|
||||
32 | GB 18030 Chinese Character Set
|
||||
33 | UTF-16LE (Low order byte first)
|
||||
34 | UTF-32BE (High order bytes first)
|
||||
35 | UTF-32LE (Low order bytes first)
|
||||
170 | ISO/IEC 646:1991 7-bit character set (Invariant)
|
||||
899 | 8-bit binary data
|
||||
------------------------------------------------------------
|
||||
|
||||
@ -1523,11 +1526,12 @@ FAST_MODE | Use faster if less optimal encodation for symbologies that
|
||||
| support it (currently DATAMATRIX only).
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
The default mode is DATA_MODE.
|
||||
The default mode is DATA_MODE. (Note that this differs from the default for the
|
||||
CLI and GUI, which is UNICODE_MODE.)
|
||||
|
||||
DATA_MODE, UNICODE_MODE and GS1_MODE are mutually exclusive, whereas ESCAPE_MODE,
|
||||
GS1PARENS_MODE, GS1NOCHECK_MODE and HEIGHTPERROW_MODE are optional. So, for
|
||||
example, you can set
|
||||
DATA_MODE, UNICODE_MODE and GS1_MODE are mutually exclusive, whereas
|
||||
ESCAPE_MODE, GS1PARENS_MODE, GS1NOCHECK_MODE, HEIGHTPERROW_MODE and FAST_MODE
|
||||
are optional. So, for example, you can set
|
||||
|
||||
my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
|
||||
|
||||
@ -1579,7 +1583,7 @@ returned on success. For instance:
|
||||
|
||||
char name[32];
|
||||
if (ZBarcode_BarcodeName(BARCODE_PDF417, name) == 0) {
|
||||
printf("%s\n", name);
|
||||
printf("%s\n", name);
|
||||
}
|
||||
|
||||
will print "BARCODE_PDF417".
|
||||
@ -3199,7 +3203,7 @@ default value is 250 (25%).
|
||||
================================
|
||||
7.1 License
|
||||
-----------
|
||||
Zint, libzint and Zint Barcode Studio are Copyright © 2021 Robin Stuart. All
|
||||
Zint, libzint and Zint Barcode Studio are Copyright © 2022 Robin Stuart. All
|
||||
historical versions are distributed under the GNU General Public License
|
||||
version 3 or later. Version 2.5 (and later) is released under a dual license:
|
||||
the encoding library is released under the BSD license whereas the GUI, Zint
|
||||
@ -3283,9 +3287,8 @@ international standards:
|
||||
capture techniques - Code 39 bar code symbology specification
|
||||
> ISO/IEC 18004:2015 Information technology - Automatic identification and data
|
||||
capture techniques - QR Code bar code symbology specification
|
||||
> ISO/IEC DIS 20830:2019 (Draft 2019-10-10) Information technology - Automatic
|
||||
identification and data capture techniques - Han Xin Code bar code
|
||||
symbology specification
|
||||
> ISO/IEC 20830:2021 Information technology - Automatic identification and data
|
||||
capture techniques - Han Xin Code bar code symbology specification
|
||||
> ISO/IEC 24723:2010 Information technology - Automatic identification and data
|
||||
capture techniques - GS1 Composite bar code symbology specification
|
||||
> ISO/IEC 24724:2011 Information technology - Automatic identification and data
|
||||
@ -3317,12 +3320,12 @@ international standards:
|
||||
(Released 9th Dec 2008)
|
||||
> AIMD/TSC15032-43 (v 0.99c) - International Technical Specification -
|
||||
Ultracode Symbology (Draft) (Released 4th Nov 2015)
|
||||
> GS1 General Specifications Release 21.0.1 (Jan 2021)
|
||||
> GS1 General Specifications Release 22.0 (Jan 2022)
|
||||
> AIM ITS/04-001 International Technical Standard - Extended Channel
|
||||
Interpretations Part 1: Identification Schemes and Protocol (Released 24th
|
||||
May 2004)
|
||||
> AIM ITS/04-023 International Technical Standard - Extended Channel
|
||||
Interpretations Part 3: Register (Released 15th July 2004)
|
||||
Interpretations Part 3: Register (Version 2, February 2022)
|
||||
|
||||
|
||||
A. Character Encoding
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2008-2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2008-2022 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -18,7 +18,6 @@
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -200,14 +199,19 @@ static void show_eci(void) {
|
||||
" 22: Windows 1251 - Cyrillic\n"
|
||||
" 23: Windows 1252 - Latin 1\n"
|
||||
" 24: Windows 1256 - Arabic\n"
|
||||
" 25: UCS-2BE (High order byte first) (Unicode BMP)\n"
|
||||
" 25: UTF-16BE (High order byte first)\n"
|
||||
" 26: UTF-8 (Unicode)\n"
|
||||
" 27: ISO/IEC 646:1991 7-bit character set (ASCII)\n"
|
||||
" 27: ISO/IEC 646:1991 7-bit ASCII\n"
|
||||
" 28: Big5 (Taiwan) Chinese Character Set\n"
|
||||
" 29: ** GB (PRC) Chinese Character Set\n"
|
||||
" 29: GB 2312 (PRC) Chinese Character Set\n"
|
||||
" 30: Korean Character Set EUC-KR (KS X 1001:2002)\n"
|
||||
" 31: GBK Chinese Character Set\n"
|
||||
" 32: GB 18030 Chinese Character Set\n"
|
||||
" 33: UTF-16LE (Low order byte first)\n"
|
||||
" 34: UTF-32BE (High order bytes first)\n"
|
||||
" 35: UTF-32LE (Low order bytes first)\n"
|
||||
"170: ISO/IEC 646:1991 7-bit Invariant\n"
|
||||
"899: 8-bit binary data\n"
|
||||
"** ECI 29 is GB 2312 except for Han Xin, when it is GB 18030\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -1479,3 +1483,5 @@ int main(int argc, char **argv) {
|
||||
|
||||
return do_exit(error_number);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2020 - 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2020-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
|
||||
@ -27,7 +27,6 @@
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
*/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include "testcommon.h"
|
||||
|
||||
@ -302,15 +301,15 @@ static void test_dump_args(int index, int debug) {
|
||||
/* 30*/ { BARCODE_DATAMATRIX, "(9\\x31)12(92)34", NULL, NULL, NULL, GS1_MODE | ESCAPE_MODE | GS1PARENS_MODE, GS1_GS_SEPARATOR, 0, -1, 0, -1, 0, -1, -1, NULL, -1, -1, 0, -1, "AA A8\nF9 DC\nBF 20\nD6 C4\nED 10\nA0 0C\nA7 C0\n96 5C\nBA 70\nBB A4\nE2 18\nDD 14\n9C 40\nFF FC" },
|
||||
/* 31*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, "12345678+12", -1, -1, 0, -1, "DB BC D3 9C 44 E9 D2 2C 19 E7 A2 D8 A0 00 00 00\nDB 31 1C 9C C7 29 92 47 D9 E9 40 C8 A0 00 00 00\nDA 3B EB 10 AF 09 9A 18 9D 7D 82 E8 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
|
||||
/* 32*/ { BARCODE_EANX_CC, "[91]12", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, 2, "12345678+12", -1, -1, 0, -1, "D3 A3 E9 DB F5 C9 DB 43 D9 CB 98 D2 20 00 00 00\nD3 25 0F 11 E4 49 D3 51 F1 AC FC D6 20 00 00 00\nD1 33 48 19 39 E9 93 18 49 D8 98 D7 20 00 00 00\nD1 A6 FC DA 1C 49 9B C5 05 E2 84 D7 A0 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n20 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00\n10 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00\n14 68 D1 A6 49 BD 55 C9 D4 22 48 B9 40 59 94 98" },
|
||||
/* 33*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 33*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "Warning 543: Converted to Shift JIS but no ECI specified\nFE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 34*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, 26, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 5B F8\n82 72 08\nBA DA E8\nBA 52 E8\nBA 2A E8\n82 0A 08\nFE AB F8\n00 D8 00\nEF F6 20\nB5 C2 28\n36 28 88\nFD 42 10\n62 2A C8\n00 95 70\nFE B7 38\n82 FD D8\nBA 97 00\nBA 43 60\nBA C8 C8\n82 C3 68\nFE EA F8" },
|
||||
/* 35*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 0, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 0A 08\nBA A2 E8\nBA 0A E8\nBA 5A E8\n82 72 08\nFE AB F8\n00 A0 00\nEF AE 20\n75 B5 20\n82 F7 58\nF4 9D C8\n5E 17 28\n00 C2 20\nFE 88 80\n82 82 38\nBA EA A8\nBA 55 50\nBA D7 68\n82 BD D0\nFE B7 78" },
|
||||
/* 36*/ { BARCODE_QRCODE, "\223\137", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 37*/ { BARCODE_QRCODE, "\\x93\\x5F", NULL, NULL, NULL, DATA_MODE | ESCAPE_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, 1, 0, -1, "FE 2B F8\n82 AA 08\nBA B2 E8\nBA 0A E8\nBA FA E8\n82 E2 08\nFE AB F8\n00 80 00\nD3 3B B0\n60 95 68\n7A B3 A0\n1D 0F 98\nAA D7 30\n00 E6 A8\nFE DA D0\n82 42 20\nBA 0E 38\nBA C7 18\nBA 17 68\n82 B9 40\nFE C5 28" },
|
||||
/* 38*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "FE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
|
||||
/* 39*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
|
||||
/* 40*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 AA\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\nAB E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" },
|
||||
/* 41*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 AA\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\nAA 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
|
||||
/* 38*/ { BARCODE_QRCODE, "点", NULL, NULL, NULL, -1, -1, 0, -1, 0, -1, 0, 2, -1, NULL, -1, 1, 0, -1, "Warning 543: Converted to Shift JIS but no ECI specified\nFE 4B F8\n82 92 08\nBA 42 E8\nBA 92 E8\nBA 3A E8\n82 EA 08\nFE AB F8\n00 38 00\nFB CD 50\nA5 89 18\n0B 74 B8\nFC 81 A0\n92 34 B8\n00 DE 48\nFE AB 10\n82 5E 50\nBA C9 20\nBA C9 20\nBA F4 E0\n82 81 A0\nFE B4 E8" },
|
||||
/* 39*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, -1, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
|
||||
/* 40*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 3, -1, NULL, -1, -1, 0, -1, "FE 16 FE\n80 E2 02\nBE C2 FA\nA0 A0 0A\nAE F6 EA\nAE 98 EA\nAE BA EA\n00 E0 00\n15 83 80\n44 7E AE\n92 9C 78\n25 BF 08\n47 4B 8C\n0D F9 74\n03 E7 50\n00 3A 00\nFE C2 EA\n02 22 EA\nFA DA EA\n0A 22 0A\nEA B2 FA\nEA 9A 02\nEA E8 FE" },
|
||||
/* 41*/ { BARCODE_HANXIN, "é", NULL, NULL, NULL, DATA_MODE, -1, 0, -1, 0, -1, 1, 4, -1, NULL, -1, -1, 0, -1, "FE 8A FE\n80 28 02\nBE E8 FA\nA0 94 0A\nAE 3E EA\nAE D2 EA\nAE 74 EA\n00 AA 00\n15 B4 80\n0B 48 74\nA2 4A A4\nB5 56 2C\nA8 5A A8\n9F 18 50\n02 07 50\n00 A6 00\nFE 20 EA\n02 C2 EA\nFA C4 EA\n0A 42 0A\nEA 52 FA\nEA 24 02\nEA AA FE" },
|
||||
};
|
||||
int data_size = ARRAY_SIZE(data);
|
||||
int i;
|
||||
@ -1013,3 +1012,5 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
@ -425,6 +425,9 @@ Remember to place [square brackets] around AI identifiers</string>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>34</number>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set the ECI (Extended Channel Interpretation) code
|
||||
(ignored if disabled)</string>
|
||||
@ -536,7 +539,7 @@ Remember to place [square brackets] around AI identifiers</string>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>25: UCS-2BE</string>
|
||||
<string>25: UTF-16BE</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
@ -564,6 +567,36 @@ Remember to place [square brackets] around AI identifiers</string>
|
||||
<string>30: Korean EUC-KR</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>31: GBK</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>32: GB 18030</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>33: UTF-16LE</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>34: UTF-32BE</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>35: UTF-32LE</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>170: ISO 646 Invariant</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>899: 8-bit binary data</string>
|
||||
|
@ -1,6 +1,6 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
|
||||
* Copyright (C) 2009-2021 by Robin Stuart <rstuart114@gmail.com> *
|
||||
* Copyright (C) 2009-2022 by Robin Stuart <rstuart114@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
@ -13,7 +13,6 @@
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
//#include <QDebug>
|
||||
#include <QGraphicsScene>
|
||||
@ -461,7 +460,7 @@ void MainWindow::about()
|
||||
"<p>A free barcode generator</p>"
|
||||
"<p>Instruction manual is available at the project homepage:<br>"
|
||||
"<a href=\"http://www.zint.org.uk\">http://www.zint.org.uk</a>"
|
||||
"<p>Copyright © 2006-2021 Robin Stuart and others.<br>"
|
||||
"<p>Copyright © 2006-2022 Robin Stuart and others.<br>"
|
||||
"Qt backend by BogDan Vatra</p>"
|
||||
"<p>Qt version %2</p>"
|
||||
"<p>With thanks to Harald Oehlmann, Norbert Szabó, Robert Elliott, Milton Neal, "
|
||||
@ -953,7 +952,6 @@ void MainWindow::change_options()
|
||||
|
||||
chkComposite->setText(tr("Add &2D Component"));
|
||||
combobox_item_enabled(cmbCompType, 3, false); // CC-C
|
||||
cmbECI->setItemText(25, tr("29: GB 2312 (PRC)"));
|
||||
btype->setItemText(0, tr("No border"));
|
||||
combobox_item_enabled(cmbFontSetting, 1, true);
|
||||
m_lblHeightPerRow = nullptr;
|
||||
@ -1294,7 +1292,6 @@ void MainWindow::change_options()
|
||||
file.close();
|
||||
load_sub_settings(settings, symbology);
|
||||
tabMain->insertTab(1, m_optionWidget, tr("Han Xin Cod&e"));
|
||||
cmbECI->setItemText(25, tr("29: GB 18030 (PRC)"));
|
||||
connect(get_widget(QSL("cmbHXSize")), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("cmbHXECC")), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(get_widget(QSL("cmbHXMask")), SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
@ -3415,3 +3412,5 @@ void MainWindow::load_sub_settings(QSettings &settings, int symbology)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et : */
|
||||
|
Loading…
Reference in New Issue
Block a user