How to output UNICODE in c++?

I want to output chess symbols ( from unicode to console in c++, please tell me how to do that.
Im using Dev c++, windows8 and console.
Im just a beginner so please keep it simple for me (also tell me the libraries to include please)
On Linux you could just have outputted them in utf8 format std::cout << "♔";
Windows doesn't use utf8 so I think your best bet is to use wide characters.

Maybe this works:
std::wcout = L"♔";

EDIT: I don't think Dev C++ has wcout so I really don't know. Hopefully someone else that knows better can come by and help you.
Last edited on
Yes, Dev c++ does not have wcout.
And when i try to paste ♔ in the code, it pastes a question mark --> ? instead of the symbol.
Every C++ compiler has std::wcout (in <iostream>)

If *pasting* the symbol into the code produces a question mark, your code editor (not the compiler) is probably unable to handle it. How about std::wcout << L'\u2654';?

On windows, before you do it, you may have to say these magic words:

_setmode(_fileno(stdout), _O_WTEXT);

and make sure your console font supports these characters.

On linux, you'd have to set locale:

In Dev C++, using wcout and _setmode(_fileno(stdout), _O_WTEXT); only produces errors saying: "`wcout' undeclared (first use this function) and `_O_WTEXT' undeclared (first use this function)
Topic archived. No new replies allowed.