chars not shown properly

i tried:

char a='ß';
cout << a;

but there is shown another charcter... (a small white rectangle)
then i tried:

char a='ß';
int x=(int)a;
cout << (char)x;

and there is still the other char shown!!! thankful for every reply
Last edited on
Try char a = 225;. It works here.

For more info: http://www.asciitable.com/
character codes above 127 (pretty much anything past '~') depend on your language settings, console code page, and even your console font.

Displaying anything other than basic ASCII (read: this includes "extended" ASCII) to the console is actually pretty difficult/impossible to do reliably with the standard lib. You'll often need to fall back to platform specific code.

Are you running Windows?
thanks... yes, i'm using windows 7 (32bit). is there any library i can include to use the extended ascii or ansi or maybe even unicode or utf-8??
ps: i cannot use it like "char a=255;" because i read the chars from a file, so i have no clue what char i'm reading... i have to get it's position in the ascii table afterwards... i just shortened my previous example
Last edited on
NCurses / PDCurses are commonly used for console programs and are cross platform.

Personally I avoid the console like the plague so I haven't actually used them myself. But they should support Unicode output.
Topic archived. No new replies allowed.