vs2008でユニコードコンパイルを使用する
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);