summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i18npool/qa/cppunit/test_breakiterator.cxx19
-rw-r--r--i18npool/source/breakiterator/xdictionary.cxx6
2 files changed, 22 insertions, 3 deletions
diff --git a/i18npool/qa/cppunit/test_breakiterator.cxx b/i18npool/qa/cppunit/test_breakiterator.cxx
index 41e40779de88..b4174bae17d8 100644
--- a/i18npool/qa/cppunit/test_breakiterator.cxx
+++ b/i18npool/qa/cppunit/test_breakiterator.cxx
@@ -44,7 +44,7 @@ public:
#endif
void testKhmer();
void testJapanese();
-
+ void testChinese();
CPPUNIT_TEST_SUITE(TestBreakIterator);
CPPUNIT_TEST(testLineBreaking);
CPPUNIT_TEST(testGraphemeIteration);
@@ -60,6 +60,7 @@ public:
CPPUNIT_TEST(testKhmer);
#endif
CPPUNIT_TEST(testJapanese);
+ CPPUNIT_TEST(testChinese);
CPPUNIT_TEST_SUITE_END();
private:
uno::Reference<i18n::XBreakIterator> m_xBreak;
@@ -909,6 +910,22 @@ void TestBreakIterator::testJapanese()
}
}
+void TestBreakIterator::testChinese()
+{
+ lang::Locale aLocale;
+ aLocale.Language = "zh";
+ aLocale.Country = "CN";
+ i18n::Boundary aBounds;
+
+ {
+ const sal_Unicode CHINESE[] = { 0x6A35, 0x6A30, 0x69FE, 0x8919, 0xD867, 0xDEDB };
+
+ OUString aTest(CHINESE, SAL_N_ELEMENTS(CHINESE));
+ aBounds = m_xBreak->getWordBoundary(aTest, 4, aLocale,
+ i18n::WordType::DICTIONARY_WORD, true);
+ CPPUNIT_ASSERT(aBounds.startPos == 4 && aBounds.endPos == 6);
+ }
+}
void TestBreakIterator::setUp()
{
BootstrapFixtureBase::setUp();
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx
index 72da09f87629..3b43fa31e4e2 100644
--- a/i18npool/source/breakiterator/xdictionary.cxx
+++ b/i18npool/source/breakiterator/xdictionary.cxx
@@ -383,9 +383,11 @@ Boundary xdictionary::getWordBoundary(const OUString& rText, sal_Int32 anyPos, s
if (u_isWhitespace(ch))
i--;
}
+
boundary.endPos = boundary.startPos;
- rText.iterateCodePoints(&boundary.endPos, aCache.wordboundary[i]);
- rText.iterateCodePoints(&boundary.startPos, aCache.wordboundary[i-1]);
+ boundary.endPos += aCache.wordboundary[i];
+ boundary.startPos += aCache.wordboundary[i-1];
+
} else {
boundary.startPos = anyPos;
if (anyPos < len) rText.iterateCodePoints(&anyPos, 1);