Error on isdigit, isalpha, isspace with char > 127
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
The is*** functions to check if a char is a digit or space fail if you pass a char that's above 127.
https://en.cppreference.com/w/cpp/string/byte/isalpha
Depending on your compiler you might get an error. You can fix this by casting the value to `unsigned char`.
Try and match this "Çüéâ" as ASCII.
```c++
static int matchdigit(char c)
{
return isdigit((unsigned char)c);
}
static int matchalpha(char c)
{
return isalpha((unsigned char)c);
}
static int matchwhitespace(char c)
{
return isspace((unsigned char)c);
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Search the C sources for the isdigit, isalpha, and isspace call sites and compare their character handling with the linked cppreference guidance. Reproduce the issue using the sample "Çüéâ" and confirm that all three checks handle characters above 127 without an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100