diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-04-17 19:24:30 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-14 07:47:20 +0200 |
commit | 9ada6e5719ec8bddbb56875cff52b902b73dc197 (patch) | |
tree | ecbcff36b64318c86d0e4d395dc3f89a15d32fa9 /src/corelib/io | |
parent | d9870dc233208e2bc233d95955e9b4384d4a707d (diff) |
Remove QTextCodec dependency from qfilesystemiterator
Assume Unix systems are utf-8 based nowadays. glib has been
assuming this for quite some time already, and all Linux and BSD
systems shipped in the last 10 years assume utf-8 for 8-bit strings.
Utf-8 is also the encoding used by macOS and QNX since a very long time.
File systems where file names are not encoded in utf-8 can usually be
translated transparently to utf8 by specifying appropriate mount
options.
Change-Id: I1970496db24e59dee8efb79ba025355a3ce87387
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfilesystemiterator_unix.cpp | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index 4bc6b2e31b..fd96298f69 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -40,10 +40,7 @@ #include "qplatformdefs.h" #include "qfilesystemiterator_p.h" -#if QT_CONFIG(textcodec) -# include <qtextcodec.h> -# include <private/qstringconverter_p.h> -#endif +#include <private/qstringconverter_p.h> #ifndef QT_NO_FILESYSTEMITERATOR @@ -59,39 +56,7 @@ static bool checkNameDecodable(const char *d_name, qsizetype len) // This function is called in a loop from advance() below, but the loop is // usually run only once. -#if QT_CONFIG(textcodec) - // We identify the codecs by their RFC 2978 MIBenum values. In this - // function: - // 3 US-ASCII (ANSI X3.4-1986) - // 4 Latin1 (ISO-8859-1) - // 106 UTF-8 - QTextCodec *codec = QTextCodec::codecForLocale(); -# ifdef QT_LOCALE_IS_UTF8 - int mibEnum = 106; -# else - int mibEnum = 4; // Latin 1 - if (codec) - mibEnum = codec->mibEnum(); -# endif - if (Q_LIKELY(mibEnum == 106)) // UTF-8 - return QUtf8::isValidUtf8(d_name, len).isValidUtf8; - if (mibEnum == 3) // US-ASCII - return QtPrivate::isAscii(QLatin1String(d_name, len)); - if (mibEnum == 4) // Latin 1 - return true; - - // fall back to generic QTextCodec - QTextCodec::ConverterState cs(QTextCodec::IgnoreHeader); - codec->toUnicode(d_name, len, &cs); - return cs.invalidChars == 0 && cs.remainingChars == 0; -#else - Q_UNUSED(d_name); - Q_UNUSED(len); - // if we have no text codecs, then QString::fromLocal8Bit is fromLatin1 - Q_UNUSED(d_name) - Q_UNUSED(len) - return true; -#endif + return QUtf8::isValidUtf8(d_name, len).isValidUtf8; } QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, |