Would you like signs with those chars?
Would you like signs with those chars?
Posted Oct 25, 2022 9:14 UTC (Tue) by jengelh (subscriber, #33263)In reply to: Would you like signs with those chars? by NYKevin
Parent article: Would you like signs with those chars?
>if you accidentally have a character with the high bit set (because you're using ISO-8859-1 or Windows-1252 or some other 8-bit ASCII superset instead of* UTF-8), then it will sign extend and you will get nonsense.
int lowertbl[] = {-1, 0, 1, ..., 0x40, 0x61, 0x62, ...};
#define tolower(c) ((lowertbl+1)[c])
Sign extension need not produce nonsense. Thanks to the equivalency of the expressions lowertbl+1[c] <=> lowertbl+1+c <=> lowertbl+c+1 <=> lowertbl[c+1], what matters is if the pointer still points to something sensible.
