ASCII checking and UNICODE conversion
I need some advice for a simple program that I'm doing.
I have to take input from stdin, check for any non-ascii character and replace it with an ascii character (7bit).
I'm using fgetc and pass it an int instead of a char to check if the value is above 127. If that's the case, then proceed with the conversion.
Now, considering that different environment equals different encodings, i.e. è is 130 in ASCII and 232 in ANSI, I thought about converting the single char to UNICODE, then convert again to what it should be in 7bit ASCII, i.e. è would become e. I read about wchar_t, and came up with this (just a short summary of the full code):
Then, just to be sure, I thought about printing z to check its value. I tried these:
while ((i = fgetc(stdin)) != EOF)
if (i > 127)
int convert(char *c);
wchar_t z = *c;
if (z == 0x00E0) //'è' in UNICODE
*c = 'e';
and the above with wprintf(), but nothing displayed on screen.
Do you think there is something wrong with what I'm doing, both in written code or in thought process?