From dd0ddad631170e8825ea549eedc14c89712b0c1b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 8 Apr 2024 11:06:07 -0500 Subject: [PATCH] QText{En,De}coder: use DefaultConversion In Qt 5, the flag to write the BOM was a negative: if IgnoreHeader wasn't set, we would write it. That was the default in Qt 5 because DefaultConversion was 0. But now it's a positive flag, DefaultConversion was updated to set it, but we forgot to use it in the constructors of these two classes. [ChangeLog][Qt5CoreCompat][QTextEncoder] Fixed a bug that caused QTextEncoder not to write the Byte Order Mark for UTF codecs when the constructor without explicit flags was used. Fixes: QTBUG-122795 Pick-to: 6.5 6.7 Change-Id: If1bf59ecbe014b569ba1fffd17c459af4e0e00c9 Reviewed-by: Volker Hilsheimer --- src/core5/codecs/qtextcodec.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core5/codecs/qtextcodec.h b/src/core5/codecs/qtextcodec.h index 0c239e1..b21393f 100644 --- a/src/core5/codecs/qtextcodec.h +++ b/src/core5/codecs/qtextcodec.h @@ -93,7 +93,8 @@ class Q_CORE5COMPAT_EXPORT QTextEncoder { Q_DISABLE_COPY(QTextEncoder) public: - explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {} + explicit QTextEncoder(const QTextCodec *codec) + : c(codec), state(QTextCodec::DefaultConversion) {} explicit QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags); ~QTextEncoder(); QByteArray fromUnicode(const QString& str); @@ -109,7 +110,8 @@ class Q_CORE5COMPAT_EXPORT QTextDecoder { Q_DISABLE_COPY(QTextDecoder) public: - explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {} + explicit QTextDecoder(const QTextCodec *codec) + : c(codec), state(QTextCodec::DefaultConversion) {} explicit QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags); ~QTextDecoder(); QString toUnicode(const char* chars, int len);