I am trying to print some "special" characters (above 127) in the console, but somehow it doesn't get printed.

I have this small code snippet:

#include <iostream>
int main()
{
    std::wcout << L"a■■■■■■■■■■■a■■■■■■■■■■■■■■a" << std::flush;
    return 0;
}

it prints the 'a' but then... nothing. and it doesn't matter if I use cout/string or wcout/wstring. (with cout I only see "?" and in wcout nothing, it ends the stream)

The ascii code is 254 for this character. What can be happening here? I thought this is okay to print?

有帮助吗?

解决方案

From the answer I linked to in the comments, I think this is your solution:

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

_setmode(_fileno(stdout), _O_U8TEXT);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top