From 2a9a7672e253aab38259092fc6d2ec24a3154212 Mon Sep 17 00:00:00 2001 From: sunyaozu Date: Fri, 25 Apr 2025 10:49:09 +0800 Subject: [PATCH] add ubrk_setUText interface Signed-off-by: sunyaozu --- third_party/icu4c/libicu.ndk.json | 4 ++++ third_party/icu4c/ndk_headers/unicode/ubrk.h | 23 ++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/third_party/icu4c/libicu.ndk.json b/third_party/icu4c/libicu.ndk.json index 40397f0531..42149b48ee 100644 --- a/third_party/icu4c/libicu.ndk.json +++ b/third_party/icu4c/libicu.ndk.json @@ -187,6 +187,10 @@ "first_introduced": "12", "name":"ubrk_setText" }, + { + "first_introduced": "20", + "name":"ubrk_setUText" + }, { "first_introduced": "12", "name":"ubrk_current" diff --git a/third_party/icu4c/ndk_headers/unicode/ubrk.h b/third_party/icu4c/ndk_headers/unicode/ubrk.h index 9724bcf569..98a27959a3 100644 --- a/third_party/icu4c/ndk_headers/unicode/ubrk.h +++ b/third_party/icu4c/ndk_headers/unicode/ubrk.h @@ -12,6 +12,7 @@ #include "unicode/utypes.h" #include "unicode/uloc.h" +#include "unicode/utext.h" #if U_SHOW_CPLUSPLUS_API #include "unicode/localpointer.h" @@ -338,6 +339,28 @@ ubrk_setText(UBreakIterator* bi, int32_t textLength, UErrorCode* status); +/** + * Sets an existing iterator to point to a new piece of text. + * + * All index positions returned by break iterator functions are + * native indices from the UText. For example, when breaking UTF-8 + * encoded text, the break positions returned by \ref ubrk_next, \ref ubrk_previous, etc. + * will be UTF-8 string indices, not UTF-16 positions. + * + * @param bi The iterator to use + * @param text The text to be set. + * This function makes a shallow clone of the supplied UText. This means + * that the caller is free to immediately close or otherwise reuse the + * UText that was passed as a parameter, but that the underlying text itself + * must not be altered while being referenced by the break iterator. + * @param status The error code + * @stable ICU 3.4 + */ +U_CAPI void U_EXPORT2 +ubrk_setUText(UBreakIterator* bi, + UText* text, + UErrorCode* status); + /** * Determine the most recently-returned text boundary. * -- Gitee