mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Expand ECI support and enforce binary mode when ECI is set
This commit is contained in:
parent
d818d1aecc
commit
451f0150d8
@ -1212,6 +1212,11 @@ int dotcode(struct zint_symbol *symbol, const unsigned char source[], int length
|
|||||||
unsigned char* masked_codeword_array;
|
unsigned char* masked_codeword_array;
|
||||||
unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char));
|
unsigned char* codeword_array = (unsigned char *) _alloca(length * 3 * sizeof (unsigned char));
|
||||||
#endif /* _MSC_VER */
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
|
if (symbol->eci > 811799) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid ECI");
|
||||||
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
data_length = dotcode_encode_message(symbol, source, length, codeword_array, &binary_finish);
|
data_length = dotcode_encode_message(symbol, source, length, codeword_array, &binary_finish);
|
||||||
|
|
||||||
|
@ -1053,6 +1053,11 @@ int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (symbol->output_options & READER_INIT) reader = 1;
|
if (symbol->output_options & READER_INIT) reader = 1;
|
||||||
|
|
||||||
|
if (symbol->eci > 811799) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid ECI");
|
||||||
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, symbol->debug);
|
error_number = gm_encode(gbdata, length, binary, reader, symbol->eci, symbol->debug);
|
||||||
if (error_number != 0) {
|
if (error_number != 0) {
|
||||||
|
@ -485,7 +485,6 @@ static int supports_eci(const int symbology) {
|
|||||||
case BARCODE_DOTCODE:
|
case BARCODE_DOTCODE:
|
||||||
case BARCODE_GRIDMATRIX:
|
case BARCODE_GRIDMATRIX:
|
||||||
case BARCODE_HANXIN:
|
case BARCODE_HANXIN:
|
||||||
case BARCODE_UPNQR:
|
|
||||||
result = 1;
|
result = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -991,6 +990,10 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source,int
|
|||||||
if ((symbol->input_mode < 0) || (symbol->input_mode > 2)) {
|
if ((symbol->input_mode < 0) || (symbol->input_mode > 2)) {
|
||||||
symbol->input_mode = DATA_MODE;
|
symbol->input_mode = DATA_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (symbol->eci != 3) {
|
||||||
|
symbol->input_mode = DATA_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
if (symbol->input_mode == GS1_MODE) {
|
if (symbol->input_mode == GS1_MODE) {
|
||||||
for (i = 0; i < in_length; i++) {
|
for (i = 0; i < in_length; i++) {
|
||||||
|
@ -559,12 +559,10 @@ void numbprocess(int *chainemc, int *mclength, char chaine[], int start, int len
|
|||||||
/* 366 */
|
/* 366 */
|
||||||
static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_t length) {
|
static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_t length) {
|
||||||
int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset;
|
int i, k, j, indexchaine, indexliste, mode, longueur, loop, mccorrection[520], offset;
|
||||||
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35], codeerr;
|
int total, chainemc[2700], mclength, c1, c2, c3, dummy[35];
|
||||||
char pattern[580];
|
char pattern[580];
|
||||||
int debug = symbol->debug;
|
int debug = symbol->debug;
|
||||||
|
|
||||||
codeerr = 0;
|
|
||||||
|
|
||||||
/* 456 */
|
/* 456 */
|
||||||
indexliste = 0;
|
indexliste = 0;
|
||||||
indexchaine = 0;
|
indexchaine = 0;
|
||||||
@ -639,6 +637,11 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (symbol->eci > 811799) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid ECI");
|
||||||
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < indexliste; i++) {
|
for (i = 0; i < indexliste; i++) {
|
||||||
switch (liste[1][i]) {
|
switch (liste[1][i]) {
|
||||||
case TEX: /* 547 - text mode */
|
case TEX: /* 547 - text mode */
|
||||||
@ -821,7 +824,7 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size
|
|||||||
symbol->width =(int)strlen(pattern);
|
symbol->width =(int)strlen(pattern);
|
||||||
|
|
||||||
/* 843 */
|
/* 843 */
|
||||||
return codeerr;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 345 */
|
/* 345 */
|
||||||
@ -863,6 +866,9 @@ int pdf417enc(struct zint_symbol *symbol, unsigned char source[], const size_t l
|
|||||||
strcpy(symbol->errtxt, "Data too long for specified number of columns (D65)");
|
strcpy(symbol->errtxt, "Data too long for specified number of columns (D65)");
|
||||||
error_number = ZINT_ERROR_TOO_LONG;
|
error_number = ZINT_ERROR_TOO_LONG;
|
||||||
break;
|
break;
|
||||||
|
case ZINT_ERROR_INVALID_OPTION:
|
||||||
|
error_number = codeerr;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(symbol->errtxt, "Something strange happened (D66)");
|
strcpy(symbol->errtxt, "Something strange happened (D66)");
|
||||||
error_number = ZINT_ERROR_ENCODING_PROBLEM;
|
error_number = ZINT_ERROR_ENCODING_PROBLEM;
|
||||||
@ -936,6 +942,11 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_
|
|||||||
mclength++;
|
mclength++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (symbol->eci > 811799) {
|
||||||
|
strcpy(symbol->errtxt, "Invalid ECI");
|
||||||
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
if (symbol->eci != 3) {
|
if (symbol->eci != 3) {
|
||||||
/* Encoding ECI assignment number, according to Table 8 */
|
/* Encoding ECI assignment number, according to Table 8 */
|
||||||
if (symbol->eci <= 899) {
|
if (symbol->eci <= 899) {
|
||||||
|
@ -424,9 +424,8 @@ The --binary option prevents Zint from performing any convertion of the data
|
|||||||
before placing in the barcode symbol and should be used if you are encoding raw
|
before placing in the barcode symbol and should be used if you are encoding raw
|
||||||
binary or encrypted data.
|
binary or encrypted data.
|
||||||
|
|
||||||
If your platform does not use Unicode or if you are using data from file which
|
If you are using data from file which is not UTF-8 formatted then you can
|
||||||
is not stored in UTF-8 then you can specify the encoding by using the --binary
|
specify the encoding by using the --eci= switch followed by the appropriate number
|
||||||
switch in combination with the --eci= switch followed by the appropriate number
|
|
||||||
from the table below. This procedure adds an ECI flag in the barcode data which
|
from the table below. This procedure adds an ECI flag in the barcode data which
|
||||||
tells the barcode reader to change character encoding.
|
tells the barcode reader to change character encoding.
|
||||||
|
|
||||||
@ -448,13 +447,25 @@ ECI Code | Character Encoding Scheme
|
|||||||
16 | ISO-8859-14 - Latin alphabet No. 8 (Celtic)
|
16 | ISO-8859-14 - Latin alphabet No. 8 (Celtic)
|
||||||
17 | ISO-8859-15 - Latin alphabet No. 9
|
17 | ISO-8859-15 - Latin alphabet No. 9
|
||||||
18 | ISO-8859-16 - Latin alphabet No. 10
|
18 | ISO-8859-16 - Latin alphabet No. 10
|
||||||
|
20 * | Shift-JIS (JISX 0208 amd JISX 0201)
|
||||||
21 | Windows-1250 - Latin 2 (Central Europe)
|
21 | Windows-1250 - Latin 2 (Central Europe)
|
||||||
22 | Windows-1251 - Cyrillic
|
22 | Windows-1251 - Cyrillic
|
||||||
23 | Windows-1252 - Latin 1
|
23 | Windows-1252 - Latin 1
|
||||||
24 | Windows-1256 - Arabic
|
24 | Windows-1256 - Arabic
|
||||||
|
25 * | UCS-2 Unicode (High order byte first)
|
||||||
26 | Unicode (UTF-8)
|
26 | Unicode (UTF-8)
|
||||||
|
27 | ISO-646:1991 7-bit character set
|
||||||
|
28 * | Big-5 (Taiwan) Chinese Character Set
|
||||||
|
29 * | GB (PRC) Chinese Character Set
|
||||||
|
30 * | Korean Character Set (KSX1001:1998)
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
|
|
||||||
|
* Note: When using the ECI flag Zint will treat all input data as raw binary.
|
||||||
|
This means that data which is encoded using a multiple-byte encoding schemes
|
||||||
|
(other than UTF-8) will not use optimal compression. It is therefore
|
||||||
|
recommended that data using these schemes be converted to UTF-8 using iconv
|
||||||
|
or similar before passing it to Zint.
|
||||||
|
|
||||||
4.11 Batch processing
|
4.11 Batch processing
|
||||||
---------------------
|
---------------------
|
||||||
Data can be batch processed by reading from a text file and producing a
|
Data can be batch processed by reading from a text file and producing a
|
||||||
@ -553,7 +564,7 @@ options available, and also gives the exact version of the software.
|
|||||||
The -t or --types option gives the table of symbologies along with the symbol
|
The -t or --types option gives the table of symbologies along with the symbol
|
||||||
ID numbers.
|
ID numbers.
|
||||||
|
|
||||||
The -e or --ecinos option gives a list of the ECI codes supported by Zint.
|
The -e or --ecinos option gives a list of the ECI codes.
|
||||||
|
|
||||||
4.16 Other output options
|
4.16 Other output options
|
||||||
-------------------------
|
-------------------------
|
||||||
|
@ -134,11 +134,18 @@ void show_eci(void) {
|
|||||||
"16: ISO-8859-14 - Latin alphabet No. 8 (Celtic)\n"
|
"16: ISO-8859-14 - Latin alphabet No. 8 (Celtic)\n"
|
||||||
"17: ISO-8859-15 - Latin alphabet No. 9\n"
|
"17: ISO-8859-15 - Latin alphabet No. 9\n"
|
||||||
"18: ISO-8859-16 - Latin alphabet No. 10\n"
|
"18: ISO-8859-16 - Latin alphabet No. 10\n"
|
||||||
|
"20: ** Shift-JIS (JISX 0208 amd JISX 0201)\n"
|
||||||
"21: Windows-1250\n"
|
"21: Windows-1250\n"
|
||||||
"22: Windows-1251\n"
|
"22: Windows-1251\n"
|
||||||
"23: Windows-1252\n"
|
"23: Windows-1252\n"
|
||||||
"24: Windows-1256\n"
|
"24: Windows-1256\n"
|
||||||
|
"25: ** UCS-2 Unicode (High order byte first)\n"
|
||||||
"26: Unicode (UTF-8)\n"
|
"26: Unicode (UTF-8)\n"
|
||||||
|
"27: ISO-646:1991 7-bit character set\n"
|
||||||
|
"28: ** Big-5 (Taiwan) Chinese Character Set\n"
|
||||||
|
"29: ** GB (PRC) Chinese Character Set\n"
|
||||||
|
"30: ** Korean Character Set (KSX1001:1998)\n"
|
||||||
|
"** See note in section 4.10 of the manual"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,7 +690,7 @@ int main(int argc, char **argv) {
|
|||||||
strncpy(filetype, optarg, (size_t) 3);
|
strncpy(filetype, optarg, (size_t) 3);
|
||||||
}
|
}
|
||||||
if (!strcmp(long_options[option_index].name, "eci")) {
|
if (!strcmp(long_options[option_index].name, "eci")) {
|
||||||
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 30)) {
|
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 999999)) {
|
||||||
my_symbol->eci = atoi(optarg);
|
my_symbol->eci = atoi(optarg);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Invalid ECI code (A18)\n");
|
fprintf(stderr, "Invalid ECI code (A18)\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user