如何显示unicode(表情符号)文件名" explorer.exe / select"使用QProcess?

时间:2017-07-27 19:56:45

标签: windows qt unicode windows-8 qprocess

我使用资源管理器显示节目文件和"选择"在Windows 7和Windows 8中,如下所示:

explorer /select,c:\foo\bar\baz.txt

在Qt中我尝试使用:

const QString filepath = a.applicationDirPath() + "\\.txt";
QStringList params = QStringList() << "/select," << filepath;
QProcess::startDetached("explorer", params);

在Windows 10中正常工作,但如果文件路径包含unicode字符(&#34; emojis&#34;),则无法在Windows 7和8中正常工作。

在我的文件夹中,我将两个文件放在发布文件夹中:

app.exe
.txt

我的来源:

#include <QCoreApplication>
#include <QProcess>
#include <QDebug>
#include <QDir>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    const QString name = ".txt";

    const QString filepath = QDir::toNativeSeparators(a.applicationDirPath() + "\\" + name);

    QStringList params = QStringList() << "/select," << filepath;

    qDebug().noquote() << "explorer " + params.join("");

    QProcess::startDetached("explorer", params);

    return a.exec();
}

我尝试使用chcp 65001

QProccess::execute("chcp 65001");
QProccess::startDetached("explorer", params);

我试过后:

const QString name = QString::fromWCharArray(L".txt");

const QString name = QString::fromStdWString(L".txt");

但不行。

&#34;编码&#34; filepath/select,参数一起使用?或者是否无法在Windows 7和Windows 8中使用unicode?

0 个答案:

没有答案
相关问题