Preliminary Info:
Codebase = C
Platform = Windows (32 bit)
Okay, let me start by saying that I know why the program crashes with the "(unsigned)(c+1) <= 256" error.
The program is pulling utf8 data text data from sql. When a German Umlaut or another char >0x80 is encountered, it is interpreted as a negative number.
In this particular case, the number being passed is -76.
My question is this then...: What would be the most logical options to avoid this limitation?
The following section of code is from "isctype.c":
1 2 3 4 5 6 7 8 9
#if defined (_DEBUG)
extern"C"int __cdecl _chvalidator(
int c,
int mask
)
{
_ASSERTE((unsigned)(c + 1) <= 256);
return _chvalidator_l(NULL, c, mask);
}
If any further info is needed, please let me know. Thank you.
Simply cast to unsigned char. That will reinterpret the signed value as an 8-bit unsigned, and sign extension will work correctly when casting again to larger types.
For example: