首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于eclipse输出汉字出现乱码的有关问题

2013-08-04 
关于eclipse输出汉字出现乱码的问题#includeiostream#includelocaleusing namespace stdint main(){s

关于eclipse输出汉字出现乱码的问题

#include<iostream>
#include<locale>
using namespace std;
int main()
{
   setlocale(LC_ALL,"chs");
   wchar_t wt[]=L"方";
   wcout<<wt;
       return 0;
}

上面程序编译完运行之后结果为:乱码(特殊字符不让显示)
我也百度过,这就是设置windows-preference-general-workplace-text file encoding改为UTF-8后的结果,
不改之前(GBK)的错误信息是(错误:converting to execution character set:Illegal byte sequence)
请大神们帮忙解决这个问题?! Eclipse C++ 编码 乱码 宽字符
[解决办法]
把文件直接转为utf-8格式的吧
[解决办法]
#include<iostream>
#include<locale>
using namespace std;
int main()
{
wchar_t wt[]=L"方";
wcout.imbue(locale("chs"));
wcout<<wt;
return 0;
}

[解决办法]
我也遇到过。编译前把文件转成UTF-8后,就不会出现了。
觉得烦,后来直接打印英文。
[解决办法]
2楼貌似是对的。。要通过imbue设置的
[解决办法]
引用:
Quote: 引用:

#include<iostream>
#include<locale>
using namespace std;
int main()
{
wchar_t wt[]=L"方";
wcout.imbue(locale("chs"));
wcout<<wt;
return 0;
}

报错:This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid


是不是我eclipse有问题



gcc没有实现chs locale, 试试vc++

热点排行