对数据源进行读取操作的时候,程序判断代码环境的 locale状况. 从而把文件内容从某种locale的编码转化到 unicode.
#include "stdafx.h" #include #include #include int _tmain(int argc, _TCHAR* argv[]) { using namespace std; wstring strLine; std::wifstream wifFileIn(L"c://1233.txt"); wifFileIn.imbue(locale("chs")); //文件编码 .936 wcout.imbue(locale("chs")); //控制台 codepage 936 while(getline(wifFileIn,strLine)) wcout<<strLine<<endl; return 0; }