Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 545
  • Last Modified:

Printing international characters in a console window with cout

Hello,

I’m using Visual Studio 6.0 and XP. The layout of the keyboard is Azerty (Belgian-Dutch). The problem is this:

#include "stdafx.h"
#include <iostream.h>
void main()
{
    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;
#include <stdafx.h>
#include <stdio.h>

void main()
{
    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.

So, how can we use cout and cin, and get the correct characters in a console window?

Thx

0
pongping
Asked:
pongping
  • 2
1 Solution
 
George TokasCommented:
Hello there.
First of all here is Borland's C++ Builder area..:-)
Anyway the problem you describe is located at the fonts used on terminal window.
Check out how you can change the font used at the terminal window on the startup of your application to display the right characters and restore it when terminating.

Regards,
gtokas.
0
 
pongpingAuthor Commented:
I'm sorry, gtokas. Its my first time here, and I didn't realise that I was in the Borland section. Can this be moved to the right place, or must I ask my question again?

Thanks for your answer, but I don’t know how to change the font of the terminal window.
0
 
George TokasCommented:
No Problem..:-)
Post a redirection to this page in C++ area with 0 points or ask a moderator to do this for you...:-)
Sorry I did't helped you much but first of all I'm using BCB and second never tried such a task in windows. I mean the console window...

gtokas.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now