首页 > 编程语言 > 详细

C++ wifstream读取日文方法(中文适用)

时间:2016-05-19 14:40:21      阅读:1020      评论:0      收藏:0      [点我收藏+]
#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

C++ wifstream读取日文方法(中文适用)

原文:http://www.cnblogs.com/elninovt9/p/5508353.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!