iostreams - Print `wchar_t` or `charXX_t` value as a character
问题 If you feed a wchar_t , char16_t , or char32_t value to a narrow ostream, it will print the numeric value of the code point. #include <iostream> using std::cout; int main() { cout << 'x' << L'x' << u'x' << U'x' << '\n'; } prints x120120120 . This is because there is an operator<< for the specific combination of basic_ostream with its charT , but there aren't analogous operators for the other character types, so they get silently converted to int and printed that way. Similarly, non-narrow