c++ - 为进程输出问题设置编码

标签 c++ qt windows-applications windows-console

我想为俄语输出的 Windows 控制台进程设置编码。在 C# 中,Process 有一个 StandardOutputEncoding 属性,但在 Qt 中不存在这样的功能。

问题是:

enter image description here

关于如何完成它有什么建议吗?

更新:

我试过 QTextStream setCodec 函数:

void Test1::getData(QByteArray data)
{
    QTextStream encodeStream(data);
    encodeStream.setCodec("windows-1251");

    dataTextBrowser->append(encodeStream.readAll());
    emit dataFinished();
}

结果:

enter image description here

最佳答案

感谢 Michael O。我已经解决了这个问题。另外,我在这里包含了代码,以便其他人可以找到解决方案。

代码:

void Test1::getData(QByteArray data)
{
    QTextStream encodeStream(data);
    encodeStream.setCodec("IBM 866");
    dataTextBrowser->append(encodeStream.readAll());
    emit dataFinished();
}

关于c++ - 为进程输出问题设置编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45633572/

相关文章:

windows-8.1 - Windows App 确定 TextBlock 是否被修剪

c++ - ULARGE_INTEGER union 的意义何在?

c++ - 如何在基于 Qt 的 Autodesk Maya 插件中使用相对路径?

.net - 部署后显示我的 Windows 应用程序的背景图像时出错

c++ - 如何检查行是否在 SQLite 中被插入或替换?

python - 扩展 pyqt 或 QT 的图像查看器示例

c# - system.stackoverflowexception 无法计算表达式,因为当前线程处于堆栈溢出状态

c++ - 如何在 C++ 中获得立方根?

c++ - 如何在 Ubuntu 上安装 OpenSSL 库?

c++ - std::bitset::at() 在 VS2015 中消失