I'm reading user input with fgets() and I'm checking if there are some non allowed symbols.
If user types "š" for example, I will notice it, because value of "š" is higher then 127. But when user types "ασδφ" or "жщдф", my code won't work, because these symbols are completely ignored and replaced by "?".
My code:
char input[100];
fgets(input, 100, stdin);
for (int i = 0; i < strlen(input) - 1; i++)
{
/// Check, if input[i] is ASCII symbol
}
When user types "š", in variable input will be "š". But when user types "щ", int variable input will be "?" and question mark is valid ASCII character.
How to fix it?
EDIT:
Operating system: Windows 10
IDE: Visual Studio 2015
Code:
for (size_t i = 0; i < strlen(input); i++)
{
printf("%c %d\n", input[i], input[i]);
if (input[i] < 0/* || input[i] > 127*/)
{
error = 4;
break;
}
}
If I pause a program, content of array input for user input "ασδφ" is 63, 63, 63, 63, 10.
EDIT 2:
Now I'm totaly confused. I tried compiling and running on Ubuntu, everything worked fine. But on Windows it is still replacing non ASII symbols with questions marks. Any idea how to get it work on Windows?