summaryrefslogtreecommitdiff
path: root/include/tools/inetmime.hxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-12-24 15:25:52 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-12-24 21:42:08 +0100
commit8b333c76945960fc62a01829666ba234f59a6d94 (patch)
tree4393e992348ac00faf04256d5f51f9e3aea2e4e6 /include/tools/inetmime.hxx
parentfd4acfaca9fc012313f03f46e927add6feb6a553 (diff)
Use rtl functions instead of own surrogate checking/combining
Change-Id: I3eb05d8f5b0761bc3b672d4c855eb469f8cc1a29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127375 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'include/tools/inetmime.hxx')
-rw-r--r--include/tools/inetmime.hxx14
1 files changed, 5 insertions, 9 deletions
diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index ce0469fa131a..a3c7de49690c 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -227,16 +227,12 @@ inline int INetMIME::getHexWeight(sal_uInt32 nChar)
inline sal_uInt32 INetMIME::getUTF32Character(const sal_Unicode *& rBegin,
const sal_Unicode * pEnd)
{
- DBG_ASSERT(rBegin && rBegin < pEnd,
+ assert(rBegin && rBegin < pEnd &&
"INetMIME::getUTF32Character(): Bad sequence");
- if (rBegin + 1 < pEnd && rBegin[0] >= 0xD800 && rBegin[0] <= 0xDBFF
- && rBegin[1] >= 0xDC00 && rBegin[1] <= 0xDFFF)
- {
- sal_uInt32 nUTF32 = sal_uInt32(*rBegin++ & 0x3FF) << 10;
- return (nUTF32 | (*rBegin++ & 0x3FF)) + 0x10000;
- }
- else
- return *rBegin++;
+ sal_uInt32 nUTF32 = *rBegin++;
+ if (rBegin < pEnd && rtl::isHighSurrogate(nUTF32) && rtl::isLowSurrogate(rBegin[0]))
+ nUTF32 = rtl::combineSurrogates(nUTF32, *rBegin++);
+ return nUTF32;
}