OSDN Git Service

inline toLocal8Bit_helper() function and use it in QString::toLocal8Bit()
authorIvailo Monev <xakepa10@gmail.com>
Mon, 31 Oct 2022 22:12:59 +0000 (00:12 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 31 Oct 2022 22:12:59 +0000 (00:12 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/tools/qstring.cpp

index f28d0ab..9bf9268 100644 (file)
@@ -3179,7 +3179,7 @@ QByteArray QString::toAscii() const
     return QTextCodecPrivate::convertFrom(constData(), length(), "US-ASCII");
 }
 
-static QByteArray toLocal8Bit_helper(const QChar *data, int length)
+static inline QByteArray toLocal8Bit_helper(const QChar *data, int length)
 {
     const QByteArray localecodec = QTextCodecPrivate::localeCodec();
     return QTextCodecPrivate::convertFrom(data, length, localecodec.constData());
@@ -3202,11 +3202,7 @@ static QByteArray toLocal8Bit_helper(const QChar *data, int length)
 */
 QByteArray QString::toLocal8Bit() const
 {
-#ifndef QT_NO_TEXTCODEC
-    return QTextCodec::codecForLocale()->fromUnicode(unicode(), length());
-#else
-    return toLatin1();
-#endif // QT_NO_TEXTCODEC
+    return toLocal8Bit_helper(unicode(), length());
 }
 
 /*!