utf8 中文
#include <iostream>
#include <codecvt>#include <fstream>#include <string> int main(void){ using namespace std; auto LocUtf8=locale(locale(""),new codecvt_utf8<wchar_t>); wofstream wfo(L"Hello.txt"); wfo.imbue(LocUtf8); wfo << L"这是Utf-8编码的文本文件!"; wfo.close(); wifstream wfi(L"Hello.txt"); wstring wstr; wfi.imbue(LocUtf8); wfi >> wstr; wcout.imbue(locale("")); wcout << wstr << endl; system("PAUSE");}
浙公网安备 33010602011771号