c - 如何将 unicode 符号打印到控制台

标签 c console codepages

我想打印 ▌ 符号到控制台。 我试过了

printf(L"▌");

wchar_t t = L'\u2588';
wprintf(L"%c\n", t);

但我只得到'?'结果。 我使用 Visual Studio 2012

更新

如果我将语言环境设置为en-US

setlocale(LC_ALL, "en-US");

我得到 | for + for _ for

最佳答案

要在控制台中启用 unicode,我们应该使用 _setmode(_fileno(stdout), _O_U16TEXT);

#include <stdio.h>
#include <io.h>
#include <fcntl.h>
void main()
{
    _setmode(_fileno(stdout), _O_U16TEXT);
    wprintf(L"█");
}

关于c - 如何将 unicode 符号打印到控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22050684/

相关文章:

c - typedef 一个函数指针

windows - 加速 Windows 上的文本输出,用于控制台

java - 在 Java 中以编程方式清除控制台

.net - .NET 可以将 Unicode 转换为 ASCII 以删除 "smart quotes"等吗?

visual-c++ - 如何更改 MS Visual Studio 2008 用于打开文件的代码页?

c# - Xamarin UI 测试 "1 is not a supported code page."

c++ - Windows CreateFile 可能的错误代码

c - 编写程序执行 sum = 1+ (1+2) + (1+2+3) + ... + (1+2...+n)

c - 如何在字符串中集成 int 变量?

javascript - 如何在 Internet Explorer 中使用控制台日志记录?