diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2018-05-21 14:28:25 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-05-22 15:38:55 +0200 |
commit | 5dc52ee00102cbf4262805d6e8f338bf0a88f470 (patch) | |
tree | 65597ac113d7e69c7405a00f0a3008ebc710650c /i18npool/qa/cppunit | |
parent | 93aa646dab749c81d512644689bd8f9a9f752131 (diff) |
tdf#113694 Fix BreakIterator_CTL surrogate pairs
BreakIterator_CTL in the non CharacterIteratorMode::SKIPCELL mode did
not handle UTF-16 surrogate pairs at all, causing backspace to delete
lone surrogates which is really bad. Just copied the corresponding code
from BreakIterator_Unicode.
Additionally, BreakIterator_th was not correctly skipping non-Thai text
and always treating one character as Thai.
Change-Id: Ia379327e042ff602fc19a485c4cbd1a3683f9230
Reviewed-on: https://gerrit.libreoffice.org/54631
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'i18npool/qa/cppunit')
-rw-r--r-- | i18npool/qa/cppunit/test_breakiterator.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx index 552274864035..0c132acf3a43 100644 --- a/i18npool/qa/cppunit/test_breakiterator.cxx +++ b/i18npool/qa/cppunit/test_breakiterator.cxx @@ -919,6 +919,29 @@ void TestBreakIterator::testThai() } while (nPos > 0); } + + // tdf#113694 + { + const sal_Unicode NON_BMP[] = { 0xD800, 0xDC00 }; + OUString aTest(NON_BMP, SAL_N_ELEMENTS(NON_BMP)); + + sal_Int32 nDone=0; + sal_Int32 nPos; + + nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, + i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(SAL_N_ELEMENTS(NON_BMP)), nPos); + nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(NON_BMP), aLocale, + i18n::CharacterIteratorMode::SKIPCELL, 1, nDone); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(0), nPos); + + nPos = m_xBreak->nextCharacters(aTest, 0, aLocale, + i18n::CharacterIteratorMode::SKIPCHARACTER, 1, nDone); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(SAL_N_ELEMENTS(NON_BMP)), nPos); + nPos = m_xBreak->previousCharacters(aTest, SAL_N_ELEMENTS(NON_BMP), aLocale, + i18n::CharacterIteratorMode::SKIPCHARACTER, 1, nDone); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Should skip full surrogate pair", static_cast<sal_Int32>(0), nPos); + } } #ifdef TODO |