[Qt-interest] QFileInfoList and UTF-8
Mathieu Malaterre
mathieu.malaterre at gmail.com
Thu Feb 24 13:04:01 CET 2011
Dear all,
I am trying to use QDir, but I do not understand how I should be
dealing with UTF-8 encoded filename. Here is a simple demo that I
tried on my linux box:
$ mkdir /tmp/demo
$ touch /tmp/demo/François.txt
$ ./demo /tmp/demo
/tmp/demo/François.txt
$ echo $LANG
en_US.utf8
Here is the code for demo.cxx:
#include <QDir>
#include <QString>
#include <iostream> // std::cout
int main(int , char *argv[])
{
const char *dirname = argv[1];
QDir dir( QString::fromUtf8(dirname) );
QFileInfoList children =
dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot);
QFileInfo file = children.at(0);
std::cout << file.absoluteFilePath().toUtf8().constData() << std::endl;
return 0;
}
What am I missing from the call to entryInfoList ? I am trying to use
a 3rd party library which expect filenames to be specified as UTF-8.
thank you
--
Mathieu
More information about the Qt-interest-old
mailing list