Improve QFile::encodeName(), QFile::decodeName() documentation

Make it explicit that the local 8 bit encoding is UTF-8 on all
platforms but Windows.

Change-Id: Icaabfd28689a71ee5cc2957f058f9388405496d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ac6e61d867d76d0a24449f82c0f484a513fec184)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Kai Köhne 2022-12-21 15:13:04 +01:00 committed by Qt Cherry-pick Bot
parent 6ff96b2dce
commit 086b41349a

View File

@ -150,13 +150,11 @@ QAbstractFileEngine *QFilePrivate::engine() const
data and operator>>() to read it back. See the class data and operator>>() to read it back. See the class
documentation for details. documentation for details.
When you use QFile, QFileInfo, and QDir to access the file system \l{Input/Output and Networking}{Qt APIs related to I/O} use UTF-16 based
with Qt, you can use Unicode file names. On Unix, these file QStrings to represent file paths. Standard C++ APIs (\c <cstdio> or
names are converted to an 8-bit encoding. If you want to use \c <iostream>) or platform-specific APIs however often need a 8-bit encoded
standard C++ APIs (\c <cstdio> or \c <iostream>) or path. You can use encodeName() and decodeName() to convert between both
platform-specific APIs to access files instead of QFile, you can representations.
use the encodeName() and decodeName() functions to convert
between Unicode file names and 8-bit file names.
On Unix, there are some special system files (e.g. in \c /proc) for which On Unix, there are some special system files (e.g. in \c /proc) for which
size() will always return 0, yet you may still be able to read more data size() will always return 0, yet you may still be able to read more data
@ -322,10 +320,10 @@ QFile::setFileName(const QString &name)
/*! /*!
\fn QByteArray QFile::encodeName(const QString &fileName) \fn QByteArray QFile::encodeName(const QString &fileName)
Converts \a fileName to the local 8-bit Converts \a fileName to an 8-bit encoding that you can use in native
encoding determined by the user's locale. This is sufficient for APIs. On Windows, the encoding is the one from active Windows (ANSI)
file names that the user chooses. File names hard-coded into the codepage. On other platforms, this is UTF-8, for \macos in decomposed
application should only use 7-bit ASCII filename characters. form (NFD).
\sa decodeName() \sa decodeName()
*/ */