summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-12-11 12:53:26 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-12-11 12:21:57 +0100
commit21154ea8c450f9f5568b32123d34a20e498a9290 (patch)
tree2c4650bd7303153e32105524264666512657dfc3 /svtools
parent692bc46b25db61176b4ced7b7beffeca7d55068e (diff)
tdf#146173: combine non-BMP characters' surrogates correctly
Change-Id: Ib3af1f9e461f133d2f5b09b9db4fb87c1ede0b9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126658 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/svrtf/svparser.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx
index 0fec7a97097e..dd5068976ff7 100644
--- a/svtools/source/svrtf/svparser.cxx
+++ b/svtools/source/svrtf/svparser.cxx
@@ -247,7 +247,27 @@ sal_uInt32 SvParser<T>::GetNextChar()
rInput.ReadUtf16(cUC);
bErr = !rInput.good();
if( !bErr )
+ {
c = cUC;
+ if (rtl::isHighSurrogate(cUC))
+ {
+ const sal_uInt64 nPos = rInput.Tell();
+ rInput.ReadUtf16(cUC);
+ bErr = !rInput.good();
+ if (!bErr)
+ {
+ if (rtl::isLowSurrogate(cUC))
+ c = rtl::combineSurrogates(c, cUC);
+ else
+ rInput.Seek(nPos); // process lone high surrogate
+ }
+ else
+ {
+ bErr = false; // process lone high surrogate
+ rInput.Seek(nPos); // maybe step 1 byte back
+ }
+ }
+ }
}
else
{