Add ECI encoding

This commit is contained in:
Robin Stuart 2016-08-16 12:43:41 +01:00
parent fc657d5fe8
commit 9d1c20201d
17 changed files with 994 additions and 317 deletions

View file

@ -71,9 +71,10 @@ void types(void) {
/* Output usage information */
void usage(void) {
printf( "Zint version %s\n"
"Encode input data in a barcode and save as a PNG, EPS or SVG file.\n\n"
"Encode input data in a barcode and save as a PNG, BMP, GIF, PCX, EPS or SVG file.\n\n"
" -h, --help Display this message.\n"
" -t, --types Display table of barcode types\n"
" -e, --ecinos Display table of ECI character encodings\n"
" -i, --input=FILE Read data from FILE.\n"
" -o, --output=FILE Write image to FILE. (default is out.png)\n"
" -d, --data=DATA Barcode content.\n"
@ -110,9 +111,35 @@ void usage(void) {
" --mirror Use batch data to determine filename (PNG output)\n"
" --mirroreps Use batch data to determine filename (EPS output)\n"
" --mirrorsvg Use batch data to determine filename (SVG output)\n"
" --eci=NUMBER Set the ECI mode for raw data\n"
, ZINT_VERSION);
}
/* Display supported ECI codes */
void show_eci(void) {
printf( " 3: ISO-8859-1 - Latin alphabet No. 1 (default)\n"
" 4: ISO-8859-2 - Latin alphabet No. 2\n"
" 5: ISO-8859-3 - Latin alphabet No. 3\n"
" 6: ISO-8859-4 - Latin alphabet No. 4\n"
" 7: ISO-8859-5 - Latin/Cyrillic alphabet\n"
" 8: ISO-8859-6 - Latin/Arabic alphabet\n"
" 9: ISO-8859-7 - Latin/Greek alphabet\n"
"10: ISO-8859-8 - Latin/Hebrew alphabet\n"
"11: ISO-8859-9 - Latin alphabet No. 5\n"
"12: ISO-8859-10 - Latin alphabet No. 6\n"
"13: ISO-8859-11 - Latin/Thai alphabet\n"
"15: ISO-8859-13 - Latin alphabet No. 7\n"
"16: ISO-8859-14 - Latin alphabet No. 8 (Celtic)\n"
"17: ISO-8859-15 - Latin alphabet No. 9\n"
"18: ISO-8859-16 - Latin alphabet No. 10\n"
"21: Windows-1250\n"
"22: Windows-1251\n"
"23: Windows-1252\n"
"24: Windows-1256\n"
"26: Unicode (UTF-8)\n"
);
}
/* Verifies that a string only uses valid characters */
int validator(char test_string[], char source[]) {
unsigned int i, j, latch;
@ -438,6 +465,7 @@ int main(int argc, char **argv) {
static struct option long_options[] = {
{"help", 0, 0, 'h'},
{"types", 0, 0, 't'},
{"ecinos", 0, 0, 'e'},
{"bind", 0, 0, 0},
{"box", 0, 0, 0},
{"directeps", 0, 0, 0},
@ -477,9 +505,10 @@ int main(int argc, char **argv) {
{"mirroreps", 0, 0, 0},
{"mirrorsvg", 0, 0, 0},
{"dotty", 0, 0, 0},
{"eci", 1, 0, 'e'},
{0, 0, 0, 0}
};
c = getopt_long(argc, argv, "htb:w:d:o:i:rcmp", long_options, &option_index);
c = getopt_long(argc, argv, "htb:w:d:o:i:rcmpe", long_options, &option_index);
if (c == -1) break;
switch (c) {
@ -660,6 +689,14 @@ int main(int argc, char **argv) {
/* Use filenames which reflect content, output to SVG */
filename_reflects_data = 3;
}
if (!strcmp(long_options[option_index].name, "eci")) {
if ((atoi(optarg) >= 0) && (atoi(optarg) <= 30)) {
my_symbol->eci = atoi(optarg);
} else {
fprintf(stderr, "Invalid ECI code\n");
fflush(stderr);
}
}
break;
case 'h':
@ -669,6 +706,10 @@ int main(int argc, char **argv) {
case 't':
types();
break;
case 'e':
show_eci();
break;
case 'b':
error_number = validator(NESET, optarg);