#include <iostream> #include <fstream> #include <locale> #include <codecvt> int main() { const std::locale empty_locale = std::locale::empty(); typedef std::codecvt_utf8<wchar_t> converter_type; //std::codecvt_utf16 const converter_type* converter = new converter_type; const std::locale utf8_locale = std::locale(empty_locale, converter); std::wifstream fin("Test_GetNextChar.txt"); //input fin.imbue(utf8_locale); wchar_t ch; while (!fin.eof()) { fin >> ch; std::cout << ch << std::endl; } system("pause"); return 0; }
方法来自:https://www.zhihu.com/question/29043383
时间: 2024-10-27 16:25:19