Solved

Printing international characters in a console window with cout

Posted on 2004-04-28
3
529 Views
Last Modified: 2013-12-03
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
Comment
Question by:pongping
  • 2
3 Comments
 
LVL 16

Expert Comment

by:George Tokas
ID: 10939087
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
 

Author Comment

by:pongping
ID: 10939435
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
 
LVL 16

Accepted Solution

by:
George Tokas earned 125 total points
ID: 10939620
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now