用wstring输出汉字,结果什么也不显示,为什么呢?

mbs34r3 2012-10-29 02:04:21
我是在英文版WindowsXP+VC2010编辑的程序:

int main(){
std::locale loc = std::locale::global( std::locale(".936",std::locale::ctype) );
setlocale(LC_ALL,"Chinese-simplified");
wcout.imbue(locale("chs"));
wstring ws(L"我来了");
wcout<<ws<<endl;
return 0;
}

但是还是不行,输出是:
???
Press any key to continue . . .

为什么?
...全文
502 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
mbs34r3 2012-10-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

添加中文字体库
中文字体库可以从网上下载再复制进XP的字体库文件夹中或是从其他中文版XP中复制过来
XP字体库所存放的文件夹在C:\WINDOWS\Fonts下面
[/Quote]

我已经添加了字体库什么的,上网IE显示,文件名中文,都没有问题的。
mbs34r3 2012-10-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

C/C++ code

#include <locale.h>
int main(){
std::locale loc = std::locale::global( std::locale(".936",std::locale::ctype) );
setlocale(LC_ALL,"Chinese-simplified");
wcout.imbue(loc……
[/Quote]
这个也不行
mbs34r3 2012-10-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

#include "iostream"

using namespace std;
int main(){
std::locale loc = std::locale::global( std::locale(".936",std::locale::ctype) );
setlocale(LC_ALL,"Chinese-simplified");
wco……
[/Quote]

这个不行
sumos 2012-10-30
  • 打赏
  • 举报
回复
setlocale的问题,要用unicode版本的。

_wsetlocale(LC_ALL,L"chs");
Isnis-fallen 2012-10-29
  • 打赏
  • 举报
回复
添加中文字体库
中文字体库可以从网上下载再复制进XP的字体库文件夹中或是从其他中文版XP中复制过来
XP字体库所存放的文件夹在C:\WINDOWS\Fonts下面
Isnis-fallen 2012-10-29
  • 打赏
  • 举报
回复
英文版WindowsXP
赵4老师 2012-10-29
  • 打赏
  • 举报
回复

#include <locale.h>
int main(){
std::locale loc = std::locale::global( std::locale(".936",std::locale::ctype) );
setlocale(LC_ALL,"Chinese-simplified");
wcout.imbue(locale("chs"));
wstring ws(L"我来了");
wcout<<ws<<endl;
return 0;
}

请叫我杨二哥 2012-10-29
  • 打赏
  • 举报
回复
#include "iostream"

using namespace std;
int main(){
std::locale loc = std::locale::global( std::locale(".936",std::locale::ctype) );
setlocale(LC_ALL,"Chinese-simplified");
wcout.imbue(locale("chs"));
wstring ws(L"我来了");
wcout<<ws.c_str()<<endl;
return 0;
}
你运行下这个试试??

64,690

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