-
Bug
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
6.8.2
QDir::entryList() / QDir::entryInfoList() (and by implication QDirIterator) skip directory entries whose byte sequences for the filename are not valid UTF-8. This makes files created with legacy 8-bit encodings (e.g., ISO-8859-15) invisible to Qt applications. Some Qt-based file managers (e.g., pcmanfm-qt) can list these files, so this appears to be a Qt API limitation rather than an OS limitation.
Steps to reproduce
mkdir -p ~/encoding_test cd ~/encoding_test touch "bl$(printf '\xC3\xA4')-utf.txt" touch "bl$(printf '\xE4')-iso.txt"
#include <QCoreApplication> #include <QDir> #include <QFile> #include <QStringList> #include <QTextStream> #include <QTextCodec>int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QTextStream out(stdout); QDir dir("/home/irfan/encoding_test"); QStringList entries = dir.entryList(QDir::NoDotAndDotDot | QDir::AllEntries); for (const QString &entry : entries) { QString entry2(QString::fromUtf8(entry.toLatin1())); out << entry.length() << ": " << entry /*<< "\t" << entry2.length() << ": " << entry2*/ << ""; } return 0; }
When you run above code only the UTF-8 file (blä-utf.txt) is listed,Qt APIs that enumerate directory entries should not drop files whose names are not valid UTF-8. At minimum