Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/ubrk.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 ******************************************************************************
0005 * Copyright (C) 1996-2015, International Business Machines Corporation and others.
0006 * All Rights Reserved.
0007 ******************************************************************************
0008 */
0009 
0010 #ifndef UBRK_H
0011 #define UBRK_H
0012 
0013 #include "unicode/utypes.h"
0014 #include "unicode/uloc.h"
0015 #include "unicode/utext.h"
0016 
0017 #if U_SHOW_CPLUSPLUS_API
0018 #include "unicode/localpointer.h"
0019 #endif   // U_SHOW_CPLUSPLUS_API
0020 
0021 /**
0022  * A text-break iterator.
0023  *  For usage in C programs.
0024  */
0025 #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
0026 #   define UBRK_TYPEDEF_UBREAK_ITERATOR
0027     /**
0028      *  Opaque type representing an ICU Break iterator object.
0029      *  @stable ICU 2.0
0030      */
0031     typedef struct UBreakIterator UBreakIterator;
0032 #endif
0033 
0034 #if !UCONFIG_NO_BREAK_ITERATION
0035 
0036 #include "unicode/parseerr.h"
0037 
0038 /**
0039  * \file
0040  * \brief C API: BreakIterator
0041  *
0042  * <h2> BreakIterator C API </h2>
0043  *
0044  * The BreakIterator C API defines  methods for finding the location
0045  * of boundaries in text. Pointer to a UBreakIterator maintain a
0046  * current position and scan over text returning the index of characters
0047  * where boundaries occur.
0048  * <p>
0049  * Line boundary analysis determines where a text string can be broken
0050  * when line-wrapping. The mechanism correctly handles punctuation and
0051  * hyphenated words.
0052  * <p>
0053  * Note: The locale keyword "lb" can be used to modify line break
0054  * behavior according to the CSS level 3 line-break options, see
0055  * <http://dev.w3.org/csswg/css-text/#line-breaking>. For example:
0056  * "ja@lb=strict", "zh@lb=loose".
0057  * <p>
0058  * Sentence boundary analysis allows selection with correct
0059  * interpretation of periods within numbers and abbreviations, and
0060  * trailing punctuation marks such as quotation marks and parentheses.
0061  * <p>
0062  * Note: The locale keyword "ss" can be used to enable use of
0063  * segmentation suppression data (preventing breaks in English after
0064  * abbreviations such as "Mr." or "Est.", for example), as follows:
0065  * "en@ss=standard".
0066  * <p>
0067  * Word boundary analysis is used by search and replace functions, as
0068  * well as within text editing applications that allow the user to
0069  * select words with a double click. Word selection provides correct
0070  * interpretation of punctuation marks within and following
0071  * words. Characters that are not part of a word, such as symbols or
0072  * punctuation marks, have word-breaks on both sides.
0073  * <p>
0074  * Character boundary analysis identifies the boundaries of
0075  * "Extended Grapheme Clusters", which are groupings of codepoints
0076  * that should be treated as character-like units for many text operations.
0077  * Please see Unicode Standard Annex #29, Unicode Text Segmentation,
0078  * http://www.unicode.org/reports/tr29/ for additional information
0079  * on grapheme clusters and guidelines on their use.
0080  * <p>
0081  * Title boundary analysis locates all positions,
0082  * typically starts of words, that should be set to Title Case
0083  * when title casing the text.
0084  * <p>
0085  * The text boundary positions are found according to the rules
0086  * described in Unicode Standard Annex #29, Text Boundaries, and
0087  * Unicode Standard Annex #14, Line Breaking Properties.  These
0088  * are available at http://www.unicode.org/reports/tr14/ and
0089  * http://www.unicode.org/reports/tr29/.
0090  * <p>
0091  * In addition to the plain C API defined in this header file, an
0092  * object oriented C++ API with equivalent functionality is defined in the
0093  * file brkiter.h.
0094  * <p>
0095  * Code snippets illustrating the use of the Break Iterator APIs
0096  * are available in the ICU User Guide,
0097  * https://unicode-org.github.io/icu/userguide/boundaryanalysis/
0098  * and in the sample program icu/source/samples/break/break.cpp
0099  */
0100 
0101 /** The possible types of text boundaries.  @stable ICU 2.0 */
0102 typedef enum UBreakIteratorType {
0103   /** Character breaks  @stable ICU 2.0 */
0104   UBRK_CHARACTER = 0,
0105   /** Word breaks @stable ICU 2.0 */
0106   UBRK_WORD = 1,
0107   /** Line breaks @stable ICU 2.0 */
0108   UBRK_LINE = 2,
0109   /** Sentence breaks @stable ICU 2.0 */
0110   UBRK_SENTENCE = 3,
0111 
0112 #ifndef U_HIDE_DEPRECATED_API
0113   /**
0114    * Title Case breaks
0115    * The iterator created using this type locates title boundaries as described for
0116    * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration,
0117    * please use Word Boundary iterator.
0118    *
0119    * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later.
0120    */
0121   UBRK_TITLE = 4,
0122     /**
0123      * One more than the highest normal UBreakIteratorType value.
0124      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
0125      */
0126     UBRK_COUNT = 5
0127 #endif  // U_HIDE_DEPRECATED_API
0128 } UBreakIteratorType;
0129 
0130 /** Value indicating all text boundaries have been returned.
0131  *  @stable ICU 2.0
0132  */
0133 #define UBRK_DONE ((int32_t) -1)
0134 
0135 
0136 /**
0137  *  Enum constants for the word break tags returned by
0138  *  getRuleStatus().  A range of values is defined for each category of
0139  *  word, to allow for further subdivisions of a category in future releases.
0140  *  Applications should check for tag values falling within the range, rather
0141  *  than for single individual values.
0142  *
0143  * The numeric values of all of these constants are stable (will not change).
0144  *
0145  * @stable ICU 2.2
0146 */
0147 typedef enum UWordBreak {
0148     /** Tag value for "words" that do not fit into any of other categories.
0149      *  Includes spaces and most punctuation. */
0150     UBRK_WORD_NONE           = 0,
0151     /** Upper bound for tags for uncategorized words. */
0152     UBRK_WORD_NONE_LIMIT     = 100,
0153     /** Tag value for words that appear to be numbers, lower limit.    */
0154     UBRK_WORD_NUMBER         = 100,
0155     /** Tag value for words that appear to be numbers, upper limit.    */
0156     UBRK_WORD_NUMBER_LIMIT   = 200,
0157     /** Tag value for words that contain letters, excluding
0158      *  hiragana, katakana or ideographic characters, lower limit.    */
0159     UBRK_WORD_LETTER         = 200,
0160     /** Tag value for words containing letters, upper limit  */
0161     UBRK_WORD_LETTER_LIMIT   = 300,
0162     /** Tag value for words containing kana characters, lower limit */
0163     UBRK_WORD_KANA           = 300,
0164     /** Tag value for words containing kana characters, upper limit */
0165     UBRK_WORD_KANA_LIMIT     = 400,
0166     /** Tag value for words containing ideographic characters, lower limit */
0167     UBRK_WORD_IDEO           = 400,
0168     /** Tag value for words containing ideographic characters, upper limit */
0169     UBRK_WORD_IDEO_LIMIT     = 500
0170 } UWordBreak;
0171 
0172 /**
0173  *  Enum constants for the line break tags returned by getRuleStatus().
0174  *  A range of values is defined for each category of
0175  *  word, to allow for further subdivisions of a category in future releases.
0176  *  Applications should check for tag values falling within the range, rather
0177  *  than for single individual values.
0178  *
0179  * The numeric values of all of these constants are stable (will not change).
0180  *
0181  * @stable ICU 2.8
0182 */
0183 typedef enum ULineBreakTag {
0184     /** Tag value for soft line breaks, positions at which a line break
0185       *  is acceptable but not required                */
0186     UBRK_LINE_SOFT            = 0,
0187     /** Upper bound for soft line breaks.              */
0188     UBRK_LINE_SOFT_LIMIT      = 100,
0189     /** Tag value for a hard, or mandatory line break  */
0190     UBRK_LINE_HARD            = 100,
0191     /** Upper bound for hard line breaks.              */
0192     UBRK_LINE_HARD_LIMIT      = 200
0193 } ULineBreakTag;
0194 
0195 
0196 
0197 /**
0198  *  Enum constants for the sentence break tags returned by getRuleStatus().
0199  *  A range of values is defined for each category of
0200  *  sentence, to allow for further subdivisions of a category in future releases.
0201  *  Applications should check for tag values falling within the range, rather
0202  *  than for single individual values.
0203  *
0204  * The numeric values of all of these constants are stable (will not change).
0205  *
0206  * @stable ICU 2.8
0207 */
0208 typedef enum USentenceBreakTag {
0209     /** Tag value for for sentences  ending with a sentence terminator
0210       * ('.', '?', '!', etc.) character, possibly followed by a
0211       * hard separator (CR, LF, PS, etc.)
0212       */
0213     UBRK_SENTENCE_TERM       = 0,
0214     /** Upper bound for tags for sentences ended by sentence terminators.    */
0215     UBRK_SENTENCE_TERM_LIMIT = 100,
0216     /** Tag value for for sentences that do not contain an ending
0217       * sentence terminator ('.', '?', '!', etc.) character, but
0218       * are ended only by a hard separator (CR, LF, PS, etc.) or end of input.
0219       */
0220     UBRK_SENTENCE_SEP        = 100,
0221     /** Upper bound for tags for sentences ended by a separator.              */
0222     UBRK_SENTENCE_SEP_LIMIT  = 200
0223     /** Tag value for a hard, or mandatory line break  */
0224 } USentenceBreakTag;
0225 
0226 
0227 /**
0228  * Open a new UBreakIterator for locating text boundaries for a specified locale.
0229  * A UBreakIterator may be used for detecting character, line, word,
0230  * and sentence breaks in text.
0231  * @param type The type of UBreakIterator to open: one of UBRK_CHARACTER, UBRK_WORD,
0232  * UBRK_LINE, UBRK_SENTENCE
0233  * @param locale The locale specifying the text-breaking conventions. Note that
0234  * locale keys such as "lb" and "ss" may be used to modify text break behavior,
0235  * see general discussion of BreakIterator C API.
0236  * @param text The text to be iterated over. May be null, in which case ubrk_setText() is
0237  *        used to specify the text to be iterated.
0238  * @param textLength The number of characters in text, or -1 if null-terminated.
0239  * @param status A UErrorCode to receive any errors.
0240  * @return A UBreakIterator for the specified locale.
0241  * @see ubrk_openRules
0242  * @stable ICU 2.0
0243  */
0244 U_CAPI UBreakIterator* U_EXPORT2
0245 ubrk_open(UBreakIteratorType type,
0246       const char *locale,
0247       const UChar *text,
0248       int32_t textLength,
0249       UErrorCode *status);
0250 
0251 /**
0252  * Open a new UBreakIterator for locating text boundaries using specified breaking rules.
0253  * The rule syntax is ... (TBD)
0254  * @param rules A set of rules specifying the text breaking conventions.
0255  * @param rulesLength The number of characters in rules, or -1 if null-terminated.
0256  * @param text The text to be iterated over.  May be null, in which case ubrk_setText() is
0257  *        used to specify the text to be iterated.
0258  * @param textLength The number of characters in text, or -1 if null-terminated.
0259  * @param parseErr   Receives position and context information for any syntax errors
0260  *                   detected while parsing the rules.
0261  * @param status A UErrorCode to receive any errors.
0262  * @return A UBreakIterator for the specified rules.
0263  * @see ubrk_open
0264  * @stable ICU 2.2
0265  */
0266 U_CAPI UBreakIterator* U_EXPORT2
0267 ubrk_openRules(const UChar     *rules,
0268                int32_t         rulesLength,
0269                const UChar     *text,
0270                int32_t          textLength,
0271                UParseError     *parseErr,
0272                UErrorCode      *status);
0273 
0274 /**
0275  * Open a new UBreakIterator for locating text boundaries using precompiled binary rules.
0276  * Opening a UBreakIterator this way is substantially faster than using ubrk_openRules.
0277  * Binary rules may be obtained using ubrk_getBinaryRules. The compiled rules are not
0278  * compatible across different major versions of ICU, nor across platforms of different
0279  * endianness or different base character set family (ASCII vs EBCDIC).
0280  * @param binaryRules A set of compiled binary rules specifying the text breaking
0281  *                    conventions. Ownership of the storage containing the compiled
0282  *                    rules remains with the caller of this function. The compiled
0283  *                    rules must not be modified or deleted during the life of the
0284  *                    break iterator.
0285  * @param rulesLength The length of binaryRules in bytes; must be >= 0.
0286  * @param text        The text to be iterated over.  May be null, in which case
0287  *                    ubrk_setText() is used to specify the text to be iterated.
0288  * @param textLength  The number of characters in text, or -1 if null-terminated.
0289  * @param status      Pointer to UErrorCode to receive any errors.
0290  * @return            UBreakIterator for the specified rules.
0291  * @see ubrk_getBinaryRules
0292  * @stable ICU 59
0293  */
0294 U_CAPI UBreakIterator* U_EXPORT2
0295 ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength,
0296                      const UChar *  text, int32_t textLength,
0297                      UErrorCode *   status);
0298 
0299 #ifndef U_HIDE_DEPRECATED_API
0300 
0301 /**
0302  * Thread safe cloning operation
0303  * @param bi iterator to be cloned
0304  * @param stackBuffer <em>Deprecated functionality as of ICU 52, use NULL.</em><br>
0305  *  user allocated space for the new clone. If NULL new memory will be allocated.
0306  *  If buffer is not large enough, new memory will be allocated.
0307  *  Clients can use the U_BRK_SAFECLONE_BUFFERSIZE.
0308  * @param pBufferSize <em>Deprecated functionality as of ICU 52, use NULL or 1.</em><br>
0309  *  pointer to size of allocated space.
0310  *  If *pBufferSize == 0, a sufficient size for use in cloning will
0311  *  be returned ('pre-flighting')
0312  *  If *pBufferSize is not enough for a stack-based safe clone,
0313  *  new memory will be allocated.
0314  * @param status to indicate whether the operation went on smoothly or there were errors
0315  *  An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used
0316  * if pBufferSize != NULL and any allocations were necessary
0317  * @return pointer to the new clone
0318  * @deprecated ICU 69 Use ubrk_clone() instead.
0319  */
0320 U_DEPRECATED UBreakIterator * U_EXPORT2
0321 ubrk_safeClone(
0322           const UBreakIterator *bi,
0323           void *stackBuffer,
0324           int32_t *pBufferSize,
0325           UErrorCode *status);
0326 
0327 #endif /* U_HIDE_DEPRECATED_API */
0328 
0329 /**
0330  * Thread safe cloning operation.
0331  * @param bi iterator to be cloned
0332  * @param status to indicate whether the operation went on smoothly or there were errors
0333  * @return pointer to the new clone
0334  * @stable ICU 69
0335  */
0336 U_CAPI UBreakIterator * U_EXPORT2
0337 ubrk_clone(const UBreakIterator *bi,
0338            UErrorCode *status);
0339 
0340 #ifndef U_HIDE_DEPRECATED_API
0341 
0342 /**
0343   * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone().
0344   * @deprecated ICU 52. Do not rely on ubrk_safeClone() cloning into any provided buffer.
0345   */
0346 #define U_BRK_SAFECLONE_BUFFERSIZE 1
0347 
0348 #endif /* U_HIDE_DEPRECATED_API */
0349 
0350 /**
0351 * Close a UBreakIterator.
0352 * Once closed, a UBreakIterator may no longer be used.
0353 * @param bi The break iterator to close.
0354  * @stable ICU 2.0
0355 */
0356 U_CAPI void U_EXPORT2
0357 ubrk_close(UBreakIterator *bi);
0358 
0359 #if U_SHOW_CPLUSPLUS_API
0360 
0361 U_NAMESPACE_BEGIN
0362 
0363 /**
0364  * \class LocalUBreakIteratorPointer
0365  * "Smart pointer" class, closes a UBreakIterator via ubrk_close().
0366  * For most methods see the LocalPointerBase base class.
0367  *
0368  * @see LocalPointerBase
0369  * @see LocalPointer
0370  * @stable ICU 4.4
0371  */
0372 U_DEFINE_LOCAL_OPEN_POINTER(LocalUBreakIteratorPointer, UBreakIterator, ubrk_close);
0373 
0374 U_NAMESPACE_END
0375 
0376 #endif
0377 
0378 /**
0379  * Sets an existing iterator to point to a new piece of text.
0380  * The break iterator retains a pointer to the supplied text.
0381  * The caller must not modify or delete the text while the BreakIterator
0382  * retains the reference.
0383  *
0384  * @param bi The iterator to use
0385  * @param text The text to be set
0386  * @param textLength The length of the text
0387  * @param status The error code
0388  * @stable ICU 2.0
0389  */
0390 U_CAPI void U_EXPORT2
0391 ubrk_setText(UBreakIterator* bi,
0392              const UChar*    text,
0393              int32_t         textLength,
0394              UErrorCode*     status);
0395 
0396 
0397 /**
0398  * Sets an existing iterator to point to a new piece of text.
0399  *
0400  * All index positions returned by break iterator functions are
0401  * native indices from the UText. For example, when breaking UTF-8
0402  * encoded text, the break positions returned by \ref ubrk_next, \ref ubrk_previous, etc.
0403  * will be UTF-8 string indices, not UTF-16 positions.
0404  *
0405  * @param bi The iterator to use
0406  * @param text The text to be set.
0407  *             This function makes a shallow clone of the supplied UText.  This means
0408  *             that the caller is free to immediately close or otherwise reuse the
0409  *             UText that was passed as a parameter, but that the underlying text itself
0410  *             must not be altered while being referenced by the break iterator.
0411  * @param status The error code
0412  * @stable ICU 3.4
0413  */
0414 U_CAPI void U_EXPORT2
0415 ubrk_setUText(UBreakIterator* bi,
0416              UText*          text,
0417              UErrorCode*     status);
0418 
0419 
0420 
0421 /**
0422  * Determine the most recently-returned text boundary.
0423  *
0424  * @param bi The break iterator to use.
0425  * @return The character index most recently returned by \ref ubrk_next, \ref ubrk_previous,
0426  * \ref ubrk_first, or \ref ubrk_last.
0427  * @stable ICU 2.0
0428  */
0429 U_CAPI int32_t U_EXPORT2
0430 ubrk_current(const UBreakIterator *bi);
0431 
0432 /**
0433  * Advance the iterator to the boundary following the current boundary.
0434  *
0435  * @param bi The break iterator to use.
0436  * @return The character index of the next text boundary, or UBRK_DONE
0437  * if all text boundaries have been returned.
0438  * @see ubrk_previous
0439  * @stable ICU 2.0
0440  */
0441 U_CAPI int32_t U_EXPORT2
0442 ubrk_next(UBreakIterator *bi);
0443 
0444 /**
0445  * Set the iterator position to the boundary preceding the current boundary.
0446  *
0447  * @param bi The break iterator to use.
0448  * @return The character index of the preceding text boundary, or UBRK_DONE
0449  * if all text boundaries have been returned.
0450  * @see ubrk_next
0451  * @stable ICU 2.0
0452  */
0453 U_CAPI int32_t U_EXPORT2
0454 ubrk_previous(UBreakIterator *bi);
0455 
0456 /**
0457  * Set the iterator position to zero, the start of the text being scanned.
0458  * @param bi The break iterator to use.
0459  * @return The new iterator position (zero).
0460  * @see ubrk_last
0461  * @stable ICU 2.0
0462  */
0463 U_CAPI int32_t U_EXPORT2
0464 ubrk_first(UBreakIterator *bi);
0465 
0466 /**
0467  * Set the iterator position to the index immediately <EM>beyond</EM> the last character in the text being scanned.
0468  * This is not the same as the last character.
0469  * @param bi The break iterator to use.
0470  * @return The character offset immediately <EM>beyond</EM> the last character in the
0471  * text being scanned.
0472  * @see ubrk_first
0473  * @stable ICU 2.0
0474  */
0475 U_CAPI int32_t U_EXPORT2
0476 ubrk_last(UBreakIterator *bi);
0477 
0478 /**
0479  * Set the iterator position to the first boundary preceding the specified offset.
0480  * The new position is always smaller than offset, or UBRK_DONE.
0481  * @param bi The break iterator to use.
0482  * @param offset The offset to begin scanning.
0483  * @return The text boundary preceding offset, or UBRK_DONE.
0484  * @see ubrk_following
0485  * @stable ICU 2.0
0486  */
0487 U_CAPI int32_t U_EXPORT2
0488 ubrk_preceding(UBreakIterator *bi,
0489            int32_t offset);
0490 
0491 /**
0492  * Advance the iterator to the first boundary following the specified offset.
0493  * The value returned is always greater than offset, or UBRK_DONE.
0494  * @param bi The break iterator to use.
0495  * @param offset The offset to begin scanning.
0496  * @return The text boundary following offset, or UBRK_DONE.
0497  * @see ubrk_preceding
0498  * @stable ICU 2.0
0499  */
0500 U_CAPI int32_t U_EXPORT2
0501 ubrk_following(UBreakIterator *bi,
0502            int32_t offset);
0503 
0504 /**
0505 * Get a locale for which text breaking information is available.
0506 * A UBreakIterator in a locale returned by this function will perform the correct
0507 * text breaking for the locale.
0508 * @param index The index of the desired locale.
0509 * @return A locale for which number text breaking information is available, or 0 if none.
0510 * @see ubrk_countAvailable
0511 * @stable ICU 2.0
0512 */
0513 U_CAPI const char* U_EXPORT2
0514 ubrk_getAvailable(int32_t index);
0515 
0516 /**
0517 * Determine how many locales have text breaking information available.
0518 * This function is most useful as determining the loop ending condition for
0519 * calls to \ref ubrk_getAvailable.
0520 * @return The number of locales for which text breaking information is available.
0521 * @see ubrk_getAvailable
0522 * @stable ICU 2.0
0523 */
0524 U_CAPI int32_t U_EXPORT2
0525 ubrk_countAvailable(void);
0526 
0527 
0528 /**
0529 * Returns true if the specified position is a boundary position.  As a side
0530 * effect, leaves the iterator pointing to the first boundary position at
0531 * or after "offset".
0532 * @param bi The break iterator to use.
0533 * @param offset the offset to check.
0534 * @return True if "offset" is a boundary position.
0535 * @stable ICU 2.0
0536 */
0537 U_CAPI  UBool U_EXPORT2
0538 ubrk_isBoundary(UBreakIterator *bi, int32_t offset);
0539 
0540 /**
0541  * Return the status from the break rule that determined the most recently
0542  * returned break position.  The values appear in the rule source
0543  * within brackets, {123}, for example.  For rules that do not specify a
0544  * status, a default value of 0 is returned.
0545  * <p>
0546  * For word break iterators, the possible values are defined in enum UWordBreak.
0547  * @stable ICU 2.2
0548  */
0549 U_CAPI  int32_t U_EXPORT2
0550 ubrk_getRuleStatus(UBreakIterator *bi);
0551 
0552 /**
0553  * Get the statuses from the break rules that determined the most recently
0554  * returned break position.  The values appear in the rule source
0555  * within brackets, {123}, for example.  The default status value for rules
0556  * that do not explicitly provide one is zero.
0557  * <p>
0558  * For word break iterators, the possible values are defined in enum UWordBreak.
0559  * @param bi        The break iterator to use
0560  * @param fillInVec an array to be filled in with the status values.
0561  * @param capacity  the length of the supplied vector.  A length of zero causes
0562  *                  the function to return the number of status values, in the
0563  *                  normal way, without attempting to store any values.
0564  * @param status    receives error codes.
0565  * @return          The number of rule status values from rules that determined
0566  *                  the most recent boundary returned by the break iterator.
0567  * @stable ICU 3.0
0568  */
0569 U_CAPI  int32_t U_EXPORT2
0570 ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status);
0571 
0572 /**
0573  * Return the locale of the break iterator. You can choose between the valid and
0574  * the actual locale.
0575  * @param bi break iterator
0576  * @param type locale type (valid or actual)
0577  * @param status error code
0578  * @return locale string
0579  * @stable ICU 2.8
0580  */
0581 U_CAPI const char* U_EXPORT2
0582 ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status);
0583 
0584 /**
0585   *  Set the subject text string upon which the break iterator is operating
0586   *  without changing any other aspect of the state.
0587   *  The new and previous text strings must have the same content.
0588   *
0589   *  This function is intended for use in environments where ICU is operating on
0590   *  strings that may move around in memory.  It provides a mechanism for notifying
0591   *  ICU that the string has been relocated, and providing a new UText to access the
0592   *  string in its new position.
0593   *
0594   *  Note that the break iterator never copies the underlying text
0595   *  of a string being processed, but always operates directly on the original text
0596   *  provided by the user. Refreshing simply drops the references to the old text
0597   *  and replaces them with references to the new.
0598   *
0599   *  Caution:  this function is normally used only by very specialized
0600   *            system-level code.   One example use case is with garbage collection
0601   *            that moves the text in memory.
0602   *
0603   * @param bi         The break iterator.
0604   * @param text       The new (moved) text string.
0605   * @param status     Receives errors detected by this function.
0606   *
0607   * @stable ICU 49
0608   */
0609 U_CAPI void U_EXPORT2
0610 ubrk_refreshUText(UBreakIterator *bi,
0611                        UText          *text,
0612                        UErrorCode     *status);
0613 
0614 
0615 /**
0616  * Get a compiled binary version of the rules specifying the behavior of a UBreakIterator.
0617  * The binary rules may be used with ubrk_openBinaryRules to open a new UBreakIterator
0618  * more quickly than using ubrk_openRules. The compiled rules are not compatible across
0619  * different major versions of ICU, nor across platforms of different endianness or
0620  * different base character set family (ASCII vs EBCDIC). Supports preflighting (with
0621  * binaryRules=NULL and rulesCapacity=0) to get the rules length without copying them to
0622  * the binaryRules buffer. However, whether preflighting or not, if the actual length
0623  * is greater than INT32_MAX, then the function returns 0 and sets *status to
0624  * U_INDEX_OUTOFBOUNDS_ERROR.
0625 
0626  * @param bi            The break iterator to use.
0627  * @param binaryRules   Buffer to receive the compiled binary rules; set to NULL for
0628  *                      preflighting.
0629  * @param rulesCapacity Capacity (in bytes) of the binaryRules buffer; set to 0 for
0630  *                      preflighting. Must be >= 0.
0631  * @param status        Pointer to UErrorCode to receive any errors, such as
0632  *                      U_BUFFER_OVERFLOW_ERROR, U_INDEX_OUTOFBOUNDS_ERROR, or
0633  *                      U_ILLEGAL_ARGUMENT_ERROR.
0634  * @return              The actual byte length of the binary rules, if <= INT32_MAX;
0635  *                      otherwise 0. If not preflighting and this is larger than
0636  *                      rulesCapacity, *status will be set to an error.
0637  * @see ubrk_openBinaryRules
0638  * @stable ICU 59
0639  */
0640 U_CAPI int32_t U_EXPORT2
0641 ubrk_getBinaryRules(UBreakIterator *bi,
0642                     uint8_t *       binaryRules, int32_t rulesCapacity,
0643                     UErrorCode *    status);
0644 
0645 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
0646 
0647 #endif