[Qt-interest] QFileInfoList and UTF-8
Rutger Storm
rutgerstorm at gmail.com
Thu Feb 24 14:06:21 CET 2011
On 24 February 2011 13:32, Niels Dekker (Qt-interest) <
mymailfromqt at xs4all.nl> wrote:
> Nikos Chantziaras wrote:
> > Mathieu Malaterre wrote:
> >> 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;
> >> }
>
> > You can't assume the local filesystem uses UTF-8.
>
> ??? Given the fact that "echo $LANG" returns en_US.utf8 on Mathieu's
> machine, why can't he assume the local filesystem uses UTF-8?
>
>
> Thanks in advance,
>
> Niels
>
That is 1 box. If he would try his application on another and it doesn't use
UTF-8 then wont expect that.
Greetings,
Rutger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110224/73ffb73c/attachment.html
More information about the Qt-interest-old
mailing list