Solved

Printing international characters in a console window with cout

Posted on 2004-04-28
3
526 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
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.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

707 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

18 Experts available now in Live!

Get 1:1 Help Now