A question about my C++ program and MSWindows :)

J

jalkadir

As I wrote the subject of this message, I got a cold feeling about this
question, I have realized that this is not only a programmer question,
but it is also a question about one the most detestable operation
systems in the market, but I will post it anyway, hoping that I will
not get fertilized by the any one here.

So, my question about a program that will display some text on the
console, not a big deal, the only thing is that the text displayed will
have some character that are not ASCCI; like the letter 'o' with two
dots on it or the letter 'ñ', (ALT-160/161/162, ETC). I don't have
much experience programming in MSW, thus I don't know how to handle
this problem.
Any help will be most appreciated.

TIA
 
Z

zikaizhang

jalkadir said:
...
So, my question about a program that will display some text on the
console, not a big deal, the only thing is that the text displayed will
have some character that are not ASCCI; like the letter 'o' with two
dots on it or the letter 'ñ', (ALT-160/161/162, ETC). I don't have
much experience programming in MSW, thus I don't know how to handle
this problem.

Try this.

#include <stdio.h>
#include <stdlib.h>
int main()
{
system("chcp 437 > nul");
printf("%c %c %c \n", 160, 161, 162);
return 0;
}
 
J

John Ratliff

jalkadir said:
As I wrote the subject of this message, I got a cold feeling about this
question, I have realized that this is not only a programmer question,
but it is also a question about one the most detestable operation
systems in the market, but I will post it anyway, hoping that I will
not get fertilized by the any one here.

So, my question about a program that will display some text on the
console, not a big deal, the only thing is that the text displayed will
have some character that are not ASCCI; like the letter 'o' with two
dots on it or the letter 'ñ', (ALT-160/161/162, ETC). I don't have
much experience programming in MSW, thus I don't know how to handle
this problem.
Any help will be most appreciated.

TIA

You might be able to print wide unicode characters if you had a wide
stream for the cout. I don't know if it can handle this.

#include <iostream>

wchar_t ch = 0xC4;
std::cout << ch;

Doesn't print A umlaut on msys under Windows, and other than that, I
don't know of any way of printing to console.

There is no 'terminal' in standard C++. This is an OS specific issue,
and better addressed in an OS specific newsgroup.

--John Ratliff
 
G

Greg

jalkadir said:
As I wrote the subject of this message, I got a cold feeling about this
question, I have realized that this is not only a programmer question,
but it is also a question about one the most detestable operation
systems in the market, but I will post it anyway, hoping that I will
not get fertilized by the any one here.

So, my question about a program that will display some text on the
console, not a big deal, the only thing is that the text displayed will
have some character that are not ASCCI; like the letter 'o' with two
dots on it or the letter 'ñ', (ALT-160/161/162, ETC). I don't have
much experience programming in MSW, thus I don't know how to handle
this problem.
Any help will be most appreciated.

TIA

I think replacing the gratuitous editorializing with an actual question
would have made a better use of those bytes. Yes, the C++ program can
send non-ASCII characters to the "terminal" (or more precisely, to
std::cout which is usually directed to a tty device). The character set
for these extended characters would by default be the Windows character
set which is practically identical to ISO-8859-1 -- a character set
which in turn is incorporated into Unicode. But why would the program
need to care? It outputs to std::cout and what anyone does with that
output is their business.

Greg
 
A

Alf P. Steinbach

* jalkadir:
So, my question about a program that will display some text on the
console, not a big deal, the only thing is that the text displayed will
have some character that are not ASCCI; like the letter 'o' with two
dots on it or the letter '=F1', (ALT-160/161/162, ETC). I don't have
much experience programming in MSW, thus I don't know how to handle
this problem.

Not strictly on-topic, but since it's a potential showstopper for newbies,
<url: http://home.no.net/dubjai/win32cpptut/html/w32cpptut_01_02_06.html>.
 
J

jalkadir

That is not the case in my Win console, when the character 'ñ' is sent
to the tty it is not displayed as a 'ñ' (alt-164) but as another
(non-letter) character. That is because, as far as I was explained; the
console in WinXP cannot handle other chars than ASCCI. However, this is
not true, because if I type ALT-164 directly to the console the letter
'ñ' is displayed.
If the win-console *does do its job as expected, when manually
inputting the data, as I explained above, then the problem exists
between the C++ code that is outputting data to the tty and the tty
itself, excuse the redundancy.

Well, thanks anyways, as I said in the original message; "Any help is
appreciated".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top