我需要使用我的 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;
}
第二种方法
unsigned char temp = 'A'
for(int i=65; i< 255; i++ )
{
std::cout << temp++ << std::endl;
std::wcout << temp << std::endl;
}
有什么建议或替代想法吗?
原文由 Nayana Adassuriya 发布,翻译遵循 CC BY-SA 4.0 许可协议
尝试使用 Unicode
cout << "\u25A0";
http://www.fileformat.info/info/unicode/category/So/list.htm