ubrk.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. ******************************************************************************
  5. * Copyright (C) 1996-2015, International Business Machines Corporation and others.
  6. * All Rights Reserved.
  7. ******************************************************************************
  8. */
  9. #ifndef UBRK_H
  10. #define UBRK_H
  11. #include "unicode/utypes.h"
  12. #include "unicode/uloc.h"
  13. #include "unicode/utext.h"
  14. #if U_SHOW_CPLUSPLUS_API
  15. #include "unicode/localpointer.h"
  16. #endif // U_SHOW_CPLUSPLUS_API
  17. /**
  18. * A text-break iterator.
  19. * For usage in C programs.
  20. */
  21. #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
  22. # define UBRK_TYPEDEF_UBREAK_ITERATOR
  23. /**
  24. * Opaque type representing an ICU Break iterator object.
  25. * @stable ICU 2.0
  26. */
  27. typedef struct UBreakIterator UBreakIterator;
  28. #endif
  29. #if !UCONFIG_NO_BREAK_ITERATION
  30. #include "unicode/parseerr.h"
  31. /**
  32. * \file
  33. * \brief C API: BreakIterator
  34. *
  35. * <h2> BreakIterator C API </h2>
  36. *
  37. * The BreakIterator C API defines methods for finding the location
  38. * of boundaries in text. Pointer to a UBreakIterator maintain a
  39. * current position and scan over text returning the index of characters
  40. * where boundaries occur.
  41. * <p>
  42. * Line boundary analysis determines where a text string can be broken
  43. * when line-wrapping. The mechanism correctly handles punctuation and
  44. * hyphenated words.
  45. * <p>
  46. * Note: The locale keyword "lb" can be used to modify line break
  47. * behavior according to the CSS level 3 line-break options, see
  48. * <http://dev.w3.org/csswg/css-text/#line-breaking>. For example:
  49. * "ja@lb=strict", "zh@lb=loose".
  50. * <p>
  51. * Sentence boundary analysis allows selection with correct
  52. * interpretation of periods within numbers and abbreviations, and
  53. * trailing punctuation marks such as quotation marks and parentheses.
  54. * <p>
  55. * Note: The locale keyword "ss" can be used to enable use of
  56. * segmentation suppression data (preventing breaks in English after
  57. * abbreviations such as "Mr." or "Est.", for example), as follows:
  58. * "en@ss=standard".
  59. * <p>
  60. * Word boundary analysis is used by search and replace functions, as
  61. * well as within text editing applications that allow the user to
  62. * select words with a double click. Word selection provides correct
  63. * interpretation of punctuation marks within and following
  64. * words. Characters that are not part of a word, such as symbols or
  65. * punctuation marks, have word-breaks on both sides.
  66. * <p>
  67. * Character boundary analysis identifies the boundaries of
  68. * "Extended Grapheme Clusters", which are groupings of codepoints
  69. * that should be treated as character-like units for many text operations.
  70. * Please see Unicode Standard Annex #29, Unicode Text Segmentation,
  71. * http://www.unicode.org/reports/tr29/ for additional information
  72. * on grapheme clusters and guidelines on their use.
  73. * <p>
  74. * Title boundary analysis locates all positions,
  75. * typically starts of words, that should be set to Title Case
  76. * when title casing the text.
  77. * <p>
  78. * The text boundary positions are found according to the rules
  79. * described in Unicode Standard Annex #29, Text Boundaries, and
  80. * Unicode Standard Annex #14, Line Breaking Properties. These
  81. * are available at http://www.unicode.org/reports/tr14/ and
  82. * http://www.unicode.org/reports/tr29/.
  83. * <p>
  84. * In addition to the plain C API defined in this header file, an
  85. * object oriented C++ API with equivalent functionality is defined in the
  86. * file brkiter.h.
  87. * <p>
  88. * Code snippets illustrating the use of the Break Iterator APIs
  89. * are available in the ICU User Guide,
  90. * https://unicode-org.github.io/icu/userguide/boundaryanalysis/
  91. * and in the sample program icu/source/samples/break/break.cpp
  92. */
  93. /** The possible types of text boundaries. @stable ICU 2.0 */
  94. typedef enum UBreakIteratorType {
  95. /** Character breaks @stable ICU 2.0 */
  96. UBRK_CHARACTER = 0,
  97. /** Word breaks @stable ICU 2.0 */
  98. UBRK_WORD = 1,
  99. /** Line breaks @stable ICU 2.0 */
  100. UBRK_LINE = 2,
  101. /** Sentence breaks @stable ICU 2.0 */
  102. UBRK_SENTENCE = 3,
  103. #ifndef U_HIDE_DEPRECATED_API
  104. /**
  105. * Title Case breaks
  106. * The iterator created using this type locates title boundaries as described for
  107. * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
  108. * please use Word Boundary iterator.
  109. *
  110. * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later.
  111. */
  112. UBRK_TITLE = 4,
  113. /**
  114. * One more than the highest normal UBreakIteratorType value.
  115. * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
  116. */
  117. UBRK_COUNT = 5
  118. #endif // U_HIDE_DEPRECATED_API
  119. } UBreakIteratorType;
  120. /** Value indicating all text boundaries have been returned.
  121. * @stable ICU 2.0
  122. */
  123. #define UBRK_DONE ((int32_t) -1)
  124. /**
  125. * Enum constants for the word break tags returned by
  126. * getRuleStatus(). A range of values is defined for each category of
  127. * word, to allow for further subdivisions of a category in future releases.
  128. * Applications should check for tag values falling within the range, rather
  129. * than for single individual values.
  130. *
  131. * The numeric values of all of these constants are stable (will not change).
  132. *
  133. * @stable ICU 2.2
  134. */
  135. typedef enum UWordBreak {
  136. /** Tag value for "words" that do not fit into any of other categories.
  137. * Includes spaces and most punctuation. */
  138. UBRK_WORD_NONE = 0,
  139. /** Upper bound for tags for uncategorized words. */
  140. UBRK_WORD_NONE_LIMIT = 100,
  141. /** Tag value for words that appear to be numbers, lower limit. */
  142. UBRK_WORD_NUMBER = 100,
  143. /** Tag value for words that appear to be numbers, upper limit. */
  144. UBRK_WORD_NUMBER_LIMIT = 200,
  145. /** Tag value for words that contain letters, excluding
  146. * hiragana, katakana or ideographic characters, lower limit. */
  147. UBRK_WORD_LETTER = 200,
  148. /** Tag value for words containing letters, upper limit */
  149. UBRK_WORD_LETTER_LIMIT = 300,
  150. /** Tag value for words containing kana characters, lower limit */
  151. UBRK_WORD_KANA = 300,
  152. /** Tag value for words containing kana characters, upper limit */
  153. UBRK_WORD_KANA_LIMIT = 400,
  154. /** Tag value for words containing ideographic characters, lower limit */
  155. UBRK_WORD_IDEO = 400,
  156. /** Tag value for words containing ideographic characters, upper limit */
  157. UBRK_WORD_IDEO_LIMIT = 500
  158. } UWordBreak;
  159. /**
  160. * Enum constants for the line break tags returned by getRuleStatus().
  161. * A range of values is defined for each category of
  162. * word, to allow for further subdivisions of a category in future releases.
  163. * Applications should check for tag values falling within the range, rather
  164. * than for single individual values.
  165. *
  166. * The numeric values of all of these constants are stable (will not change).
  167. *
  168. * @stable ICU 2.8
  169. */
  170. typedef enum ULineBreakTag {
  171. /** Tag value for soft line breaks, positions at which a line break
  172. * is acceptable but not required */
  173. UBRK_LINE_SOFT = 0,
  174. /** Upper bound for soft line breaks. */
  175. UBRK_LINE_SOFT_LIMIT = 100,
  176. /** Tag value for a hard, or mandatory line break */
  177. UBRK_LINE_HARD = 100,
  178. /** Upper bound for hard line breaks. */
  179. UBRK_LINE_HARD_LIMIT = 200
  180. } ULineBreakTag;
  181. /**
  182. * Enum constants for the sentence break tags returned by getRuleStatus().
  183. * A range of values is defined for each category of
  184. * sentence, to allow for further subdivisions of a category in future releases.
  185. * Applications should check for tag values falling within the range, rather
  186. * than for single individual values.
  187. *
  188. * The numeric values of all of these constants are stable (will not change).
  189. *
  190. * @stable ICU 2.8
  191. */
  192. typedef enum USentenceBreakTag {
  193. /** Tag value for for sentences ending with a sentence terminator
  194. * ('.', '?', '!', etc.) character, possibly followed by a
  195. * hard separator (CR, LF, PS, etc.)
  196. */
  197. UBRK_SENTENCE_TERM = 0,
  198. /** Upper bound for tags for sentences ended by sentence terminators. */
  199. UBRK_SENTENCE_TERM_LIMIT = 100,
  200. /** Tag value for for sentences that do not contain an ending
  201. * sentence terminator ('.', '?', '!', etc.) character, but
  202. * are ended only by a hard separator (CR, LF, PS, etc.) or end of input.
  203. */
  204. UBRK_SENTENCE_SEP = 100,
  205. /** Upper bound for tags for sentences ended by a separator. */
  206. UBRK_SENTENCE_SEP_LIMIT = 200
  207. /** Tag value for a hard, or mandatory line break */
  208. } USentenceBreakTag;
  209. /**
  210. * Open a new UBreakIterator for locating text boundaries for a specified locale.
  211. * A UBreakIterator may be used for detecting character, line, word,
  212. * and sentence breaks in text.
  213. * @param type The type of UBreakIterator to open: one of UBRK_CHARACTER, UBRK_WORD,
  214. * UBRK_LINE, UBRK_SENTENCE
  215. * @param locale The locale specifying the text-breaking conventions. Note that
  216. * locale keys such as "lb" and "ss" may be used to modify text break behavior,
  217. * see general discussion of BreakIterator C API.
  218. * @param text The text to be iterated over. May be null, in which case ubrk_setText() is
  219. * used to specify the text to be iterated.
  220. * @param textLength The number of characters in text, or -1 if null-terminated.
  221. * @param status A UErrorCode to receive any errors.
  222. * @return A UBreakIterator for the specified locale.
  223. * @see ubrk_openRules
  224. * @stable ICU 2.0
  225. */
  226. U_CAPI UBreakIterator* U_EXPORT2
  227. ubrk_open(UBreakIteratorType type,
  228. const char *locale,
  229. const UChar *text,
  230. int32_t textLength,
  231. UErrorCode *status);
  232. /**
  233. * Open a new UBreakIterator for locating text boundaries using specified breaking rules.
  234. * The rule syntax is ... (TBD)
  235. * @param rules A set of rules specifying the text breaking conventions.
  236. * @param rulesLength The number of characters in rules, or -1 if null-terminated.
  237. * @param text The text to be iterated over. May be null, in which case ubrk_setText() is
  238. * used to specify the text to be iterated.
  239. * @param textLength The number of characters in text, or -1 if null-terminated.
  240. * @param parseErr Receives position and context information for any syntax errors
  241. * detected while parsing the rules.
  242. * @param status A UErrorCode to receive any errors.
  243. * @return A UBreakIterator for the specified rules.
  244. * @see ubrk_open
  245. * @stable ICU 2.2
  246. */
  247. U_CAPI UBreakIterator* U_EXPORT2
  248. ubrk_openRules(const UChar *rules,
  249. int32_t rulesLength,
  250. const UChar *text,
  251. int32_t textLength,
  252. UParseError *parseErr,
  253. UErrorCode *status);
  254. /**
  255. * Open a new UBreakIterator for locating text boundaries using precompiled binary rules.
  256. * Opening a UBreakIterator this way is substantially faster than using ubrk_openRules.
  257. * Binary rules may be obtained using ubrk_getBinaryRules. The compiled rules are not
  258. * compatible across different major versions of ICU, nor across platforms of different
  259. * endianness or different base character set family (ASCII vs EBCDIC).
  260. * @param binaryRules A set of compiled binary rules specifying the text breaking
  261. * conventions. Ownership of the storage containing the compiled
  262. * rules remains with the caller of this function. The compiled
  263. * rules must not be modified or deleted during the life of the
  264. * break iterator.
  265. * @param rulesLength The length of binaryRules in bytes; must be >= 0.
  266. * @param text The text to be iterated over. May be null, in which case
  267. * ubrk_setText() is used to specify the text to be iterated.
  268. * @param textLength The number of characters in text, or -1 if null-terminated.
  269. * @param status Pointer to UErrorCode to receive any errors.
  270. * @return UBreakIterator for the specified rules.
  271. * @see ubrk_getBinaryRules
  272. * @stable ICU 59
  273. */
  274. U_CAPI UBreakIterator* U_EXPORT2
  275. ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
  276. const UChar * text, int32_t textLength,
  277. UErrorCode * status);
  278. #ifndef U_HIDE_DEPRECATED_API
  279. /**
  280. * Thread safe cloning operation
  281. * @param bi iterator to be cloned
  282. * @param stackBuffer <em>Deprecated functionality as of ICU 52, use NULL.</em><br>
  283. * user allocated space for the new clone. If NULL new memory will be allocated.
  284. * If buffer is not large enough, new memory will be allocated.
  285. * Clients can use the U_BRK_SAFECLONE_BUFFERSIZE.
  286. * @param pBufferSize <em>Deprecated functionality as of ICU 52, use NULL or 1.</em><br>
  287. * pointer to size of allocated space.
  288. * If *pBufferSize == 0, a sufficient size for use in cloning will
  289. * be returned ('pre-flighting')
  290. * If *pBufferSize is not enough for a stack-based safe clone,
  291. * new memory will be allocated.
  292. * @param status to indicate whether the operation went on smoothly or there were errors
  293. * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used
  294. * if pBufferSize != NULL and any allocations were necessary
  295. * @return pointer to the new clone
  296. * @deprecated ICU 69 Use ubrk_clone() instead.
  297. */
  298. U_DEPRECATED UBreakIterator * U_EXPORT2
  299. ubrk_safeClone(
  300. const UBreakIterator *bi,
  301. void *stackBuffer,
  302. int32_t *pBufferSize,
  303. UErrorCode *status);
  304. #endif /* U_HIDE_DEPRECATED_API */
  305. /**
  306. * Thread safe cloning operation.
  307. * @param bi iterator to be cloned
  308. * @param status to indicate whether the operation went on smoothly or there were errors
  309. * @return pointer to the new clone
  310. * @stable ICU 69
  311. */
  312. U_CAPI UBreakIterator * U_EXPORT2
  313. ubrk_clone(const UBreakIterator *bi,
  314. UErrorCode *status);
  315. #ifndef U_HIDE_DEPRECATED_API
  316. /**
  317. * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone().
  318. * @deprecated ICU 52. Do not rely on ubrk_safeClone() cloning into any provided buffer.
  319. */
  320. #define U_BRK_SAFECLONE_BUFFERSIZE 1
  321. #endif /* U_HIDE_DEPRECATED_API */
  322. /**
  323. * Close a UBreakIterator.
  324. * Once closed, a UBreakIterator may no longer be used.
  325. * @param bi The break iterator to close.
  326. * @stable ICU 2.0
  327. */
  328. U_CAPI void U_EXPORT2
  329. ubrk_close(UBreakIterator *bi);
  330. #if U_SHOW_CPLUSPLUS_API
  331. U_NAMESPACE_BEGIN
  332. /**
  333. * \class LocalUBreakIteratorPointer
  334. * "Smart pointer" class, closes a UBreakIterator via ubrk_close().
  335. * For most methods see the LocalPointerBase base class.
  336. *
  337. * @see LocalPointerBase
  338. * @see LocalPointer
  339. * @stable ICU 4.4
  340. */
  341. U_DEFINE_LOCAL_OPEN_POINTER(LocalUBreakIteratorPointer, UBreakIterator, ubrk_close);
  342. U_NAMESPACE_END
  343. #endif
  344. /**
  345. * Sets an existing iterator to point to a new piece of text.
  346. * The break iterator retains a pointer to the supplied text.
  347. * The caller must not modify or delete the text while the BreakIterator
  348. * retains the reference.
  349. *
  350. * @param bi The iterator to use
  351. * @param text The text to be set
  352. * @param textLength The length of the text
  353. * @param status The error code
  354. * @stable ICU 2.0
  355. */
  356. U_CAPI void U_EXPORT2
  357. ubrk_setText(UBreakIterator* bi,
  358. const UChar* text,
  359. int32_t textLength,
  360. UErrorCode* status);
  361. /**
  362. * Sets an existing iterator to point to a new piece of text.
  363. *
  364. * All index positions returned by break iterator functions are
  365. * native indices from the UText. For example, when breaking UTF-8
  366. * encoded text, the break positions returned by \ref ubrk_next, \ref ubrk_previous, etc.
  367. * will be UTF-8 string indices, not UTF-16 positions.
  368. *
  369. * @param bi The iterator to use
  370. * @param text The text to be set.
  371. * This function makes a shallow clone of the supplied UText. This means
  372. * that the caller is free to immediately close or otherwise reuse the
  373. * UText that was passed as a parameter, but that the underlying text itself
  374. * must not be altered while being referenced by the break iterator.
  375. * @param status The error code
  376. * @stable ICU 3.4
  377. */
  378. U_CAPI void U_EXPORT2
  379. ubrk_setUText(UBreakIterator* bi,
  380. UText* text,
  381. UErrorCode* status);
  382. /**
  383. * Determine the most recently-returned text boundary.
  384. *
  385. * @param bi The break iterator to use.
  386. * @return The character index most recently returned by \ref ubrk_next, \ref ubrk_previous,
  387. * \ref ubrk_first, or \ref ubrk_last.
  388. * @stable ICU 2.0
  389. */
  390. U_CAPI int32_t U_EXPORT2
  391. ubrk_current(const UBreakIterator *bi);
  392. /**
  393. * Advance the iterator to the boundary following the current boundary.
  394. *
  395. * @param bi The break iterator to use.
  396. * @return The character index of the next text boundary, or UBRK_DONE
  397. * if all text boundaries have been returned.
  398. * @see ubrk_previous
  399. * @stable ICU 2.0
  400. */
  401. U_CAPI int32_t U_EXPORT2
  402. ubrk_next(UBreakIterator *bi);
  403. /**
  404. * Set the iterator position to the boundary preceding the current boundary.
  405. *
  406. * @param bi The break iterator to use.
  407. * @return The character index of the preceding text boundary, or UBRK_DONE
  408. * if all text boundaries have been returned.
  409. * @see ubrk_next
  410. * @stable ICU 2.0
  411. */
  412. U_CAPI int32_t U_EXPORT2
  413. ubrk_previous(UBreakIterator *bi);
  414. /**
  415. * Set the iterator position to zero, the start of the text being scanned.
  416. * @param bi The break iterator to use.
  417. * @return The new iterator position (zero).
  418. * @see ubrk_last
  419. * @stable ICU 2.0
  420. */
  421. U_CAPI int32_t U_EXPORT2
  422. ubrk_first(UBreakIterator *bi);
  423. /**
  424. * Set the iterator position to the index immediately <EM>beyond</EM> the last character in the text being scanned.
  425. * This is not the same as the last character.
  426. * @param bi The break iterator to use.
  427. * @return The character offset immediately <EM>beyond</EM> the last character in the
  428. * text being scanned.
  429. * @see ubrk_first
  430. * @stable ICU 2.0
  431. */
  432. U_CAPI int32_t U_EXPORT2
  433. ubrk_last(UBreakIterator *bi);
  434. /**
  435. * Set the iterator position to the first boundary preceding the specified offset.
  436. * The new position is always smaller than offset, or UBRK_DONE.
  437. * @param bi The break iterator to use.
  438. * @param offset The offset to begin scanning.
  439. * @return The text boundary preceding offset, or UBRK_DONE.
  440. * @see ubrk_following
  441. * @stable ICU 2.0
  442. */
  443. U_CAPI int32_t U_EXPORT2
  444. ubrk_preceding(UBreakIterator *bi,
  445. int32_t offset);
  446. /**
  447. * Advance the iterator to the first boundary following the specified offset.
  448. * The value returned is always greater than offset, or UBRK_DONE.
  449. * @param bi The break iterator to use.
  450. * @param offset The offset to begin scanning.
  451. * @return The text boundary following offset, or UBRK_DONE.
  452. * @see ubrk_preceding
  453. * @stable ICU 2.0
  454. */
  455. U_CAPI int32_t U_EXPORT2
  456. ubrk_following(UBreakIterator *bi,
  457. int32_t offset);
  458. /**
  459. * Get a locale for which text breaking information is available.
  460. * A UBreakIterator in a locale returned by this function will perform the correct
  461. * text breaking for the locale.
  462. * @param index The index of the desired locale.
  463. * @return A locale for which number text breaking information is available, or 0 if none.
  464. * @see ubrk_countAvailable
  465. * @stable ICU 2.0
  466. */
  467. U_CAPI const char* U_EXPORT2
  468. ubrk_getAvailable(int32_t index);
  469. /**
  470. * Determine how many locales have text breaking information available.
  471. * This function is most useful as determining the loop ending condition for
  472. * calls to \ref ubrk_getAvailable.
  473. * @return The number of locales for which text breaking information is available.
  474. * @see ubrk_getAvailable
  475. * @stable ICU 2.0
  476. */
  477. U_CAPI int32_t U_EXPORT2
  478. ubrk_countAvailable(void);
  479. /**
  480. * Returns true if the specified position is a boundary position. As a side
  481. * effect, leaves the iterator pointing to the first boundary position at
  482. * or after "offset".
  483. * @param bi The break iterator to use.
  484. * @param offset the offset to check.
  485. * @return True if "offset" is a boundary position.
  486. * @stable ICU 2.0
  487. */
  488. U_CAPI UBool U_EXPORT2
  489. ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
  490. /**
  491. * Return the status from the break rule that determined the most recently
  492. * returned break position. The values appear in the rule source
  493. * within brackets, {123}, for example. For rules that do not specify a
  494. * status, a default value of 0 is returned.
  495. * <p>
  496. * For word break iterators, the possible values are defined in enum UWordBreak.
  497. * @stable ICU 2.2
  498. */
  499. U_CAPI int32_t U_EXPORT2
  500. ubrk_getRuleStatus(UBreakIterator *bi);
  501. /**
  502. * Get the statuses from the break rules that determined the most recently
  503. * returned break position. The values appear in the rule source
  504. * within brackets, {123}, for example. The default status value for rules
  505. * that do not explicitly provide one is zero.
  506. * <p>
  507. * For word break iterators, the possible values are defined in enum UWordBreak.
  508. * @param bi The break iterator to use
  509. * @param fillInVec an array to be filled in with the status values.
  510. * @param capacity the length of the supplied vector. A length of zero causes
  511. * the function to return the number of status values, in the
  512. * normal way, without attempting to store any values.
  513. * @param status receives error codes.
  514. * @return The number of rule status values from rules that determined
  515. * the most recent boundary returned by the break iterator.
  516. * @stable ICU 3.0
  517. */
  518. U_CAPI int32_t U_EXPORT2
  519. ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status);
  520. /**
  521. * Return the locale of the break iterator. You can choose between the valid and
  522. * the actual locale.
  523. * @param bi break iterator
  524. * @param type locale type (valid or actual)
  525. * @param status error code
  526. * @return locale string
  527. * @stable ICU 2.8
  528. */
  529. U_CAPI const char* U_EXPORT2
  530. ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status);
  531. /**
  532. * Set the subject text string upon which the break iterator is operating
  533. * without changing any other aspect of the state.
  534. * The new and previous text strings must have the same content.
  535. *
  536. * This function is intended for use in environments where ICU is operating on
  537. * strings that may move around in memory. It provides a mechanism for notifying
  538. * ICU that the string has been relocated, and providing a new UText to access the
  539. * string in its new position.
  540. *
  541. * Note that the break iterator never copies the underlying text
  542. * of a string being processed, but always operates directly on the original text
  543. * provided by the user. Refreshing simply drops the references to the old text
  544. * and replaces them with references to the new.
  545. *
  546. * Caution: this function is normally used only by very specialized
  547. * system-level code. One example use case is with garbage collection
  548. * that moves the text in memory.
  549. *
  550. * @param bi The break iterator.
  551. * @param text The new (moved) text string.
  552. * @param status Receives errors detected by this function.
  553. *
  554. * @stable ICU 49
  555. */
  556. U_CAPI void U_EXPORT2
  557. ubrk_refreshUText(UBreakIterator *bi,
  558. UText *text,
  559. UErrorCode *status);
  560. /**
  561. * Get a compiled binary version of the rules specifying the behavior of a UBreakIterator.
  562. * The binary rules may be used with ubrk_openBinaryRules to open a new UBreakIterator
  563. * more quickly than using ubrk_openRules. The compiled rules are not compatible across
  564. * different major versions of ICU, nor across platforms of different endianness or
  565. * different base character set family (ASCII vs EBCDIC). Supports preflighting (with
  566. * binaryRules=NULL and rulesCapacity=0) to get the rules length without copying them to
  567. * the binaryRules buffer. However, whether preflighting or not, if the actual length
  568. * is greater than INT32_MAX, then the function returns 0 and sets *status to
  569. * U_INDEX_OUTOFBOUNDS_ERROR.
  570. * @param bi The break iterator to use.
  571. * @param binaryRules Buffer to receive the compiled binary rules; set to NULL for
  572. * preflighting.
  573. * @param rulesCapacity Capacity (in bytes) of the binaryRules buffer; set to 0 for
  574. * preflighting. Must be >= 0.
  575. * @param status Pointer to UErrorCode to receive any errors, such as
  576. * U_BUFFER_OVERFLOW_ERROR, U_INDEX_OUTOFBOUNDS_ERROR, or
  577. * U_ILLEGAL_ARGUMENT_ERROR.
  578. * @return The actual byte length of the binary rules, if <= INT32_MAX;
  579. * otherwise 0. If not preflighting and this is larger than
  580. * rulesCapacity, *status will be set to an error.
  581. * @see ubrk_openBinaryRules
  582. * @stable ICU 59
  583. */
  584. U_CAPI int32_t U_EXPORT2
  585. ubrk_getBinaryRules(UBreakIterator *bi,
  586. uint8_t * binaryRules, int32_t rulesCapacity,
  587. UErrorCode * status);
  588. #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
  589. #endif