Allow explicit ECI 3

Setting ECI to 3 now causes Zint to include ECI 3 in symbol, and allows entry of data formatted in ISO 8859_1
Fixes #127 requested by Harald Oehlmann
This commit is contained in:
Robin Stuart 2019-10-06 17:39:54 +01:00
parent ff2ceea361
commit 15ae99ee11
9 changed files with 1362 additions and 1362 deletions

View File

@ -529,7 +529,7 @@ static int aztec_text_process(const unsigned char source[], const size_t src_len
bin_append(0, 3, binary_string); // FLG(0) bin_append(0, 3, binary_string); // FLG(0)
} }
if (eci != 3) { if (eci != 0) {
bin_append(0, 5, binary_string); // P/S bin_append(0, 5, binary_string); // P/S
bin_append(0, 5, binary_string); // FLG(n) bin_append(0, 5, binary_string); // FLG(n)
if (eci < 10) { if (eci < 10) {

View File

@ -581,7 +581,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
} }
} }
if (symbol->eci > 3) { if (symbol->eci > 0) {
/* Encode ECI numbers according to Table 6 */ /* Encode ECI numbers according to Table 6 */
target[tp] = 241; /* ECI Character */ target[tp] = 241; /* ECI Character */
tp++; tp++;

View File

@ -486,7 +486,7 @@ int dotcode_encode_message(struct zint_symbol *symbol, const unsigned char sourc
} }
} }
if (symbol->eci > 3) { if (symbol->eci > 0) {
codeword_array[array_length] = 108; // FNC2 codeword_array[array_length] = 108; // FNC2
array_length++; array_length++;
if (symbol->eci <= 39) { if (symbol->eci <= 39) {

View File

@ -366,7 +366,7 @@ static int gm_encode(int gbdata[], const size_t length, char binary[],const int
bin_append(10, 4, binary); /* FNC3 - Reader Initialisation */ bin_append(10, 4, binary); /* FNC3 - Reader Initialisation */
} }
if (eci != 3) { if (eci != 0) {
/* ECI assignment according to Table 8 */ /* ECI assignment according to Table 8 */
bin_append(12, 4, binary); /* ECI */ bin_append(12, 4, binary); /* ECI */
if (eci <= 1023) { if (eci <= 1023) {
@ -1021,7 +1021,7 @@ int grid_matrix(struct zint_symbol *symbol, const unsigned char source[], size_t
word[i] = 0; word[i] = 0;
} }
if ((symbol->input_mode == DATA_MODE) || (symbol->eci != 3)) { if ((symbol->input_mode == DATA_MODE) || (symbol->eci != 0)) {
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
gbdata[i] = (int) source[i]; gbdata[i] = (int) source[i];
} }

View File

@ -70,7 +70,7 @@ static int calculate_binlength(char mode[], int source[], const size_t length, i
int est_binlen = 0; int est_binlen = 0;
int submode = 1; int submode = 1;
if (eci != 3) { if (eci != 0) {
est_binlen += 12; est_binlen += 12;
} }
@ -336,7 +336,7 @@ static void calculate_binary(char binary[], char mode[], int source[], const siz
int glyph; int glyph;
int submode; int submode;
if (eci != 3) { if (eci != 0) {
/* Encoding ECI assignment number, according to Table 5 */ /* Encoding ECI assignment number, according to Table 5 */
bin_append(8, 4, binary); // ECI bin_append(8, 4, binary); // ECI
if (eci <= 127) { if (eci <= 127) {
@ -1249,7 +1249,7 @@ int han_xin(struct zint_symbol *symbol, const unsigned char source[], size_t len
unsigned char *grid; unsigned char *grid;
#endif #endif
if ((symbol->input_mode == DATA_MODE) || (symbol->eci != 3)) { if ((symbol->input_mode == DATA_MODE) || (symbol->eci != 0)) {
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
gbdata[i] = (int) source[i]; gbdata[i] = (int) source[i];
} }

View File

@ -71,7 +71,7 @@ struct zint_symbol *ZBarcode_Create() {
symbol->bitmap = NULL; symbol->bitmap = NULL;
symbol->bitmap_width = 0; symbol->bitmap_width = 0;
symbol->bitmap_height = 0; symbol->bitmap_height = 0;
symbol->eci = 3; symbol->eci = 0; // Default 0 uses ECI 3
symbol->dot_size = 4.0 / 5.0; symbol->dot_size = 4.0 / 5.0;
symbol->debug = 0; symbol->debug = 0;
return symbol; return symbol;
@ -1144,12 +1144,12 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
error_buffer = error_number; error_buffer = error_number;
} }
if ((!(supports_eci(symbol->symbology))) && (symbol->eci != 3)) { if ((!(supports_eci(symbol->symbology))) && (symbol->eci != 0)) {
strcpy(symbol->errtxt, "217: Symbology does not support ECI switching"); strcpy(symbol->errtxt, "217: Symbology does not support ECI switching");
error_number = ZINT_ERROR_INVALID_OPTION; error_number = ZINT_ERROR_INVALID_OPTION;
} }
if ((symbol->eci < 3) || (symbol->eci > 999999)) { if ((symbol->eci < 0) || (symbol->eci == 1) || (symbol->eci == 2) || (symbol->eci > 999999)) {
strcpy(symbol->errtxt, "218: Invalid ECI mode"); strcpy(symbol->errtxt, "218: Invalid ECI mode");
error_number = ZINT_ERROR_INVALID_OPTION; error_number = ZINT_ERROR_INVALID_OPTION;
} }
@ -1192,7 +1192,7 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source, int
input_mode = DATA_MODE; input_mode = DATA_MODE;
} }
if ((symbol->eci != 3) && (symbol->eci != 26)) { if ((symbol->eci != 0) && (symbol->eci != 26)) {
input_mode = DATA_MODE; input_mode = DATA_MODE;
} }

View File

@ -454,7 +454,7 @@ int maxi_text_process(int mode, unsigned char source[], int length, int eci) {
/* Insert ECI at the beginning of message if needed */ /* Insert ECI at the beginning of message if needed */
/* Encode ECI assignment numbers according to table 3 */ /* Encode ECI assignment numbers according to table 3 */
if (eci != 3) { if (eci != 0) {
maxi_bump(set, character, 0); maxi_bump(set, character, 0);
character[0] = 27; // ECI character[0] = 27; // ECI
if (eci <= 31) { if (eci <= 31) {

View File

@ -606,7 +606,7 @@ static int pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size
mclength++; mclength++;
} }
if (symbol->eci != 3) { if (symbol->eci != 0) {
/* Encoding ECI assignment number, according to Table 8 */ /* Encoding ECI assignment number, according to Table 8 */
if (symbol->eci <= 899) { if (symbol->eci <= 899) {
chainemc[mclength] = 927; /* ECI */ chainemc[mclength] = 927; /* ECI */
@ -956,7 +956,7 @@ int micro_pdf417(struct zint_symbol *symbol, unsigned char chaine[], const size_
return ZINT_ERROR_INVALID_OPTION; return ZINT_ERROR_INVALID_OPTION;
} }
if (symbol->eci != 3) { if (symbol->eci != 0) {
/* Encoding ECI assignment number, according to Table 8 */ /* Encoding ECI assignment number, according to Table 8 */
if (symbol->eci <= 899) { if (symbol->eci <= 899) {
chainemc[mclength] = 927; /* ECI */ chainemc[mclength] = 927; /* ECI */

View File

@ -166,7 +166,7 @@ static void qr_binary(int datastream[], const int version, const int target_binl
strcat(binary, "0101"); /* FNC1 */ strcat(binary, "0101"); /* FNC1 */
} }
if (eci != 3) { if (eci != 0) {
strcat(binary, "0111"); /* ECI (Table 4) */ strcat(binary, "0111"); /* ECI (Table 4) */
if (eci <= 127) { if (eci <= 127) {
bin_append(eci, 8, binary); /* 000000 to 000127 */ bin_append(eci, 8, binary); /* 000000 to 000127 */
@ -1338,7 +1338,7 @@ static int getBinaryLength(const int version,char inputMode[],const int inputDat
count += 4; count += 4;
} }
if (eci != 3) { if (eci != 0) {
count += 12; count += 12;
} }
@ -1425,7 +1425,7 @@ int qr_code(struct zint_symbol *symbol, const unsigned char source[], size_t len
gs1 = (symbol->input_mode == GS1_MODE); gs1 = (symbol->input_mode == GS1_MODE);
if ((symbol->input_mode == DATA_MODE) || (symbol->eci != 3)) { if ((symbol->input_mode == DATA_MODE) || (symbol->eci != 0)) {
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
jisdata[i] = (int) source[i]; jisdata[i] = (int) source[i];
} }