sandthorn
sandthorn

Reputation: 2870

Can Windows' std::wcout display UTF-16 wchar_t surrogate pairs as a unicode character?

[LIVE]

\U0001F34C\U0002008A on cout  : 🍌𠂊
\U0001F34C\U0002008A on wcout : 
                      wcsnlen : 4
1 :     0xd83c
2 :     0xdf4c
3 :     0xd840
4 :     0xdc8a
    wcsrtombs to char on cout : 🍌𠂊

Even though UCRT makes MSVC more compliant with the standard.

Each character above BMP on Windows is stored as a UTF-16 surrogate pairs. It looks like standard std::wcout on Windows is implemented in the way it can't display any of these characters.

Other than convert back from wchar_t to multibyte char (UTF-8), can we make Windows std::wcout display these kind of characters right away?

Upvotes: 1

Views: 306

Answers (0)

Related Questions