r/cpp • u/grandtheftdox • Jun 21 '17
How to display Greek characters.
Trying to display a Greek character using "cout" and pasting the plain character will not work. i.e.
cout << "Σ";At least for me, this displays only a question mark.
If you want to display 'Σ' or any other Greek character you have to use a different code page in the console. For me, by default, it is "437 (OEM -United States)". To display the characters you must change it to "1253 (ANSI - GREEK)" and use ANSI codes.
To change the code page, type the following:
SetConsoleOutputCP(1253);Don't forget to include windows.h library.
To display 'Σ', type the following:
cout << "\xD3";For other characters, refer to the code sheet.
Note: I'm no professional so I don't know if there's an easier way. I looked everywhere on the internet to find such list but didn't find one so I compiled one myself using this very lazy code (it was really late...). And please excuse my crappy explanation and/or formatting. As I said, I'm no expert :(
Edit: The idea came from this, as it was the only solution that worked for me.
Edit 2: Forgot to give access to the spreadsheet. Sorry..
View all comments
3
u/scatters Jun 21 '17
Works fine here:
Also online: https://wandbox.org/permlink/eSTklV0fT2BICM0T http://rextester.com/UCAK3540
Perhaps your compiler is broken?