Solved

Printing international characters in a console window with cout

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

679 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