mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Non-latin1 interpretation characters crash png output.
https://sourceforge.net/p/zint/tickets/11/
This commit is contained in:
parent
a31e562fd4
commit
2a1d6b8e48
@ -690,6 +690,7 @@ int maxi_png_plot(struct zint_symbol *symbol, int rotate_angle, int data_type)
|
||||
return error_number;
|
||||
}
|
||||
|
||||
/* Convert UTF-8 to Latin1 Codepage for the interpretation line */
|
||||
void to_latin1(unsigned char source[], unsigned char preprocessed[])
|
||||
{
|
||||
int j, i, input_length;
|
||||
@ -699,22 +700,30 @@ void to_latin1(unsigned char source[], unsigned char preprocessed[])
|
||||
j = 0;
|
||||
i = 0;
|
||||
while (i < input_length) {
|
||||
switch (source[i]) {
|
||||
case 0xC2:
|
||||
/* UTF-8 C2xxh */
|
||||
/* Character range: C280h (latin: 80h) to C2BFh (latin: BFh) */
|
||||
i++;
|
||||
preprocessed[j] = source[i];
|
||||
j++;
|
||||
break;
|
||||
case 0xC3:
|
||||
/* UTF-8 C3xx */
|
||||
/* Character range: C380h (latin: C0h) to C3BFh (latin: FFh) */
|
||||
i++;
|
||||
preprocessed[j] = source[i] + 64;
|
||||
j++;
|
||||
break;
|
||||
default:
|
||||
/* Process ASCII (< 80h), all other unicode points are ignored */
|
||||
if(source[i] < 128) {
|
||||
preprocessed[j] = source[i];
|
||||
j++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
if(source[i] == 0xC2) {
|
||||
preprocessed[j] = source[i + 1];
|
||||
j++;
|
||||
i += 2;
|
||||
}
|
||||
if(source[i] == 0xC3) {
|
||||
preprocessed[j] = source[i + 1] + 64;
|
||||
j++;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
preprocessed[j] = '\0';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user