Printing international characters in a console window with cout
Posted on 2004-04-28
I’m using Visual Studio 6.0 and XP. The layout of the keyboard is Azerty (Belgian-Dutch). The problem is this:
cout << "My name is Hélène\n";
// output: My name is HÚlÞne
When I write this program, I get the wrong output on my console window, as you can see. Is it possible to use cout and get the correct output? It’s important, because here in Belgium we use a lot of accents.
This question is asked on a Dutch speaking forum but nobody seems to know an answer. The strange thing is that it works as expected with a compiler like gcc (Linux).
It’s possible to print all the ascii-characters with a program like this:
// Print extended ascii codes and characters
using namespace std;
for (int i = 128; i < 255; i++) printf("ASCII character #%i = %c\n", i, i);
But this is a way to work around the problem, it doesn’t solve it. Of course, we have examined MSDN but with no success so far. There are only 2 fonts available in the console (Lucida Console and Mono), and both show the wrong characters.
So, how can we use cout and cin, and get the correct characters in a console window?