API overhaul part 1: removal of nullchar

This commit is contained in:
hooper114 2009-09-29 09:45:46 +00:00
parent 4455c6a893
commit 04b9a99241
42 changed files with 1458 additions and 1194 deletions

View file

@ -88,11 +88,11 @@ void to_upper(unsigned char source[])
}
}
int is_sane(char test_string[], unsigned char source[])
int is_sane(char test_string[], unsigned char source[], int length)
{ /* Verifies that a string only uses valid characters */
unsigned int i, j, latch;
for(i = 0; i < ustrlen(source); i++) {
for(i = 0; i < length; i++) {
latch = FALSE;
for(j = 0; j < strlen(test_string); j++) {
if (source[i] == test_string[j]) { latch = TRUE; } }
@ -279,3 +279,41 @@ float froundup(float input)
return output;
}
int latin1_process(struct zint_symbol *symbol, unsigned char source[], unsigned char preprocessed[], int *length)
{
int j, i, next;
/* Convert Unicode to Latin-1 for those symbologies which only support Latin-1 */
j = 0;
i = 0;
do {
next = -1;
if(source[i] < 128) {
preprocessed[j] = source[i];
j++;
next = i + 1;
} else {
if(source[i] == 0xC2) {
preprocessed[j] = source[i + 1];
j++;
next = i + 2;
}
if(source[i] == 0xC3) {
preprocessed[j] = source[i + 1] + 64;
j++;
next = i + 2;
}
}
if(next == -1) {
strcpy(symbol->errtxt, "error: Invalid character in input string (only Latin-1 characters supported)");
return ERROR_INVALID_DATA;
}
i = next;
} while(i < *length);
preprocessed[j] = '\0';
*length = j;
return 0;
}