小编Phy*_*137的帖子

如何在Linux上用std :: ifstream读取文件中的非ASCII行?

我试图读取纯文本文件.在我的情况下,我需要读取每行的行,并处理该信息.我知道C++有阅读wchars的功能.我尝试了以下方法:

#include <fstream>
#include <iostream>

int main() {
    std::wfstream file("file");       // aaaàaaa
    std::wstring str;
    std::getline(file, str);
    std::wcout << str << std::endl;   // aaa
}
Run Code Online (Sandbox Code Playgroud)

但正如你所看到的,它没有读完整行.读取"à"时会停止,这是非ASCII.我该如何解决?

c++ linux

9
推荐指数
1
解决办法
2710
查看次数

标签 统计

c++ ×1

linux ×1