views:

82

answers:

2

I couldn't display a 'bullet' of character code DEC 149 which can be found on ASCII Chart.

cout << char(149) << endl;

it comes out as ò on console window. I know a few characters from charmap that I'd like to use but how would i know their character codes?

A: 

The problem is that ASCII only defines character codes 0 through 127. If you want to use codes above that, then you need to specify an ANSI code page. The chart you referenced is using the Latin-1 code page and your console is apparently using something else.

You need to set your console code page to Latin-1 for your characters to display as desired. There's no standard C++ way to do this. If you're programming on Windows, you can use the SetConsoleOutputCP() function. The code page id for Latin-1 on Windows is 1252.

Peter Ruderman
Standard C++ doesn't have a way to do this; the standard way would be to use `std::wcout`. Unfortunately that appears a bit broken on VC++
MSalters
A: 

To get the Unicode character codes you can look them up in the Unicode code charts.

decodeunicode.org is nice for interactive browsing.

starblue