读取unicode文件输出失败。
用下面代码在win7上运行,发现在控制台没有任何显示
#include "StdAfx.h"
#include <iostream>
#include <string>
using namespace std;
int main(int args, const char *argc[])
{
FILE* pfile = fopen("e:\\c++\\unicodeTest\\testinput.txt", "rb");
if(!pfile)
{
wcout<<"open file error!\n";
return 0;
}
fseek(pfile, 2, 0);
wchar_t buf[1024];
wstring line;
wstring newl = L"\x000D\x000A";
while (!feof(pfile))
{
fgetws(buf, 1024, pfile);
line =buf;
if(line.find(newl)!=wstring::npos)
line = line.substr(0, line.find(newl));
wcout<<line;
}
fclose(pfile);
return 0;
}
请问有谁知道怎么弄吗,我需要从unicode文件中读取内容然后再写入一个unicode文件。如果代码在linux下跑的也可以