Mahmoud Abd El Samea
Mahmoud Abd El Samea

Reputation: 47

Creating a directory with a name containing UTF-8 characters in Qt

I am trying to create a directory that contains a UTF-8 characters using QDir::mkpath . A directory is created but the name is not correct. I am using this sample code:

#include <QCoreApplication>
#include <QDir>

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

    QString path = QDir::homePath();
    path += QDir::separator();
    path += "محمود";
    QDir().mkpath(path);
}

Upvotes: 1

Views: 576

Answers (1)

Mahmoud Abd El Samea
Mahmoud Abd El Samea

Reputation: 47

I solved my problem by replacing

path += "محمود";

by

path += QString::fromUtf8("محمود");

Upvotes: 1

Related Questions