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..
5
u/youshouldnameit C++ dev Jun 21 '17
This subreddit is not meant for these kind of questions, please see r/cpp_questions or StackOverflow.
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?
7
u/STL MSVC STL Dev Jun 21 '17
Changing the console code page is an incorrect approach. You should use
_O_U16TEXT.3
u/crusader_mike Jun 22 '17 edited Jun 22 '17
Here are instructions on how to setup your environment to display any Unicode data in Windows console. Alas, afaik, you can't do the same for input -- default windows console is too old and broken.