summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/parse.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 4e3b8172ca41..2f0f908d4b7b 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -956,9 +956,14 @@ void SmParser::NextToken()
m_aCurToken.cMathChar = '\0';
m_aCurToken.nGroup = TG::NONE;
m_aCurToken.nLevel = 5;
- m_aCurToken.aText = m_aBufferString.copy( nRealStart, 1 );
- aRes.EndPos = nRealStart + 1;
+ // tdf#129372: we may have to deal with surrogate pairs
+ // (see https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates)
+ // in this case, we must read 2 sal_Unicode instead of 1
+ int nOffset(rtl::isSurrogate(m_aBufferString[nRealStart])? 2 : 1);
+ m_aCurToken.aText = m_aBufferString.copy( nRealStart, nOffset );
+
+ aRes.EndPos = nRealStart + nOffset;
}
if (TEND != m_aCurToken.eType)