On Thu, Dec 07, 2006 at 04:34:45PM +0100, Enrico Forestieri wrote:
> On Thu, Dec 07, 2006 at 12:39:36PM +0100, Georg Baum wrote:
> > Am Dienstag, 5. Dezember 2006 23:20 schrieb Enrico Forestieri:
> 
> > > I think this is what the Qt QString::toLocal8Bit() does.
> > 
> > Yes, I think so, too. I wonder what the difference to QFile::encodeName() 
> > is?
> 
> I think they perform the same task, except that you can use encodeName()
> directly with a QFile object.

I checked the sources and it turned out that they are equivalent
except on Mac, as shown from this excerpt from qfile.cpp:

static QByteArray locale_encode(const QString &f)
{
#ifndef Q_OS_DARWIN
    return f.toLocal8Bit();
#else
    // Mac always expects UTF-8
    return f.toUtf8();
#endif
}

...

void
QFile::setEncodingFunction(EncoderFn f)
{
    if (!f)
        f = locale_encode;
    QFilePrivate::encoder = f;
}

...

QByteArray
QFile::encodeName(const QString &fileName)
{
    return (*QFilePrivate::encoder)(fileName);
}

-- 
Enrico

Reply via email to