diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-12-18 20:23:11 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-12-20 11:13:22 +0100 |
commit | a2ddd96ac8b7657c2ef64f2a8f51db5cd8a8d96a (patch) | |
tree | d118809cc7b6203f9e48c717313dd472cb5d7518 /src/corelib/text/qstringview.h | |
parent | 556712f511a02ff8101e648d2e6f0090231d4f3d (diff) |
Introduce QString(View)::isValidUtf16
QString(View)s can be built or manipulated in ways that make them
contain/refer to improperly encoded UTF-16 data. Problem is,
we don't have public APIs to check whether a string contains
valid UTF-16. This knowledge is precious if the string is to be fed in
algorithms, regular expressions, etc. that expect validated input
(e.g. QRegularExpression can be faster if it can assume valid UTF-16,
otherwise it has to employ extra checks).
Add a function that does the validation.
[ChangeLog][QtCore][QStringView] Added QStringView::isValidUtf16.
[ChangeLog][QtCore][QString] Added QString::isValidUtf16.
Change-Id: Idd699183f6ec08013046c76c6a5a7c524b6c6fbc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r-- | src/corelib/text/qstringview.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 4ab4d2570f..06391ffef4 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -294,6 +294,8 @@ public: Q_REQUIRED_RESULT bool isRightToLeft() const noexcept { return QtPrivate::isRightToLeft(*this); } + Q_REQUIRED_RESULT bool isValidUtf16() const noexcept + { return QtPrivate::isValidUtf16(*this); } Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h |