Mark places where we missed conversion to unicode character types
We should use char32_t for the toUcs4() methods of QString and QStringView and use char16_t for QString::utf16(), thereby matching QStringView. These naturally imply knock-on changes in various places. Unfortunately, we didn't make those changes in Qt 6, so they'll have to wait for Qt 7. Change-Id: I18451d4b31b76658092e19d3fcbc8bc0fe5ce307 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
d3399092db
commit
c9c598d4d7
@ -708,7 +708,7 @@ public:
|
||||
|
||||
[[nodiscard]] QString repeated(qsizetype times) const;
|
||||
|
||||
const ushort *utf16() const;
|
||||
const ushort *utf16() const; // ### Qt 7 char16_t
|
||||
|
||||
#if !defined(Q_CLANG_QDOC)
|
||||
[[nodiscard]] QByteArray toLatin1() const &
|
||||
@ -728,7 +728,7 @@ public:
|
||||
[[nodiscard]] QByteArray toUtf8() const;
|
||||
[[nodiscard]] QByteArray toLocal8Bit() const;
|
||||
#endif
|
||||
[[nodiscard]] QList<uint> toUcs4() const;
|
||||
[[nodiscard]] QList<uint> toUcs4() const; // ### Qt 7 char32_t
|
||||
|
||||
// note - this are all inline so we can benefit from strlen() compile time optimizations
|
||||
static QString fromLatin1(QByteArrayView ba);
|
||||
@ -775,7 +775,7 @@ public:
|
||||
|
||||
QString &setRawData(const QChar *unicode, qsizetype size);
|
||||
QString &setUnicode(const QChar *unicode, qsizetype size);
|
||||
inline QString &setUtf16(const ushort *utf16, qsizetype size);
|
||||
inline QString &setUtf16(const ushort *utf16, qsizetype size); // ### Qt 7 char16_t
|
||||
|
||||
#if QT_STRINGVIEW_LEVEL < 2
|
||||
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
|
||||
@ -1089,7 +1089,7 @@ private:
|
||||
static QByteArray toLatin1_helper_inplace(QString &);
|
||||
static QByteArray toUtf8_helper(const QString &);
|
||||
static QByteArray toLocal8Bit_helper(const QChar *data, qsizetype size);
|
||||
static qsizetype toUcs4_helper(const ushort *uc, qsizetype length, uint *out);
|
||||
static qsizetype toUcs4_helper(const ushort *uc, qsizetype length, uint *out); // ### Qt 7 char16_t
|
||||
static qlonglong toIntegral_helper(QStringView string, bool *ok, int base);
|
||||
static qulonglong toIntegral_helper(QStringView string, bool *ok, uint base);
|
||||
void replace_helper(size_t *indices, qsizetype nIndices, qsizetype blen, const QChar *after, qsizetype alen);
|
||||
|
@ -144,7 +144,7 @@ namespace QtPrivate {
|
||||
[[nodiscard]] Q_CORE_EXPORT QByteArray convertToLatin1(QStringView str);
|
||||
[[nodiscard]] Q_CORE_EXPORT QByteArray convertToUtf8(QStringView str);
|
||||
[[nodiscard]] Q_CORE_EXPORT QByteArray convertToLocal8Bit(QStringView str);
|
||||
[[nodiscard]] Q_CORE_EXPORT QList<uint> convertToUcs4(QStringView str);
|
||||
[[nodiscard]] Q_CORE_EXPORT QList<uint> convertToUcs4(QStringView str); // ### Qt 7 char32_t
|
||||
|
||||
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept;
|
||||
|
||||
|
@ -254,7 +254,7 @@ public:
|
||||
[[nodiscard]] QByteArray toLatin1() const { return QtPrivate::convertToLatin1(*this); }
|
||||
[[nodiscard]] QByteArray toUtf8() const { return QtPrivate::convertToUtf8(*this); }
|
||||
[[nodiscard]] QByteArray toLocal8Bit() const { return QtPrivate::convertToLocal8Bit(*this); }
|
||||
[[nodiscard]] inline QList<uint> toUcs4() const; // defined in qlist.h
|
||||
[[nodiscard]] inline QList<uint> toUcs4() const; // defined in qlist.h ### Qt 7 char32_t
|
||||
|
||||
[[nodiscard]] constexpr QChar at(qsizetype n) const noexcept { return (*this)[n]; }
|
||||
|
||||
|
@ -933,6 +933,7 @@ qsizetype erase_if(QList<T> &list, Predicate pred)
|
||||
return QtPrivate::sequential_erase_if(list, pred);
|
||||
}
|
||||
|
||||
// ### Qt 7 char32_t
|
||||
QList<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user