File::encodeName() and Utf8 as the default encoding under Qt5

Lubomir I. Ivanov neolit123 at
Wed Oct 29 08:32:58 PDT 2014

hi Thiogo,

related to bug #740
where special chars in Win32 file names no longer work (again).

in mainwindow.cpp we have some ::encodeName() calls.
as i understand it on Qt4 it should work because of the setup in qt-qui.cpp.

but for Qt5:

QFile::setEncodingFunction() and QFile::setDecodingFunction() are
deprecated. The QFile::encodeName() andQFile::decodeName() functions
are now hard-coded to operate on QString::fromLocal8Bit() and
QString::toLocal8Bit() only. The old behavior is still possible using
QTextCodec::setCodecForLocale(), but it is recommended that the new
code should not make assumptions about the file system encoding and
older code should remove such assumptions.

now, i know how to fix the issue by simply not use File::encodeName()
at all on Win32 and use QString::toUtf8() instead but is there a
cleaner way with no #ifdefs?

not sure if QTextCodec::setCodecForLocale() should be set to Utf8 on Win32...


More information about the subsurface mailing list