-
July 1st, 2007, 01:10 PM
#1
cout Extended ASCII characters ain't working
I can't make program print what I want!
I type this script:
int main()
{
cout << "█▓▒░\n";
return 0;
}
and all I get on console is:
????
How to make program print Extended ASCII characters?
Please help.
-
July 1st, 2007, 05:25 PM
#2
Re: cout Extended ASCII characters ain't working
Trying to do block graphics with ascii characters above 07F? What code page is your console using?
-
July 2nd, 2007, 10:20 AM
#3
Re: cout Extended ASCII characters ain't working
Yes. But what do you mean by code page (Can you describe what is code page?)?
I fought the problem was with preprocessor definitions.
It was: WIN32;_DEBUG;_CONSOLE
so I added: _UNICODE (_UNICODE;WIN32;_DEBUG;_CONSOLE)
and it still weren't working.
So I played a little and I tried this and it's working?!
int main()
{
char ch = 178;
int i = 0;
for ( ; i < 3; ch--, i++)
{
cout << ch << endl;
}
return 0;
}
or similar:
int main()
{
char ch = 178;
cout << ch << " \n";
ch--;
cout << ch << " \n";
ch--;
cout << ch << " \n";
return 0;
}
Console result:
▓▒░
So now I am totally confused.
-
July 2nd, 2007, 10:32 AM
#4
Re: cout Extended ASCII characters ain't working
Originally Posted by Vila
Yes. But what do you mean by code page (Can you describe what is code page?)?
Do a google search for "code page". It is one of the fundamental things you should be aware of when printing characters that are above ASCII 127. The code page determines what the characters will be between ASCII 128 and ASCII 255.
So I played a little and I tried this and it's working?!
So in the current code page, character 178 is one of the block characters you wanted. For another code page, character 178 could be (and probably is) some other character.
Also, you could have just ran your original program in the debugger, and inspect what the values are of those block characters that you wrote in your program. When you do this, what were the values of those characters?
Another thing -- don't say "script" when you mean "program". Saying that you wrote a "script" sounds like a total newbie with no comprehension as to what C++ really is.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; July 2nd, 2007 at 10:35 AM.
-
July 2nd, 2007, 12:10 PM
#5
Re: cout Extended ASCII characters ain't working
Thanks.
That characters were 176,177,178,219 (it isn't 'some other character').
And I use wrong code page (1252).
So will you tell me how to change code page.
And, just for the record, I know to write 'program' (and by that I mean that I know, well not everything, but enough to write a decent 'program' in C++) in C++, just I newer spoke to anyone about C++, on any forum, so I don't know witch 'terms' are used.
And I haft to say that I never worked with ASCII characters 128-255 in C++ (and in any other program) so don't be mad at me for not knowing 'one of fundamental things'.
Thank you again... :|
Last edited by Vila; July 2nd, 2007 at 12:29 PM.
-
July 2nd, 2007, 01:43 PM
#6
Re: cout Extended ASCII characters ain't working
Changing the code table for a console window is done by the command GRAFTABL xxx where xxx is code page to use. From code you use SetConsoleCP(UINT wCodePageID)
Last edited by S_M_A; July 2nd, 2007 at 01:44 PM.
Reason: Language
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|