How to deal with special characters in C?

316 Views Asked by At

I'm trying to read (with fgets) and write (with printf) strings with latin special characters (such as ç, á, è, etc).

I've tried to use the setlocale funcion in several different ways, without any positive result. Sometimes the string that I read is written in a good as I want, but in this case, the constant strings (hardcoded in the program) are written with strange characters, and vice-versa.

For example, I've tried these options:

setlocale(LC_CTYPE, "")
setlocale(LC_CTYPE, "Portuguese")
setlocale(LC_CTYPE, "Portuguese_Brazil.1252")

I'm wondering if the encoding of my file code has something to do with this problem.

How can I deadl with this issue?

0

There are 0 best solutions below