Print special characters in the Windows console
How to print special characters like ' ES ' and ' ç ' in windows console (printf)?
2 answers
There are three ways to use these special characters in windows:
-
Passing code directly in printf:
printf("isto \x82"); //imprime isto é
(this code above assumes CodePage 850)
Creating a function that uses the above functionality to print the special characters an example is the function oprintf that is available with the LGPL license
Or as Giovani said, using
setlocale
.
Note: I suggest do not use system("PAUSE"); or the library when there is no need. (Are in the setlocale example).
As you can find on the website: http://linguagensdeprogramacao.wordpress.com/2011/07/16/resolvendo-problema-da-acentuacao-no-dev-c/
To solve this problem you just need to use the regionalization of C so that it not only accentuates words correctly, but that shows dates and times in Portuguese, for example.
This is done using the setlocale command from the locale library.h. next an example of code.
#include <stdio.h>
#include <conio.h>
#include <locale.h>
int main(void)
{
setlocale(LC_ALL, "Portuguese");
printf("Alô mundo! \n\n");
system("PAUSE");
return 0;
}
----- Edit --------
If you still have a problem try changing the font of the command: