summaryrefslogtreecommitdiffstats
path: root/src/corelib/text
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-08 23:54:50 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-13 19:26:25 +0000
commitf5a56cf9bbaa05eabf2bb62ab881b9536bd554bf (patch)
tree1ccf3156f01f72bfa3485346215d3a88cf2c6754 /src/corelib/text
parent46fb39ef5ab5dff2d442ac382f0790afd265dc9d (diff)
QString: deprecate fromUtf16(ushort*)/fromUcs4(uint*)
... in favor of existing char16_t* and char32_t* versions. Swap the implementations around so the deprecated version is inline. [ChangeLog][QtCore][QString] The fromUtf16(const ushort*) and fromUcs4(const uint*) functions have been deprecated in favor of the char16_t and char32_t versions, resp. Change-Id: I94ff63ae98d190267da0b1c943d3d9c4e825ef10 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text')
-rw-r--r--src/corelib/text/qstring.cpp38
-rw-r--r--src/corelib/text/qstring.h16
2 files changed, 20 insertions, 34 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 5ee4102cdb..0682395ebf 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -5448,6 +5448,7 @@ QString QString::fromUtf8_helper(const char *str, int size)
}
/*!
+ \since 5.3
Returns a QString initialized with the first \a size characters
of the Unicode string \a unicode (ISO-10646-UTF-16 encoded).
@@ -5463,7 +5464,7 @@ QString QString::fromUtf8_helper(const char *str, int size)
\sa utf16(), setUtf16(), fromStdU16String()
*/
-QString QString::fromUtf16(const ushort *unicode, int size)
+QString QString::fromUtf16(const char16_t *unicode, int size)
{
if (!unicode)
return QString();
@@ -5476,39 +5477,22 @@ QString QString::fromUtf16(const ushort *unicode, int size)
}
/*!
- \fn QString QString::fromUtf16(const char16_t *str, int size)
- \since 5.3
-
- Returns a QString initialized with the first \a size characters
- of the Unicode string \a str (ISO-10646-UTF-16 encoded).
-
- If \a size is -1 (default), \a str must be \\0'-terminated.
-
- This function checks for a Byte Order Mark (BOM). If it is missing,
- host byte order is assumed.
-
- This function is slow compared to the other Unicode conversions.
- Use QString(const QChar *, int) or QString(const QChar *) if possible.
-
- QString makes a deep copy of the Unicode data.
+ \fn QString QString::fromUtf16(const ushort *str, int size)
+ \obsolete
- \sa utf16(), setUtf16(), fromStdU16String()
+ Use the \c char16_t overload.
*/
/*!
- \fn QString QString::fromUcs4(const char32_t *str, int size)
- \since 5.3
-
- Returns a QString initialized with the first \a size characters
- of the Unicode string \a str (ISO-10646-UCS-4 encoded).
-
- If \a size is -1 (default), \a str must be \\0'-terminated.
+ \fn QString QString::fromUcs4(const uint *str, int size)
+ \since 4.2
+ \obsolete
- \sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray(), fromStdU32String()
+ Use the \c char32_t overload instead.
*/
/*!
- \since 4.2
+ \since 5.3
Returns a QString initialized with the first \a size characters
of the Unicode string \a unicode (ISO-10646-UCS-4 encoded).
@@ -5517,7 +5501,7 @@ QString QString::fromUtf16(const ushort *unicode, int size)
\sa toUcs4(), fromUtf16(), utf16(), setUtf16(), fromWCharArray(), fromStdU32String()
*/
-QString QString::fromUcs4(const uint *unicode, int size)
+QString QString::fromUcs4(const char32_t *unicode, int size)
{
if (!unicode)
return QString();
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 229dc17a28..a7cafced31 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -720,15 +720,17 @@ public:
{ return str.isNull() ? QString() : fromUtf8(str.data(), qstrnlen(str.constData(), str.size())); }
static inline QString fromLocal8Bit(const QByteArray &str)
{ return str.isNull() ? QString() : fromLocal8Bit(str.data(), qstrnlen(str.constData(), str.size())); }
- static QString fromUtf16(const ushort *, int size = -1);
- static QString fromUcs4(const uint *, int size = -1);
+ static QString fromUtf16(const char16_t *, int size = -1);
+ static QString fromUcs4(const char32_t *, int size = -1);
static QString fromRawData(const QChar *, int size);
-#if defined(Q_COMPILER_UNICODE_STRINGS)
- static QString fromUtf16(const char16_t *str, int size = -1)
- { return fromUtf16(reinterpret_cast<const ushort *>(str), size); }
- static QString fromUcs4(const char32_t *str, int size = -1)
- { return fromUcs4(reinterpret_cast<const uint *>(str), size); }
+#if QT_DEPRECATED_SINCE(6, 0)
+ QT_DEPRECATED_VERSION_X_6_0("Use char16_t* overload.")
+ static QString fromUtf16(const ushort *str, int size = -1)
+ { return fromUtf16(reinterpret_cast<const char16_t *>(str), size); }
+ QT_DEPRECATED_VERSION_X_6_0("Use char32_t* overload.")
+ static QString fromUcs4(const uint *str, int size = -1)
+ { return fromUcs4(reinterpret_cast<const char32_t *>(str), size); }
#endif
inline int toWCharArray(wchar_t *array) const;