To output Unicode characters, you simply use the output streams, just like you should output ASCII characters. You can save the Unicode code as a multi-character string:
std::string str = "\u265E"; std::cout << str << std::endl;
It may also be convenient to use widescreen output if you want to output a single Unicode character with a code number above the ASCII range:
setlocale(LC_ALL, "en_US.UTF-8"); wchar_t codepoint = 0x265E; std::wcout << codepoint << std::endl;
However, as others have noted, whether this is displayed correctly depends on many factors in the user environment, for example, whether the user terminal supports Unicode display, regardless of whether the user has the correct fonts installed, etc. This should not be a problem for most common distributions such as Ubuntu / Debian with Gnome installed, but do not expect it to work everywhere.
Charles Salvia
source share