jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ****************************************************************************** jpayne@69: * Copyright (C) 1996-2015, International Business Machines Corporation and others. jpayne@69: * All Rights Reserved. jpayne@69: ****************************************************************************** jpayne@69: */ jpayne@69: jpayne@69: #ifndef UBRK_H jpayne@69: #define UBRK_H jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: #include "unicode/uloc.h" jpayne@69: #include "unicode/utext.h" jpayne@69: #include "unicode/localpointer.h" jpayne@69: jpayne@69: /** jpayne@69: * A text-break iterator. jpayne@69: * For usage in C programs. jpayne@69: */ jpayne@69: #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR jpayne@69: # define UBRK_TYPEDEF_UBREAK_ITERATOR jpayne@69: /** jpayne@69: * Opaque type representing an ICU Break iterator object. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: typedef struct UBreakIterator UBreakIterator; jpayne@69: #endif jpayne@69: jpayne@69: #if !UCONFIG_NO_BREAK_ITERATION jpayne@69: jpayne@69: #include "unicode/parseerr.h" jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: BreakIterator jpayne@69: * jpayne@69: *

BreakIterator C API

jpayne@69: * jpayne@69: * The BreakIterator C API defines methods for finding the location jpayne@69: * of boundaries in text. Pointer to a UBreakIterator maintain a jpayne@69: * current position and scan over text returning the index of characters jpayne@69: * where boundaries occur. jpayne@69: *

jpayne@69: * Line boundary analysis determines where a text string can be broken jpayne@69: * when line-wrapping. The mechanism correctly handles punctuation and jpayne@69: * hyphenated words. jpayne@69: *

jpayne@69: * Note: The locale keyword "lb" can be used to modify line break jpayne@69: * behavior according to the CSS level 3 line-break options, see jpayne@69: * . For example: jpayne@69: * "ja@lb=strict", "zh@lb=loose". jpayne@69: *

jpayne@69: * Sentence boundary analysis allows selection with correct jpayne@69: * interpretation of periods within numbers and abbreviations, and jpayne@69: * trailing punctuation marks such as quotation marks and parentheses. jpayne@69: *

jpayne@69: * Note: The locale keyword "ss" can be used to enable use of jpayne@69: * segmentation suppression data (preventing breaks in English after jpayne@69: * abbreviations such as "Mr." or "Est.", for example), as follows: jpayne@69: * "en@ss=standard". jpayne@69: *

jpayne@69: * Word boundary analysis is used by search and replace functions, as jpayne@69: * well as within text editing applications that allow the user to jpayne@69: * select words with a double click. Word selection provides correct jpayne@69: * interpretation of punctuation marks within and following jpayne@69: * words. Characters that are not part of a word, such as symbols or jpayne@69: * punctuation marks, have word-breaks on both sides. jpayne@69: *

jpayne@69: * Character boundary analysis identifies the boundaries of jpayne@69: * "Extended Grapheme Clusters", which are groupings of codepoints jpayne@69: * that should be treated as character-like units for many text operations. jpayne@69: * Please see Unicode Standard Annex #29, Unicode Text Segmentation, jpayne@69: * http://www.unicode.org/reports/tr29/ for additional information jpayne@69: * on grapheme clusters and guidelines on their use. jpayne@69: *

jpayne@69: * Title boundary analysis locates all positions, jpayne@69: * typically starts of words, that should be set to Title Case jpayne@69: * when title casing the text. jpayne@69: *

jpayne@69: * The text boundary positions are found according to the rules jpayne@69: * described in Unicode Standard Annex #29, Text Boundaries, and jpayne@69: * Unicode Standard Annex #14, Line Breaking Properties. These jpayne@69: * are available at http://www.unicode.org/reports/tr14/ and jpayne@69: * http://www.unicode.org/reports/tr29/. jpayne@69: *

jpayne@69: * In addition to the plain C API defined in this header file, an jpayne@69: * object oriented C++ API with equivalent functionality is defined in the jpayne@69: * file brkiter.h. jpayne@69: *

