一开始在vs2010 beta2里不能输出中文,最简单代码:
#include<stdio.h>
int main()
{
printf("汉字");
return 0;
}
错误信息是:
warning C4566: character represented by universal-character-name '/u6C49' cannot be represented in the current code page (1252)
warning C4566: character represented by universal-character-name '/u5B57' cannot be represented in the current code page (1252)
一开始一直在修改输出流的编码方式,网上的各种方法都不行,最后在csdn论坛上问得到提示,可能是codepage的问题,
我在cmd.exe里输入chcp,出来的是437就是美国的代码页,但是当输入chcp 936的时候,提示无效代码页,我去注册表了看了,在database->codepage有936该子键,很纳闷这个是为什么?
因为得系统是英文的,System locale也是US的,所以默认的codepage才是437.
但是我把我的System locale改成Chinese(PRC)之后,重启,默认的codepage就是936了。
当我是英文的System locale的时候,输入chcp 936显示无效代码页,这个问题还是没解决,很奇怪,我明明找的到!
System locale 的作用:This setting(System locale) controls the lanusge used when displaying text in programs that do not support Unicode.
本文解决了在VS2010中无法输出中文字符的问题。通过更改系统的区域设置来调整默认的代码页,从437更改为936,实现了中文字符的正常显示。
2224

被折叠的 条评论
为什么被折叠?



