Shift-JIS decoding fails using wifstrem in Visual C++ 2013

前端 未结 1 332
情话喂你
情话喂你 2021-01-03 04:42

I am trying to read a text file encoded in Shift-JIS (cp 932) using std::wifstream, and std::getline. The following code works in VS2010 but fails in VS2013:



        
相关标签:
1条回答
  • 2021-01-03 05:10

    I have found a workaround: if for the creation of the locale I explicitly change the global MBC code page, the locale is initialized correctly, and the lines are read and decoded as expected.

    const int oldMbcp = _getmbcp();
    _setmbcp(932);
    const std::locale locale("Japanese_Japan.932");
    _setmbcp(oldMbcp);
    
    0 讨论(0)
提交回复
热议问题