mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
extended ASCII bug fix
This commit is contained in:
parent
89f02b7dd5
commit
00aeeea0b1
@ -134,17 +134,26 @@ void dxsmooth(int *indexliste)
|
||||
|
||||
}
|
||||
|
||||
|
||||
void c128_set_a(unsigned char source, char dest[], int values[], int *bar_chars)
|
||||
{ /* Translate Code 128 Set A characters into barcodes */
|
||||
/* This set handles all control characters NULL to US */
|
||||
|
||||
if(source > 127) {
|
||||
concat(dest, C128Table[source + 64 - 128]);
|
||||
values[(*bar_chars)] = source + 64 - 128;
|
||||
if(source < 160) {
|
||||
concat(dest, C128Table[(source - 128) + 64]);
|
||||
values[(*bar_chars)] = (source - 128) + 64;
|
||||
} else {
|
||||
concat(dest, C128Table[(source - 128) - 32]);
|
||||
values[(*bar_chars)] = (source - 128) - 32;
|
||||
}
|
||||
} else {
|
||||
if(source < 32) {
|
||||
concat(dest, C128Table[source + 64]);
|
||||
values[(*bar_chars)] = source + 64;
|
||||
} else {
|
||||
concat(dest, C128Table[source - 32]);
|
||||
values[(*bar_chars)] = source - 32;
|
||||
}
|
||||
}
|
||||
(*bar_chars)++;
|
||||
}
|
||||
@ -184,6 +193,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
|
||||
errornum = 0;
|
||||
strcpy(dest, "");
|
||||
|
||||
sourcelen = strlen(source);
|
||||
|
||||
j = 0;
|
||||
@ -237,23 +247,32 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
|
||||
/* Detect extended ASCII characters */
|
||||
for(i = 0; i < sourcelen; i++) {
|
||||
if(source[i] >=128) {
|
||||
if(source[i] >= 128) {
|
||||
fset[i] = 'f';
|
||||
} else {
|
||||
fset[i] = ' ';
|
||||
}
|
||||
}
|
||||
fset[i] = '\0';
|
||||
|
||||
/* Decide when to latch to extended mode - Annex E note 3 */
|
||||
for(i = 0; i < sourcelen; i++) {
|
||||
j = 0;
|
||||
for(i = 0; i < sourcelen; i++) {
|
||||
if(fset[i] == 'f') {
|
||||
do {
|
||||
j++;
|
||||
} while(source[i + j] == 'f');
|
||||
if((j >= 5) || ((j >= 3) && ((i + j) == sourcelen))) {
|
||||
for(k = 0; k <= j; k++) {
|
||||
source[i + k] = 'F';
|
||||
} else {
|
||||
j = 0;
|
||||
}
|
||||
|
||||
if(j >= 5) {
|
||||
for(k = i; k > (i - 5); k--) {
|
||||
fset[k] = 'F';
|
||||
}
|
||||
}
|
||||
|
||||
if((j >= 3) && (i == (sourcelen - 1))) {
|
||||
for(k = i; k > (i - 3); k--) {
|
||||
fset[k] = 'F';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,6 +404,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
return ERROR_TOO_LONG;
|
||||
}
|
||||
|
||||
|
||||
/* So now we know what start character to use - we can get on with it! */
|
||||
switch(set[0])
|
||||
{
|
||||
@ -489,13 +509,15 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
}
|
||||
}
|
||||
|
||||
if(fset[i] == 'f') {
|
||||
if(fset[read] == 'f') {
|
||||
/* Shift extended mode */
|
||||
switch(set[i]) {
|
||||
switch(set[read]) {
|
||||
case 'a':
|
||||
case 'A':
|
||||
concat(dest, C128Table[101]);
|
||||
values[bar_characters] = 101;
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
concat(dest, C128Table[100]);
|
||||
values[bar_characters] = 100;
|
||||
@ -504,7 +526,7 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
bar_characters++;
|
||||
}
|
||||
|
||||
if((set[i] == 'a') || (set[i] == 'b')) {
|
||||
if((set[read] == 'a') || (set[read] == 'b')) {
|
||||
/* Insert shift character */
|
||||
concat(dest, C128Table[98]);
|
||||
values[bar_characters] = 98;
|
||||
@ -526,12 +548,6 @@ int code_128(struct zint_symbol *symbol, unsigned char source[])
|
||||
break;
|
||||
}
|
||||
|
||||
/* printf("vals: ");
|
||||
for(i = 0; i < bar_characters; i++) {
|
||||
printf("%d, ", values[i]);
|
||||
}
|
||||
printf("\n"); */
|
||||
|
||||
} while (read < sourcelen);
|
||||
|
||||
/* check digit calculation */
|
||||
|
@ -107,9 +107,17 @@ void reysmooth(int *indexliste)
|
||||
void c16k_set_a(unsigned char source, int values[], int *bar_chars)
|
||||
{
|
||||
if(source > 127) {
|
||||
if(source < 160) {
|
||||
values[(*bar_chars)] = source + 64 - 128;
|
||||
} else {
|
||||
values[(*bar_chars)] = source - 32 - 128;
|
||||
}
|
||||
} else {
|
||||
if(source < 32) {
|
||||
values[(*bar_chars)] = source + 64;
|
||||
} else {
|
||||
values[(*bar_chars)] = source - 32;
|
||||
}
|
||||
}
|
||||
(*bar_chars)++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user