[C/C++]_[VS2010来源与UTF8中国字符串转码ANSI问题]


现场:

1.思想vs设置源文件UTF8编码,代码中国串出现在它必须是utf8编码,不幸的是,,假定源代码将出现在中国字符串,在存储器中转码ANSI编码。

Unicode(UTF8签名) 代码页(65001),从菜单->文件->高级保存选项 设置.


样例:

char path[] = "resources\\中文\\";
for(int i = 0; i < strlen(path); ++i)
{
	printf("0x%x,",(unsigned char)path[i]);
}

查看UTF8文件十六进制
0x72,0x65,0x73,0x6F,0x75,0x72,0x63,0x65,0x73,0x5C,0x5C,0xE4,0xB8,0xAD,0xE6,0x96,0x87,0x5C,0x5C


打印出来的内存:
0x72,0x65,0x73,0x6f,0x75,0x72,0x63,0x65,0x73,0x5c,0xd6,0xd0,0xce,0xc4,0x5c

明确"中国”该文件的编码是
0xE4,0xB8,0xAD,0xE6,0x96,0x87

装载存储器,并成为,此代码是ANSI编码,这是本地编码(GB2312).
0xd6,0xd0,0xce,0xc4

得出的结论是: vs不要出现在源代码utf8中国的字符串,它将被代码转换ansi编码.


posted @ 2015-06-18 14:36  blfshiye  阅读(529)  评论(0编辑  收藏  举报