VS 2012 を使用してこのコードを作成しました。
std::wofstream logout("my_log.txt", std::ios_base::out | std::ios_base::trunc);
std::locale utf8_locale(locale(), new codecvt_utf8<wchar_t>);
logout.imbue(utf8_locale);
if (!logout.is_open())
{
printf("Cannot open file.\n");
return 1;
}
else printf("Log file created.\n");
logout << "Client IP │"<< "Recv time │"<< "Request │"<< "Response "<<endl;
logout << "─────────────────────┼"<< "─────────────────────────┼"<<endl;
my_log.txt ファイルでは、すべての Unicode 記号が「?????」に置き換えられます。ログファイルテーブルのようなものを作成したい。「---」のような標準のASCII記号を使用すると、機能し、それらはすべて正しく表示されます。グローバル ロケールを変更しようとしましたが、成功しません。