From 086b41349ad50d03073633607082febad56b05ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Wed, 21 Dec 2022 15:13:04 +0100 Subject: [PATCH] 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 (cherry picked from commit ac6e61d867d76d0a24449f82c0f484a513fec184) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/io/qfile.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index bb4a4640174..585b5c8a1b9 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -150,13 +150,11 @@ QAbstractFileEngine *QFilePrivate::engine() const data and operator>>() to read it back. See the class documentation for details. - When you use QFile, QFileInfo, and QDir to access the file system - with Qt, you can use Unicode file names. On Unix, these file - names are converted to an 8-bit encoding. If you want to use - standard C++ APIs (\c or \c ) or - platform-specific APIs to access files instead of QFile, you can - use the encodeName() and decodeName() functions to convert - between Unicode file names and 8-bit file names. + \l{Input/Output and Networking}{Qt APIs related to I/O} use UTF-16 based + QStrings to represent file paths. Standard C++ APIs (\c or + \c ) or platform-specific APIs however often need a 8-bit encoded + path. You can use encodeName() and decodeName() to convert between both + representations. 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 @@ -322,10 +320,10 @@ QFile::setFileName(const QString &name) /*! \fn QByteArray QFile::encodeName(const QString &fileName) - Converts \a fileName to the local 8-bit - encoding determined by the user's locale. This is sufficient for - file names that the user chooses. File names hard-coded into the - application should only use 7-bit ASCII filename characters. + Converts \a fileName to an 8-bit encoding that you can use in native + APIs. On Windows, the encoding is the one from active Windows (ANSI) + codepage. On other platforms, this is UTF-8, for \macos in decomposed + form (NFD). \sa decodeName() */