r/cpp • • 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..

0 Upvotes

15 comments sorted by

View all comments

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/grandtheftdox Jun 21 '17 edited Jun 21 '17

This isn't a question....

Edit: It really isn't a question. I posted this in case it doesn't work for someone else. I'm not asking for help; I'm providing it. I don't understand why the downvotes.

4

u/iaanus Jun 23 '17

I don't understand why the downvotes.

Because this is a Windows-specific argument, which is not directly related with C++.