I am parsing a file that involves characters such as æ ø å. If we assume I have stored a line of the text file as follows
#define MAXLINESIZE 1024
char* buffer = malloc(MAXLINESIZE)
...
fgets(buffer,MAXLINESIZE,handle)
...
if I wanted to count the number of characters on a line. If I try to do the following:
char* p = buffer
int count = 0;
while (*p != '\n') {
if (isgraph(*p)) {
count++;
}
p++;
}
this ignores the any occurrence of æ ø å
ie: counting "aåeæioøu" would return 5 not 8
do I need to read the file in an alternative way? should I not be using a char*
but an int*
?