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);

 

posted @ 2022-07-25 18:06  快雪  阅读(198)  评论(0编辑  收藏  举报