【发布时间】:2015-12-12 11:49:20
【问题描述】:
我试过setlocale、wchar、普通char……怎么定义:
char c = '☻'
cout << c << endl;
打印到控制台上(这与 VS2012 和 http://ideone.com/LJtDUz 有关)
【问题讨论】:
-
你不打印 :) 代替吗? :v
标签: c++
我试过setlocale、wchar、普通char……怎么定义:
char c = '☻'
cout << c << endl;
打印到控制台上(这与 VS2012 和 http://ideone.com/LJtDUz 有关)
【问题讨论】:
标签: c++
问题是windows默认不处理Unicode字符,windows控制台也无法显示。
我在This CPP Thread找到的解决方案如下:
#include <fcntl.h>
#include <io.h>
#include <iostream>
int
main(int argc, char* argv[])
{
wchar_t* c = L"☻"; /* needed because the project is using 'Unicode Character Set' */
_setmode(_fileno(stdout), _O_WTEXT); /* set stdout to UTF16 */
std::wcout << c << std::endl; /* use a wide cout call to output characters */
getchar();
return 0;
}
当您尝试直接在代码中使用☻ 符号时,Windows 会告诉您我需要将您的文件转换为Unicode,请确保接受并使用Unicode Character Set 作为您的项目字符集类型.
【讨论】: