On Wed Nov 23 07:05:07 2022 +0000, Nikolay Sivov wrote:
Looks like it's still doing too much, handling multibyte codepages.
Oh, weird. I wrote a small test program and you're right, on Windows isxdigit can be true for characters above 255:
``` #include <locale.h> #include <stdio.h> #include <ctype.h>
int main() { if (!setlocale(LC_ALL, "chinese")) printf("setlocale failed\n");
if (isxdigit(0x6161)) printf("0x6161 is a hex digit\n"); else printf("0x6161 is NOT a hex digit\n");
return 0; } ```
On Windows, the program prints "0x6161 is a hex digit". However, on Linux, the same program with "chinese" changed to "zh-CN" prints "0x6161 is NOT a hex digit". I checked the C99 standard and it says:
The header <ctype.h> declares several functions useful for classifying and mapping characters.) In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall equal the value of the macro EOF. If the argument has any other value, the behavior is undefined.
So it seems that Windows is well within its rights to do whatever it wants if c > 255.