unicode下使用wofstream无法写入中文问题
#ifdef _UNICODE std::wofstream os; #else std::ofstream os; #endif
请设置:
os.imbue(std::locale("chs"));
或存为utf-8:
std::locale utf8(std::locale("C"), new std::codecvt_utf8<wchar_t, 0x10ffff, std::codecvt_mode(std::generate_header | std::little_endian)>()); os.imbue(utf8);