#include #include #include #include #include ... // Write file in UTF-8 std::wofstream wof; wof.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8)); wof.open(L"file.txt"); wof << L"This is a test."; wof << L"This is another test."; wof << L"\nThis is the final test.\n"; wof.close(); // Read file in UTF-8 std::wifstream wif(L"file.txt"); wif.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8)); std::wstringstream wss; wss << wif.rdbuf();