关于C语言读取Unicode文档的有关问题,求教
关于C语言读取Unicode文档的问题,求教
------解决思路----------------------
因为windows中txt文件保存为unicode是带签名的,就是在文件开始有几个字节的字符作标记,你用一个二进制查看器看一下就知道了
//in main.cpp
#include<stdio.h>
#include<wchar.h>
int main()
{
FILE*pf = _wfopen(L"D:\\Unicode.txt",L"rt");
if(!pf)
{
printf("Error:can not open this file.\n");
return 0;
}
wchar_t wc;
while((wc = fgetwc(pf))!=EOF)
wprintf(L"%c",wc);
fclose(pf);
return 0;
}
// What's in Unicode.txt?
// Just a string "123456"
//Display:
// ? 2 3 4 5 6
//Question
//Why can not show the character '1'?
------解决思路----------------------
因为windows中txt文件保存为unicode是带签名的,就是在文件开始有几个字节的字符作标记,你用一个二进制查看器看一下就知道了