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.
Printable View
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.
Trying to do block graphics with ascii characters above 07F? What code page is your console using?
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. :(
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.Quote:
Originally Posted by Vila
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.Quote:
So I played a little and I tried this and it's working?!
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
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... :|
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)