From 4aa38ca8a6f0c18097fac4c50ee3dab5f98f753e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= Date: Wed, 20 Nov 2024 14:25:59 +0100 Subject: [PATCH] Document that size is number of code units in QString::fromWCharArray Other functions that creates QString instances from buffers document that the size argument represents the number of characters to copy. This patch adds this statement to QString::fromWCharArray too, but makes it explicit that the size represents the number of code units. Change-Id: If3c0ebe299281a3c0ffc2d9e609b89df2578811d Reviewed-by: Nicholas Bennett (cherry picked from commit a315a9e70e69e36cef0e51058faad048773040e1) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qstring.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 6d66b578695..19e0d2d0f69 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -2410,9 +2410,10 @@ encoded in \1, and is converted to QString using the \2 function. /*! \fn QString QString::fromWCharArray(const wchar_t *string, qsizetype size) \since 4.2 - Returns a copy of the \a string, where the encoding of \a string depends on - the size of wchar. If wchar is 4 bytes, the \a string is interpreted as - UCS-4, if wchar is 2 bytes it is interpreted as UTF-16. + Reads the first \a size code units of the \c wchar_t array to whose start + \a string points, converting them to Unicode and returning the result as + a QString. The encoding used by \c wchar_t is assumed to be UCS-4 if the + type's size is four bytes or UTF-16 if its size is two bytes. If \a size is -1 (default), the \a string must be '\\0'-terminated.