czerny
czerny

Reputation: 16682

How to print 4 byte Unicode character in Windows C++ console app?

How to print "👩" emoji (Unicode code 1F469) in Windows console app using C++?

In example below I followed Printing UTF-8 Text to the Windows Console.

#include <iostream>
#include <io.h>
#include <fcntl.h>

int main()
{
    _setmode(_fileno(stdout), _O_U16TEXT);
    std::wcout << L"face: 👩\n";
    return 0;
}

However it only prints two questionmarks:

console screenshot - two questionmarks.

"Command Prompt" (cmd.exe) app can't render this char so I'm using Windows Terminal that can render it:

rendered face emoji in Windows Terminal

Upvotes: 0

Views: 761

Answers (1)

M.M
M.M

Reputation: 141648

The Windows Console cannot display characters outside of Plane 0. The Windows Terminal was designed to improve on the limitations of the Windows Console.

Further reading: How to use unicode characters in Windows command line?

Upvotes: 1

Related Questions