I wanted to print individual bytes of word "česnek" expecting to printf 7 bytes, because "č" is coded in 2 bytes, which it does but prints garbage character such as a question mark in terminal. If I print out the integer value, I get this sequence.
-60 -115 101 115 110 101 107
Why are the first two numbers negative? Here is the code I used to try it.
char *utfstring = "česnek";
for(size_t i = 0; i < strlen(utfstring); i++) {
printf("%c ", utfstring[i]);
}
for(size_t i = 0; i < strlen(utfstring); i++) {
printf("%d ", utfstring[i]);
}
I expected first two values to be c4 8d because č is encoded like that according to https://www.utf8-chartable.de/unicode-utf8-table.pl?start=256&unicodeinhtml=dec