在控制台中打印填充的方块

Nay*_*iya 3 c++ linux ascii

我需要使用我的C++程序(1cm x 1cm大小)在Linux终端中打印填充的正方形.我尝试使用ASCII 254(■),但在终端中它打印为垃圾字符.我不确定如何使用c ++打印扩展的ASCII字符.以下是我尝试打印扩展ASCII的两种方法.但没有成功.

第一种方法

for(int i=128; i< 255; i++ )
{
 std::cout << static_cast<char>(i) << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

第二种方法

unsigned char temp = 'A'
for(int i=65; i< 255; i++ )
{
 std::cout << temp++ << std::endl;
 std::wcout << temp << std::endl;
}
Run Code Online (Sandbox Code Playgroud)

任何建议或替代想法?

小智 5

或者尝试:

std::cout << (char)254u;
Run Code Online (Sandbox Code Playgroud)