【发布时间】:2017-10-10 11:03:01
【问题描述】:
我正在尝试读取可能包含任何字符集/codePage 的文件,但我没有设置哪个区域设置以正确读取文件。
下面是我的代码 sn-p,我在其中尝试读取字符集为 windows-1256 的文件,但我想从正在读取的文件中动态获取字符集,以便我可以相应地设置语言环境。
std::wifstream input{ filename.c_str() };
std::wstring content{ std::istreambuf_iterator<wchar_t>(input1), std::istreambuf_iterator<wchar_t>() };
input.imbue(std::locale(".1256"));
contents = ws2s(content); // Convert wstring to CString
【问题讨论】:
标签: c++ unicode character-encoding utf icu