jpayne@69: * Code snippets illustrating the use of the Break Iterator APIs jpayne@69: * are available in the ICU User Guide, jpayne@69: * http://icu-project.org/userguide/boundaryAnalysis.html jpayne@69: * and in the sample program icu/source/samples/break/break.cpp jpayne@69: */ jpayne@69: jpayne@69: /** The possible types of text boundaries. @stable ICU 2.0 */ jpayne@69: typedef enum UBreakIteratorType { jpayne@69: /** Character breaks @stable ICU 2.0 */ jpayne@69: UBRK_CHARACTER = 0, jpayne@69: /** Word breaks @stable ICU 2.0 */ jpayne@69: UBRK_WORD = 1, jpayne@69: /** Line breaks @stable ICU 2.0 */ jpayne@69: UBRK_LINE = 2, jpayne@69: /** Sentence breaks @stable ICU 2.0 */ jpayne@69: UBRK_SENTENCE = 3, jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * Title Case breaks jpayne@69: * The iterator created using this type locates title boundaries as described for jpayne@69: * Unicode 3.2 only. For Unicode 4.0 and above title boundary iteration, jpayne@69: * please use Word Boundary iterator. jpayne@69: * jpayne@69: * @deprecated ICU 2.8 Use the word break iterator for titlecasing for Unicode 4 and later. jpayne@69: */ jpayne@69: UBRK_TITLE = 4, jpayne@69: /** jpayne@69: * One more than the highest normal UBreakIteratorType value. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: UBRK_COUNT = 5 jpayne@69: #endif // U_HIDE_DEPRECATED_API jpayne@69: } UBreakIteratorType; jpayne@69: jpayne@69: /** Value indicating all text boundaries have been returned. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: #define UBRK_DONE ((int32_t) -1) jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Enum constants for the word break tags returned by jpayne@69: * getRuleStatus(). A range of values is defined for each category of jpayne@69: * word, to allow for further subdivisions of a category in future releases. jpayne@69: * Applications should check for tag values falling within the range, rather jpayne@69: * than for single individual values. jpayne@69: * jpayne@69: * The numeric values of all of these constants are stable (will not change). jpayne@69: * jpayne@69: * @stable ICU 2.2 jpayne@69: */ jpayne@69: typedef enum UWordBreak { jpayne@69: /** Tag value for "words" that do not fit into any of other categories. jpayne@69: * Includes spaces and most punctuation. */ jpayne@69: UBRK_WORD_NONE = 0, jpayne@69: /** Upper bound for tags for uncategorized words. */ jpayne@69: UBRK_WORD_NONE_LIMIT = 100, jpayne@69: /** Tag value for words that appear to be numbers, lower limit. */ jpayne@69: UBRK_WORD_NUMBER = 100, jpayne@69: /** Tag value for words that appear to be numbers, upper limit. */ jpayne@69: UBRK_WORD_NUMBER_LIMIT = 200, jpayne@69: /** Tag value for words that contain letters, excluding jpayne@69: * hiragana, katakana or ideographic characters, lower limit. */ jpayne@69: UBRK_WORD_LETTER = 200, jpayne@69: /** Tag value for words containing letters, upper limit */ jpayne@69: UBRK_WORD_LETTER_LIMIT = 300, jpayne@69: /** Tag value for words containing kana characters, lower limit */ jpayne@69: UBRK_WORD_KANA = 300, jpayne@69: /** Tag value for words containing kana characters, upper limit */ jpayne@69: UBRK_WORD_KANA_LIMIT = 400, jpayne@69: /** Tag value for words containing ideographic characters, lower limit */ jpayne@69: UBRK_WORD_IDEO = 400, jpayne@69: /** Tag value for words containing ideographic characters, upper limit */ jpayne@69: UBRK_WORD_IDEO_LIMIT = 500 jpayne@69: } UWordBreak; jpayne@69: jpayne@69: /** jpayne@69: * Enum constants for the line break tags returned by getRuleStatus(). jpayne@69: * A range of values is defined for each category of jpayne@69: * word, to allow for further subdivisions of a category in future releases. jpayne@69: * Applications should check for tag values falling within the range, rather jpayne@69: * than for single individual values. jpayne@69: * jpayne@69: * The numeric values of all of these constants are stable (will not change). jpayne@69: * jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: typedef enum ULineBreakTag { jpayne@69: /** Tag value for soft line breaks, positions at which a line break jpayne@69: * is acceptable but not required */ jpayne@69: UBRK_LINE_SOFT = 0, jpayne@69: /** Upper bound for soft line breaks. */ jpayne@69: UBRK_LINE_SOFT_LIMIT = 100, jpayne@69: /** Tag value for a hard, or mandatory line break */ jpayne@69: UBRK_LINE_HARD = 100, jpayne@69: /** Upper bound for hard line breaks. */ jpayne@69: UBRK_LINE_HARD_LIMIT = 200 jpayne@69: } ULineBreakTag; jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Enum constants for the sentence break tags returned by getRuleStatus(). jpayne@69: * A range of values is defined for each category of jpayne@69: * sentence, to allow for further subdivisions of a category in future releases. jpayne@69: * Applications should check for tag values falling within the range, rather jpayne@69: * than for single individual values. jpayne@69: * jpayne@69: * The numeric values of all of these constants are stable (will not change). jpayne@69: * jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: typedef enum USentenceBreakTag { jpayne@69: /** Tag value for for sentences ending with a sentence terminator jpayne@69: * ('.', '?', '!', etc.) character, possibly followed by a jpayne@69: * hard separator (CR, LF, PS, etc.) jpayne@69: */ jpayne@69: UBRK_SENTENCE_TERM = 0, jpayne@69: /** Upper bound for tags for sentences ended by sentence terminators. */ jpayne@69: UBRK_SENTENCE_TERM_LIMIT = 100, jpayne@69: /** Tag value for for sentences that do not contain an ending jpayne@69: * sentence terminator ('.', '?', '!', etc.) character, but jpayne@69: * are ended only by a hard separator (CR, LF, PS, etc.) or end of input. jpayne@69: */ jpayne@69: UBRK_SENTENCE_SEP = 100, jpayne@69: /** Upper bound for tags for sentences ended by a separator. */ jpayne@69: UBRK_SENTENCE_SEP_LIMIT = 200 jpayne@69: /** Tag value for a hard, or mandatory line break */ jpayne@69: } USentenceBreakTag; jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Open a new UBreakIterator for locating text boundaries for a specified locale. jpayne@69: * A UBreakIterator may be used for detecting character, line, word, jpayne@69: * and sentence breaks in text. jpayne@69: * @param type The type of UBreakIterator to open: one of UBRK_CHARACTER, UBRK_WORD, jpayne@69: * UBRK_LINE, UBRK_SENTENCE jpayne@69: * @param locale The locale specifying the text-breaking conventions. Note that jpayne@69: * locale keys such as "lb" and "ss" may be used to modify text break behavior, jpayne@69: * see general discussion of BreakIterator C API. jpayne@69: * @param text The text to be iterated over. May be null, in which case ubrk_setText() is jpayne@69: * used to specify the text to be iterated. jpayne@69: * @param textLength The number of characters in text, or -1 if null-terminated. jpayne@69: * @param status A UErrorCode to receive any errors. jpayne@69: * @return A UBreakIterator for the specified locale. jpayne@69: * @see ubrk_openRules jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE UBreakIterator* U_EXPORT2 jpayne@69: ubrk_open(UBreakIteratorType type, jpayne@69: const char *locale, jpayne@69: const UChar *text, jpayne@69: int32_t textLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Open a new UBreakIterator for locating text boundaries using specified breaking rules. jpayne@69: * The rule syntax is ... (TBD) jpayne@69: * @param rules A set of rules specifying the text breaking conventions. jpayne@69: * @param rulesLength The number of characters in rules, or -1 if null-terminated. jpayne@69: * @param text The text to be iterated over. May be null, in which case ubrk_setText() is jpayne@69: * used to specify the text to be iterated. jpayne@69: * @param textLength The number of characters in text, or -1 if null-terminated. jpayne@69: * @param parseErr Receives position and context information for any syntax errors jpayne@69: * detected while parsing the rules. jpayne@69: * @param status A UErrorCode to receive any errors. jpayne@69: * @return A UBreakIterator for the specified rules. jpayne@69: * @see ubrk_open jpayne@69: * @stable ICU 2.2 jpayne@69: */ jpayne@69: U_STABLE UBreakIterator* U_EXPORT2 jpayne@69: ubrk_openRules(const UChar *rules, jpayne@69: int32_t rulesLength, jpayne@69: const UChar *text, jpayne@69: int32_t textLength, jpayne@69: UParseError *parseErr, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Open a new UBreakIterator for locating text boundaries using precompiled binary rules. jpayne@69: * Opening a UBreakIterator this way is substantially faster than using ubrk_openRules. jpayne@69: * Binary rules may be obtained using ubrk_getBinaryRules. The compiled rules are not jpayne@69: * compatible across different major versions of ICU, nor across platforms of different jpayne@69: * endianness or different base character set family (ASCII vs EBCDIC). jpayne@69: * @param binaryRules A set of compiled binary rules specifying the text breaking jpayne@69: * conventions. Ownership of the storage containing the compiled jpayne@69: * rules remains with the caller of this function. The compiled jpayne@69: * rules must not be modified or deleted during the life of the jpayne@69: * break iterator. jpayne@69: * @param rulesLength The length of binaryRules in bytes; must be >= 0. jpayne@69: * @param text The text to be iterated over. May be null, in which case jpayne@69: * ubrk_setText() is used to specify the text to be iterated. jpayne@69: * @param textLength The number of characters in text, or -1 if null-terminated. jpayne@69: * @param status Pointer to UErrorCode to receive any errors. jpayne@69: * @return UBreakIterator for the specified rules. jpayne@69: * @see ubrk_getBinaryRules jpayne@69: * @stable ICU 59 jpayne@69: */ jpayne@69: U_STABLE UBreakIterator* U_EXPORT2 jpayne@69: ubrk_openBinaryRules(const uint8_t *binaryRules, int32_t rulesLength, jpayne@69: const UChar * text, int32_t textLength, jpayne@69: UErrorCode * status); jpayne@69: jpayne@69: /** jpayne@69: * Thread safe cloning operation jpayne@69: * @param bi iterator to be cloned jpayne@69: * @param stackBuffer Deprecated functionality as of ICU 52, use NULL.
jpayne@69: * user allocated space for the new clone. If NULL new memory will be allocated. jpayne@69: * If buffer is not large enough, new memory will be allocated. jpayne@69: * Clients can use the U_BRK_SAFECLONE_BUFFERSIZE. jpayne@69: * @param pBufferSize Deprecated functionality as of ICU 52, use NULL or 1.
jpayne@69: * pointer to size of allocated space. jpayne@69: * If *pBufferSize == 0, a sufficient size for use in cloning will jpayne@69: * be returned ('pre-flighting') jpayne@69: * If *pBufferSize is not enough for a stack-based safe clone, jpayne@69: * new memory will be allocated. jpayne@69: * @param status to indicate whether the operation went on smoothly or there were errors jpayne@69: * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary. jpayne@69: * @return pointer to the new clone jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE UBreakIterator * U_EXPORT2 jpayne@69: ubrk_safeClone( jpayne@69: const UBreakIterator *bi, jpayne@69: void *stackBuffer, jpayne@69: int32_t *pBufferSize, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: jpayne@69: /** jpayne@69: * A recommended size (in bytes) for the memory buffer to be passed to ubrk_saveClone(). jpayne@69: * @deprecated ICU 52. Do not rely on ubrk_safeClone() cloning into any provided buffer. jpayne@69: */ jpayne@69: #define U_BRK_SAFECLONE_BUFFERSIZE 1 jpayne@69: jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: jpayne@69: /** jpayne@69: * Close a UBreakIterator. jpayne@69: * Once closed, a UBreakIterator may no longer be used. jpayne@69: * @param bi The break iterator to close. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: ubrk_close(UBreakIterator *bi); jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: /** jpayne@69: * \class LocalUBreakIteratorPointer jpayne@69: * "Smart pointer" class, closes a UBreakIterator via ubrk_close(). jpayne@69: * For most methods see the LocalPointerBase base class. jpayne@69: * jpayne@69: * @see LocalPointerBase jpayne@69: * @see LocalPointer jpayne@69: * @stable ICU 4.4 jpayne@69: */ jpayne@69: U_DEFINE_LOCAL_OPEN_POINTER(LocalUBreakIteratorPointer, UBreakIterator, ubrk_close); jpayne@69: jpayne@69: U_NAMESPACE_END jpayne@69: jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * Sets an existing iterator to point to a new piece of text. jpayne@69: * The break iterator retains a pointer to the supplied text. jpayne@69: * The caller must not modify or delete the text while the BreakIterator jpayne@69: * retains the reference. jpayne@69: * jpayne@69: * @param bi The iterator to use jpayne@69: * @param text The text to be set jpayne@69: * @param textLength The length of the text jpayne@69: * @param status The error code jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: ubrk_setText(UBreakIterator* bi, jpayne@69: const UChar* text, jpayne@69: int32_t textLength, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Sets an existing iterator to point to a new piece of text. jpayne@69: * jpayne@69: * All index positions returned by break iterator functions are jpayne@69: * native indices from the UText. For example, when breaking UTF-8 jpayne@69: * encoded text, the break positions returned by \ref ubrk_next, \ref ubrk_previous, etc. jpayne@69: * will be UTF-8 string indices, not UTF-16 positions. jpayne@69: * jpayne@69: * @param bi The iterator to use jpayne@69: * @param text The text to be set. jpayne@69: * This function makes a shallow clone of the supplied UText. This means jpayne@69: * that the caller is free to immediately close or otherwise reuse the jpayne@69: * UText that was passed as a parameter, but that the underlying text itself jpayne@69: * must not be altered while being referenced by the break iterator. jpayne@69: * @param status The error code jpayne@69: * @stable ICU 3.4 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: ubrk_setUText(UBreakIterator* bi, jpayne@69: UText* text, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Determine the most recently-returned text boundary. jpayne@69: * jpayne@69: * @param bi The break iterator to use. jpayne@69: * @return The character index most recently returned by \ref ubrk_next, \ref ubrk_previous, jpayne@69: * \ref ubrk_first, or \ref ubrk_last. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_current(const UBreakIterator *bi); jpayne@69: jpayne@69: /** jpayne@69: * Advance the iterator to the boundary following the current boundary. jpayne@69: * jpayne@69: * @param bi The break iterator to use. jpayne@69: * @return The character index of the next text boundary, or UBRK_DONE jpayne@69: * if all text boundaries have been returned. jpayne@69: * @see ubrk_previous jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_next(UBreakIterator *bi); jpayne@69: jpayne@69: /** jpayne@69: * Set the iterator position to the boundary preceding the current boundary. jpayne@69: * jpayne@69: * @param bi The break iterator to use. jpayne@69: * @return The character index of the preceding text boundary, or UBRK_DONE jpayne@69: * if all text boundaries have been returned. jpayne@69: * @see ubrk_next jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_previous(UBreakIterator *bi); jpayne@69: jpayne@69: /** jpayne@69: * Set the iterator position to zero, the start of the text being scanned. jpayne@69: * @param bi The break iterator to use. jpayne@69: * @return The new iterator position (zero). jpayne@69: * @see ubrk_last jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_first(UBreakIterator *bi); jpayne@69: jpayne@69: /** jpayne@69: * Set the iterator position to the index immediately beyond the last character in the text being scanned. jpayne@69: * This is not the same as the last character. jpayne@69: * @param bi The break iterator to use. jpayne@69: * @return The character offset immediately beyond the last character in the jpayne@69: * text being scanned. jpayne@69: * @see ubrk_first jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_last(UBreakIterator *bi); jpayne@69: jpayne@69: /** jpayne@69: * Set the iterator position to the first boundary preceding the specified offset. jpayne@69: * The new position is always smaller than offset, or UBRK_DONE. jpayne@69: * @param bi The break iterator to use. jpayne@69: * @param offset The offset to begin scanning. jpayne@69: * @return The text boundary preceding offset, or UBRK_DONE. jpayne@69: * @see ubrk_following jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_preceding(UBreakIterator *bi, jpayne@69: int32_t offset); jpayne@69: jpayne@69: /** jpayne@69: * Advance the iterator to the first boundary following the specified offset. jpayne@69: * The value returned is always greater than offset, or UBRK_DONE. jpayne@69: * @param bi The break iterator to use. jpayne@69: * @param offset The offset to begin scanning. jpayne@69: * @return The text boundary following offset, or UBRK_DONE. jpayne@69: * @see ubrk_preceding jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_following(UBreakIterator *bi, jpayne@69: int32_t offset); jpayne@69: jpayne@69: /** jpayne@69: * Get a locale for which text breaking information is available. jpayne@69: * A UBreakIterator in a locale returned by this function will perform the correct jpayne@69: * text breaking for the locale. jpayne@69: * @param index The index of the desired locale. jpayne@69: * @return A locale for which number text breaking information is available, or 0 if none. jpayne@69: * @see ubrk_countAvailable jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE const char* U_EXPORT2 jpayne@69: ubrk_getAvailable(int32_t index); jpayne@69: jpayne@69: /** jpayne@69: * Determine how many locales have text breaking information available. jpayne@69: * This function is most useful as determining the loop ending condition for jpayne@69: * calls to \ref ubrk_getAvailable. jpayne@69: * @return The number of locales for which text breaking information is available. jpayne@69: * @see ubrk_getAvailable jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_countAvailable(void); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Returns true if the specified position is a boundary position. As a side jpayne@69: * effect, leaves the iterator pointing to the first boundary position at jpayne@69: * or after "offset". jpayne@69: * @param bi The break iterator to use. jpayne@69: * @param offset the offset to check. jpayne@69: * @return True if "offset" is a boundary position. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_STABLE UBool U_EXPORT2 jpayne@69: ubrk_isBoundary(UBreakIterator *bi, int32_t offset); jpayne@69: jpayne@69: /** jpayne@69: * Return the status from the break rule that determined the most recently jpayne@69: * returned break position. The values appear in the rule source jpayne@69: * within brackets, {123}, for example. For rules that do not specify a jpayne@69: * status, a default value of 0 is returned. jpayne@69: *

jpayne@69: * For word break iterators, the possible values are defined in enum UWordBreak. jpayne@69: * @stable ICU 2.2 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_getRuleStatus(UBreakIterator *bi); jpayne@69: jpayne@69: /** jpayne@69: * Get the statuses from the break rules that determined the most recently jpayne@69: * returned break position. The values appear in the rule source jpayne@69: * within brackets, {123}, for example. The default status value for rules jpayne@69: * that do not explicitly provide one is zero. jpayne@69: *

jpayne@69: * For word break iterators, the possible values are defined in enum UWordBreak. jpayne@69: * @param bi The break iterator to use jpayne@69: * @param fillInVec an array to be filled in with the status values. jpayne@69: * @param capacity the length of the supplied vector. A length of zero causes jpayne@69: * the function to return the number of status values, in the jpayne@69: * normal way, without attempting to store any values. jpayne@69: * @param status receives error codes. jpayne@69: * @return The number of rule status values from rules that determined jpayne@69: * the most recent boundary returned by the break iterator. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_getRuleStatusVec(UBreakIterator *bi, int32_t *fillInVec, int32_t capacity, UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Return the locale of the break iterator. You can choose between the valid and jpayne@69: * the actual locale. jpayne@69: * @param bi break iterator jpayne@69: * @param type locale type (valid or actual) jpayne@69: * @param status error code jpayne@69: * @return locale string jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: U_STABLE const char* U_EXPORT2 jpayne@69: ubrk_getLocaleByType(const UBreakIterator *bi, ULocDataLocaleType type, UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Set the subject text string upon which the break iterator is operating jpayne@69: * without changing any other aspect of the state. jpayne@69: * The new and previous text strings must have the same content. jpayne@69: * jpayne@69: * This function is intended for use in environments where ICU is operating on jpayne@69: * strings that may move around in memory. It provides a mechanism for notifying jpayne@69: * ICU that the string has been relocated, and providing a new UText to access the jpayne@69: * string in its new position. jpayne@69: * jpayne@69: * Note that the break iterator never copies the underlying text jpayne@69: * of a string being processed, but always operates directly on the original text jpayne@69: * provided by the user. Refreshing simply drops the references to the old text jpayne@69: * and replaces them with references to the new. jpayne@69: * jpayne@69: * Caution: this function is normally used only by very specialized jpayne@69: * system-level code. One example use case is with garbage collection jpayne@69: * that moves the text in memory. jpayne@69: * jpayne@69: * @param bi The break iterator. jpayne@69: * @param text The new (moved) text string. jpayne@69: * @param status Receives errors detected by this function. jpayne@69: * jpayne@69: * @stable ICU 49 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: ubrk_refreshUText(UBreakIterator *bi, jpayne@69: UText *text, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Get a compiled binary version of the rules specifying the behavior of a UBreakIterator. jpayne@69: * The binary rules may be used with ubrk_openBinaryRules to open a new UBreakIterator jpayne@69: * more quickly than using ubrk_openRules. The compiled rules are not compatible across jpayne@69: * different major versions of ICU, nor across platforms of different endianness or jpayne@69: * different base character set family (ASCII vs EBCDIC). Supports preflighting (with jpayne@69: * binaryRules=NULL and rulesCapacity=0) to get the rules length without copying them to jpayne@69: * the binaryRules buffer. However, whether preflighting or not, if the actual length jpayne@69: * is greater than INT32_MAX, then the function returns 0 and sets *status to jpayne@69: * U_INDEX_OUTOFBOUNDS_ERROR. jpayne@69: jpayne@69: * @param bi The break iterator to use. jpayne@69: * @param binaryRules Buffer to receive the compiled binary rules; set to NULL for jpayne@69: * preflighting. jpayne@69: * @param rulesCapacity Capacity (in bytes) of the binaryRules buffer; set to 0 for jpayne@69: * preflighting. Must be >= 0. jpayne@69: * @param status Pointer to UErrorCode to receive any errors, such as jpayne@69: * U_BUFFER_OVERFLOW_ERROR, U_INDEX_OUTOFBOUNDS_ERROR, or jpayne@69: * U_ILLEGAL_ARGUMENT_ERROR. jpayne@69: * @return The actual byte length of the binary rules, if <= INT32_MAX; jpayne@69: * otherwise 0. If not preflighting and this is larger than jpayne@69: * rulesCapacity, *status will be set to an error. jpayne@69: * @see ubrk_openBinaryRules jpayne@69: * @stable ICU 59 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: ubrk_getBinaryRules(UBreakIterator *bi, jpayne@69: uint8_t * binaryRules, int32_t rulesCapacity, jpayne@69: UErrorCode * status); jpayne@69: jpayne@69: #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ jpayne@69: jpayne@69: #endif