ubrk.h 24 KB

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