diff --git a/icu4c/source/common/ubrk.cpp b/icu4c/source/common/ubrk.cpp index ecbd52e40a1..610456d18ca 100644 --- a/icu4c/source/common/ubrk.cpp +++ b/icu4c/source/common/ubrk.cpp @@ -201,3 +201,10 @@ ubrk_countAvailable() return uloc_countAvailable(); } + + +U_CAPI UBool U_EXPORT2 +ubrk_isBoundary(UBreakIterator *bi, int32_t offset) +{ + return ((BreakIterator *)bi)->isBoundary(offset); +}; diff --git a/icu4c/source/common/unicode/ubrk.h b/icu4c/source/common/unicode/ubrk.h index 6e176e1c9b6..644ae26e336 100644 --- a/icu4c/source/common/unicode/ubrk.h +++ b/icu4c/source/common/unicode/ubrk.h @@ -387,4 +387,16 @@ ubrk_getAvailable(int32_t index); U_CAPI int32_t U_EXPORT2 ubrk_countAvailable(void); + +/** +* Returns true if the specfied position is a boundary position. As a side +* effect, leaves the iterator pointing to the first boundary position at +* or after "offset". +* @param bi The break iterator to use. +* @param offset the offset to check. +* @return True if "offset" is a boundary position. +*/ +U_CAPI UBool U_EXPORT2 +ubrk_isBoundary(UBreakIterator *bi, int32_t offset); + #endif diff --git a/icu4c/source/test/cintltst/cbiapts.c b/icu4c/source/test/cintltst/cbiapts.c index 67f2df2a705..15321ed33ef 100644 --- a/icu4c/source/test/cintltst/cbiapts.c +++ b/icu4c/source/test/cintltst/cbiapts.c @@ -49,6 +49,10 @@ static void TestBreakIteratorCAPI() uint8_t buffer [CLONETEST_ITERATOR_COUNT] [U_BRK_SAFECLONE_BUFFERSIZE]; int32_t bufferSize = U_BRK_SAFECLONE_BUFFERSIZE; + /* Note: the adjacent "" are concatenating strings, not adding a \" to the + string, which is probably what whoever wrote this intended. Don't fix, + because it would throw off the hard coded break positions in the following + tests. */ u_uastrcpy(text, "He's from Africa. ""Mr. Livingston, I presume?"" Yeah"); @@ -146,7 +150,16 @@ static void TestBreakIteratorCAPI() pos=ubrk_previous(word); log_verbose("%d \n", pos); - + if (ubrk_isBoundary(word, 2) != FALSE) { + log_err("error ubrk_isBoundary(word, 2) did not return FALSE\n"); + } + pos=ubrk_current(word); + if (pos != 4) { + log_err("error ubrk_current() != 4 after ubrk_isBoundary(word, 2)\n"); + } + if (ubrk_isBoundary(word, 4) != TRUE) { + log_err("error ubrk_isBoundary(word, 4) did not return TRUE\n"); + }