在vs2008中使用unicode编译如何用wofstream将许多语言字符输出到C++文件中?
我可以在 C 代码中做到这一点没问题,例如
FILE *out;
if( (out = _wfopen( L"test.txt", L"wb" )) != NULL )
{
fwprintf(out,L"test\r\n");
fwprintf(out,L"наказание\r\n");
fwprintf(out,L"ウェブ全体から検索\r\n");
}
当我打开文件时,一切都是正确的,但是在下面的 C++ 程序中,我得到的只是第一行,我尝试过 locale::global(locale("")); 结果相同。
wofstream MyOutputStream(L"test.txt");
if(!MyOutputStream)
{
AfxMessageBox(L"Error opening file");
return;
}
MyOutputStream << L"test\r\n";
MyOutputStream << L"наказание\r\n";
MyOutputStream << L"ウェブ全体から検索\r\n";
MyOutputStream.close();
我已经尝试以相同的结果插入它:-
std::locale mylocale("");
MyOutputStream.imbue(mylocale);