Printing and handling files with specific character encoding

96 views Asked by At

I am training file handling in C and I have a problem when I scanf(); a name, such as "Vinícius" which has an accented letter, and fwrite(); it on a file the output is "Vin¡cius" and when i fread(); this file and printf(); on the console the output is also "Vin¡cius". But when I output it as integers the fourth number, that representes the fourth letter "í", is 161 and after searching for the ASCII table I was very confused to see that 161 is in fact the decimal value of "í" but only on the CP437 encoding and my PC apparently uses the Windows-1252 encoding which defines that 161 is the decimal value of "¡". How would I print and use the functions fread(); and fwrite(); in the character encoding my PC understands ?

P.S: I don't know if this has something to do with my IDE but I use CodeBlocks

0

There are 0 answers