diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index 6dbbec25a51..c3f1ba7228d 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -360,6 +360,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) if (bytesRead <= 0) return false; +#ifndef QT_BOOTSTRAPPED if (autoDetectUnicode) { autoDetectUnicode = false; @@ -374,6 +375,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) #if defined (QTEXTSTREAM_DEBUG) qDebug("QTextStreamPrivate::fillReadBuffer(), using %s encoding", QStringConverter::nameForEncoding(encoding)); #endif +#endif #if defined (QTEXTSTREAM_DEBUG) qDebug("QTextStreamPrivate::fillReadBuffer(), device->read(\"%s\", %d) == %d", diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 30054e5fe24..716b5823fbd 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -3419,6 +3419,7 @@ QString &QString::assign(QAnyStringView s) return *this; } +#ifndef QT_BOOTSTRAPPED QString &QString::assign_helper(const char32_t *data, qsizetype len) { // worst case: each char32_t requires a surrogate pair, so @@ -3438,6 +3439,7 @@ QString &QString::assign_helper(const char32_t *data, qsizetype len) } return *this; } +#endif /*! \fn QString &QString::remove(qsizetype position, qsizetype n) @@ -6022,6 +6024,7 @@ QString QString::fromUtf8(QByteArrayView ba) return QUtf8::convertToUnicode(ba); } +#ifndef QT_BOOTSTRAPPED /*! \since 5.3 Returns a QString initialized with the first \a size characters @@ -6083,7 +6086,7 @@ QString QString::fromUcs4(const char32_t *unicode, qsizetype size) QStringDecoder toUtf16(QStringDecoder::Utf32, QStringDecoder::Flag::Stateless); return toUtf16(QByteArrayView(reinterpret_cast(unicode), size * 4)); } - +#endif // !QT_BOOTSTRAPPED /*! Resizes the string to \a size characters and copies \a unicode diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index 854850a981f..895ec4b5c0a 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -1311,7 +1311,11 @@ QString QString::fromWCharArray(const wchar_t *string, qsizetype size) if constexpr (sizeof(wchar_t) == sizeof(QChar)) { return QString(reinterpret_cast(string), size); } else { +#ifdef QT_BOOTSTRAPPED + Q_UNREACHABLE_RETURN(QString()); +#else return fromUcs4(reinterpret_cast(string), size); +#endif } } diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 6ada8a842a5..efa625e30b5 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -942,6 +942,7 @@ int QUtf8::compareUtf8(QByteArrayView lhs, QByteArrayView rhs, Qt::CaseSensitivi return (end1 > src1) - (end2 > src2); } +#ifndef QT_BOOTSTRAPPED QByteArray QUtf16::convertFromUnicode(QStringView in, QStringConverter::State *state, DataEndianness endian) { bool writeBom = !(state->internalState & HeaderDone) && state->flags & QStringConverter::Flag::WriteBom; @@ -1251,6 +1252,7 @@ QChar *QUtf32::convertToUnicode(QChar *out, QByteArrayView in, QStringConverter: return out; } +#endif // !QT_BOOTSTRAPPED #if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) int QLocal8Bit::checkUtf8() @@ -1647,6 +1649,7 @@ void QStringConverter::State::reset() noexcept } } +#ifndef QT_BOOTSTRAPPED static QChar *fromUtf16(QChar *out, QByteArrayView in, QStringConverter::State *state) { return QUtf16::convertToUnicode(out, in, state, DetectEndianness); @@ -1706,6 +1709,7 @@ static char *toUtf32LE(char *out, QStringView in, QStringConverter::State *state { return QUtf32::convertFromUnicode(out, in, state, LittleEndianness); } +#endif // !QT_BOOTSTRAPPED char *QLatin1::convertFromUnicode(char *out, QStringView in, QStringConverter::State *state) noexcept { @@ -1747,11 +1751,13 @@ static char *toLocal8Bit(char *out, QStringView in, QStringConverter::State *sta static qsizetype fromUtf8Len(qsizetype l) { return l + 1; } static qsizetype toUtf8Len(qsizetype l) { return 3*(l + 1); } +#ifndef QT_BOOTSTRAPPED static qsizetype fromUtf16Len(qsizetype l) { return l/2 + 2; } static qsizetype toUtf16Len(qsizetype l) { return 2*(l + 1); } static qsizetype fromUtf32Len(qsizetype l) { return l/2 + 2; } static qsizetype toUtf32Len(qsizetype l) { return 4*(l + 1); } +#endif static qsizetype fromLatin1Len(qsizetype l) { return l + 1; } static qsizetype toLatin1Len(qsizetype l) { return l + 1; } @@ -1887,12 +1893,14 @@ static qsizetype toLatin1Len(qsizetype l) { return l + 1; } const QStringConverter::Interface QStringConverter::encodingInterfaces[QStringConverter::LastEncoding + 1] = { { "UTF-8", QUtf8::convertToUnicode, fromUtf8Len, QUtf8::convertFromUnicode, toUtf8Len }, +#ifndef QT_BOOTSTRAPPED { "UTF-16", fromUtf16, fromUtf16Len, toUtf16, toUtf16Len }, { "UTF-16LE", fromUtf16LE, fromUtf16Len, toUtf16LE, toUtf16Len }, { "UTF-16BE", fromUtf16BE, fromUtf16Len, toUtf16BE, toUtf16Len }, { "UTF-32", fromUtf32, fromUtf32Len, toUtf32, toUtf32Len }, { "UTF-32LE", fromUtf32LE, fromUtf32Len, toUtf32LE, toUtf32Len }, { "UTF-32BE", fromUtf32BE, fromUtf32Len, toUtf32BE, toUtf32Len }, +#endif { "ISO-8859-1", QLatin1::convertToUnicode, fromLatin1Len, QLatin1::convertFromUnicode, toLatin1Len }, { "Locale", fromLocal8Bit, fromUtf8Len, toLocal8Bit, toUtf8Len } }; @@ -2240,6 +2248,7 @@ std::optional QStringConverter::encodingForName(cons return std::nullopt; } +#ifndef QT_BOOTSTRAPPED /*! Returns the encoding for the content of \a data if it can be determined. \a expectedFirstCharacter can be passed as an additional hint to help determine @@ -2401,7 +2410,6 @@ QStringList QStringConverter::availableCodecs() return result; } - /*! Tries to determine the encoding of the HTML in \a data by looking at leading byte order marks or a charset specifier in the HTML meta tag and returns a QStringDecoder @@ -2425,7 +2433,7 @@ QStringDecoder QStringDecoder::decoderForHtml(QByteArrayView data) return QStringDecoder(Utf8); } - +#endif // !QT_BOOTSTRAPPED /*! Returns the canonical name for encoding \a e. diff --git a/src/corelib/text/qstringconverter_base.h b/src/corelib/text/qstringconverter_base.h index 19b6399c05c..d6b6fcb484b 100644 --- a/src/corelib/text/qstringconverter_base.h +++ b/src/corelib/text/qstringconverter_base.h @@ -89,12 +89,14 @@ public: enum Encoding { Utf8, +#ifndef QT_BOOTSTRAPPED Utf16, Utf16LE, Utf16BE, Utf32, Utf32LE, Utf32BE, +#endif Latin1, System, LastEncoding = System