#ifndef USTRING_H /** * \ingroup ustring_ustrlen * @param s Pointer to sequence of UChars. * @return Length of sequence.
*/
U_CAPI int32_t U_EXPORT2 u_strlen(const UChar *s); #endif
U_NAMESPACE_BEGIN
#if !UCONFIG_NO_BREAK_ITERATION class BreakIterator; // unicode/brkiter.h #endif class Edits;
U_NAMESPACE_END
// Not #ifndef U_HIDE_INTERNAL_API because UnicodeString needs the UStringCaseMapper. /** * Internal string case mapping function type. * All error checking must be done. * src and dest must not overlap. * @internal
*/ typedef int32_t U_CALLCONV
UStringCaseMapper(int32_t caseLocale, uint32_t options, #if !UCONFIG_NO_BREAK_ITERATION
icu::BreakIterator *iter, #endif
char16_t *dest, int32_t destCapacity, const char16_t *src, int32_t srcLength,
icu::Edits *edits,
UErrorCode &errorCode);
U_NAMESPACE_BEGIN
class Locale; // unicode/locid.h class StringCharacterIterator; class UnicodeStringAppendable; // unicode/appendable.h
/* The <iostream> include has been moved to unicode/ustream.h */
/** * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor * which constructs a Unicode string from an invariant-character char * string. * About invariant characters see utypes.h. * This constructor has no runtime dependency on conversion code and is * therefore recommended over ones taking a charset name string * (where the empty string "" indicates invariant-character conversion). * * @stable ICU 3.2
*/ #define US_INV icu::UnicodeString::kInvariant
/** * \def UNICODE_STRING * Obsolete macro approximating UnicodeString literals. * * Prior to the availability of C++11 and u"UTF-16 string literals", * this macro was provided for portability and efficiency when * initializing UnicodeStrings from literals. * * Since C++17 and ICU 76, you can use UTF-16 string literals with compile-time * length determination: * \code * UnicodeString str(u"literal"); * if (str == u"other literal") { ... } * \endcode * * The string parameter must be a C string literal. * The length of the string, not including the terminating * `NUL`, must be specified as a constant. * @stable ICU 2.0
*/ #if !U_CHAR16_IS_TYPEDEF # define UNICODE_STRING(cs, _length) icu::UnicodeString(true, u ## cs, _length) #else # define UNICODE_STRING(cs, _length) icu::UnicodeString(true, (const char16_t*)u ## cs, _length) #endif
/** * Unicode String literals in C++. * Obsolete macro approximating UnicodeString literals. * See UNICODE_STRING. * * The string parameter must be a C string literal. * @stable ICU 2.0 * @see UNICODE_STRING
*/ #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
/** * \def UNISTR_FROM_CHAR_EXPLICIT * This can be defined to be empty or "explicit". * If explicit, then the UnicodeString(char16_t) and UnicodeString(UChar32) * constructors are marked as explicit, preventing their inadvertent use. * @stable ICU 49
*/ #ifndef UNISTR_FROM_CHAR_EXPLICIT # ifdefined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) // Auto-"explicit" in ICU library code. # define UNISTR_FROM_CHAR_EXPLICIT explicit # else // Empty by default for source code compatibility. # define UNISTR_FROM_CHAR_EXPLICIT # endif #endif
/** * \def UNISTR_FROM_STRING_EXPLICIT * This can be defined to be empty or "explicit". * If explicit, then the UnicodeString(const char *) and UnicodeString(const char16_t *) * constructors are marked as explicit, preventing their inadvertent use. * * In particular, this helps prevent accidentally depending on ICU conversion code * by passing a string literal into an API with a const UnicodeString & parameter. * @stable ICU 49
*/ #ifndef UNISTR_FROM_STRING_EXPLICIT # ifdefined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) // Auto-"explicit" in ICU library code. # define UNISTR_FROM_STRING_EXPLICIT explicit # else // Empty by default for source code compatibility. # define UNISTR_FROM_STRING_EXPLICIT # endif #endif
/** * \def UNISTR_OBJECT_SIZE * Desired sizeof(UnicodeString) in bytes. * It should be a multiple of sizeof(pointer) to avoid unusable space for padding. * The object size may want to be a multiple of 16 bytes, * which is a common granularity for heap allocation. * * Any space inside the object beyond sizeof(vtable pointer) + 2 * is available for storing short strings inside the object. * The bigger the object, the longer a string that can be stored inside the object, * without additional heap allocation. * * Depending on a platform's pointer size, pointer alignment requirements, * and struct padding, the compiler will usually round up sizeof(UnicodeString) * to 4 * sizeof(pointer) (or 3 * sizeof(pointer) for P128 data models), * to hold the fields for heap-allocated strings. * Such a minimum size also ensures that the object is easily large enough * to hold at least 2 char16_ts, for one supplementary code point (U16_MAX_LENGTH). * * sizeof(UnicodeString) >= 48 should work for all known platforms. * * For example, on a 64-bit machine where sizeof(vtable pointer) is 8, * sizeof(UnicodeString) = 64 would leave space for * (64 - sizeof(vtable pointer) - 2) / U_SIZEOF_UCHAR = (64 - 8 - 2) / 2 = 27 * char16_ts stored inside the object. * * The minimum object size on a 64-bit machine would be * 4 * sizeof(pointer) = 4 * 8 = 32 bytes, * and the internal buffer would hold up to 11 char16_ts in that case. * * @see U16_MAX_LENGTH * @stable ICU 56
*/ #ifndef UNISTR_OBJECT_SIZE # define UNISTR_OBJECT_SIZE 64 #endif
/** * UnicodeString is a string class that stores Unicode characters directly and provides * similar functionality as the Java String and StringBuffer/StringBuilder classes. * It is a concrete implementation of the abstract class Replaceable (for transliteration). * * The UnicodeString equivalent of std::string’s clear() is remove(). * * A UnicodeString may "alias" an external array of characters * (that is, point to it, rather than own the array) * whose lifetime must then at least match the lifetime of the aliasing object. * This aliasing may be preserved when returning a UnicodeString by value, * depending on the compiler and the function implementation, * via Return Value Optimization (RVO) or the move assignment operator. * (However, the copy assignment operator does not preserve aliasing.) * For details see the description of storage models at the end of the class API docs * and in the User Guide chapter linked from there. * * The UnicodeString class is not suitable for subclassing. * * For an overview of Unicode strings in C and C++ see the * [User Guide Strings chapter](https://unicode-org.github.io/icu/userguide/strings#strings-in-cc). * * In ICU, a Unicode string consists of 16-bit Unicode *code units*. * A Unicode character may be stored with either one code unit * (the most common case) or with a matched pair of special code units * ("surrogates"). The data type for code units is char16_t. * For single-character handling, a Unicode character code *point* is a value * in the range 0..0x10ffff. ICU uses the UChar32 type for code points. * * Indexes and offsets into and lengths of strings always count code units, not code points. * This is the same as with multi-byte char* strings in traditional string handling. * Operations on partial strings typically do not test for code point boundaries. * If necessary, the user needs to take care of such boundaries by testing for the code unit * values or by using functions like * UnicodeString::getChar32Start() and UnicodeString::getChar32Limit() * (or, in C, the equivalent macros U16_SET_CP_START() and U16_SET_CP_LIMIT(), see utf.h). * * UnicodeString methods are more lenient with regard to input parameter values * than other ICU APIs. In particular: * - If indexes are out of bounds for a UnicodeString object * (< 0 or > length()) then they are "pinned" to the nearest boundary. * - If the buffer passed to an insert/append/replace operation is owned by the * target object, e.g., calling str.append(str), an extra copy may take place * to ensure safety. * - If primitive string pointer values (e.g., const char16_t * or char *) * for input strings are nullptr, then those input string parameters are treated * as if they pointed to an empty string. * However, this is *not* the case for char * parameters for charset names * or other IDs. * - Most UnicodeString methods do not take a UErrorCode parameter because * there are usually very few opportunities for failure other than a shortage * of memory, error codes in low-level C++ string methods would be inconvenient, * and the error code as the last parameter (ICU convention) would prevent * the use of default parameter values. * Instead, such methods set the UnicodeString into a "bogus" state * (see isBogus()) if an error occurs. * * In string comparisons, two UnicodeString objects that are both "bogus" * compare equal (to be transitive and prevent endless loops in sorting), * and a "bogus" string compares less than any non-"bogus" one. * * Const UnicodeString methods are thread-safe. Multiple threads can use * const methods on the same UnicodeString object simultaneously, * but non-const methods must not be called concurrently (in multiple threads) * with any other (const or non-const) methods. * * Similarly, const UnicodeString & parameters are thread-safe. * One object may be passed in as such a parameter concurrently in multiple threads. * This includes the const UnicodeString & parameters for * copy construction, assignment, and cloning. * * UnicodeString uses several storage methods. * String contents can be stored inside the UnicodeString object itself, * in an allocated and shared buffer, or in an outside buffer that is "aliased". * Most of this is done transparently, but careful aliasing in particular provides * significant performance improvements. * Also, the internal buffer is accessible via special functions. * For details see the * [User Guide Strings chapter](https://unicode-org.github.io/icu/userguide/strings#maximizing-performance-with-the-unicodestring-storage-model). * * @see utf.h * @see CharacterIterator * @stable ICU 2.0
*/ class U_COMMON_API UnicodeString : public Replaceable
{ public:
/** * Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor * which constructs a Unicode string from an invariant-character char * string. * Use the macro US_INV instead of the full qualification for this value. * * @see US_INV * @stable ICU 3.2
*/ enum EInvariant { /** * @see EInvariant * @stable ICU 3.2
*/
kInvariant
};
/* Comparison - bitwise only - for international comparison use collation */
/** * Equality operator. Performs only bitwise comparison. * @param text The UnicodeString to compare to this one. * @return true if `text` contains the same characters as this one, * false otherwise. * @stable ICU 2.0
*/ inlinebooloperator== (const UnicodeString& text) const;
#ifndef U_HIDE_DRAFT_API /** * Equality operator. Performs only bitwise comparison with `text` * which is, or which is implicitly convertible to, * a std::u16string_view or (if U_SIZEOF_WCHAR_T==2) std::wstring_view. * * For performance, you can use UTF-16 string literals with compile-time * length determination: * \code * UnicodeString str = ...; * if (str == u"literal") { ... } * \endcode * @param text The string view to compare to this string. * @return true if `text` contains the same characters as this one, false otherwise. * @draft ICU 76
*/ template<typename S, typename = std::enable_if_t<ConvertibleToU16StringView<S>>> inlinebooloperator==(const S &text) const {
std::u16string_view sv(internal::toU16StringView(text));
uint32_t len; // unsigned to avoid a compiler warning return !isBogus() && (len = length()) == sv.length() && doEquals(sv.data(), len);
} #endif// U_HIDE_DRAFT_API
/** * Inequality operator. Performs only bitwise comparison. * @param text The UnicodeString to compare to this one. * @return false if `text` contains the same characters as this one, * true otherwise. * @stable ICU 2.0
*/ inlinebooloperator!= (const UnicodeString& text) const;
#ifndef U_HIDE_DRAFT_API /** * Inequality operator. Performs only bitwise comparison with `text` * which is, or which is implicitly convertible to, * a std::u16string_view or (if U_SIZEOF_WCHAR_T==2) std::wstring_view. * * For performance, you can use std::u16string_view literals with compile-time * length determination: * \code * #include <string_view> * using namespace std::string_view_literals; * UnicodeString str = ...; * if (str != u"literal"sv) { ... } * \endcode * @param text The string view to compare to this string. * @return false if `text` contains the same characters as this one, true otherwise. * @draft ICU 76
*/ template<typename S, typename = std::enable_if_t<ConvertibleToU16StringView<S>>> inlinebooloperator!=(const S &text) const { return !operator==(text);
} #endif// U_HIDE_DRAFT_API
/** * Greater than operator. Performs only bitwise comparison. * @param text The UnicodeString to compare to this one. * @return true if the characters in this are bitwise * greater than the characters in `text`, false otherwise * @stable ICU 2.0
*/ inline UBool operator> (const UnicodeString& text) const;
/** * Less than operator. Performs only bitwise comparison. * @param text The UnicodeString to compare to this one. * @return true if the characters in this are bitwise * less than the characters in `text`, false otherwise * @stable ICU 2.0
*/ inline UBool operator< (const UnicodeString& text) const;
/** * Greater than or equal operator. Performs only bitwise comparison. * @param text The UnicodeString to compare to this one. * @return true if the characters in this are bitwise * greater than or equal to the characters in `text`, false otherwise * @stable ICU 2.0
*/ inline UBool operator>= (const UnicodeString& text) const;
/** * Less than or equal operator. Performs only bitwise comparison. * @param text The UnicodeString to compare to this one. * @return true if the characters in this are bitwise * less than or equal to the characters in `text`, false otherwise * @stable ICU 2.0
*/ inline UBool operator<= (const UnicodeString& text) const;
/** * Compare the characters bitwise in this UnicodeString to * the characters in `text`. * @param text The UnicodeString to compare to this one. * @return The result of bitwise character comparison: 0 if this * contains the same characters as `text`, -1 if the characters in * this are bitwise less than the characters in `text`, +1 if the * characters in this are bitwise greater than the characters * in `text`. * @stable ICU 2.0
*/ inline int8_t compare(const UnicodeString& text) const;
/** * Compare the characters bitwise in the range * [`start`, `start + length`) with the characters * in the **entire string** `text`. * (The parameters "start" and "length" are not applied to the other text "text".) * @param start the offset at which the compare operation begins * @param length the number of characters of text to compare. * @param text the other text to be compared against this string. * @return The result of bitwise character comparison: 0 if this * contains the same characters as `text`, -1 if the characters in * this are bitwise less than the characters in `text`, +1 if the * characters in this are bitwise greater than the characters * in `text`. * @stable ICU 2.0
*/ inline int8_t compare(int32_t start,
int32_t length, const UnicodeString& text) const;
/** * Compare the characters bitwise in the range * [`start`, `start + length`) with the characters * in `srcText` in the range * [`srcStart`, `srcStart + srcLength`). * @param start the offset at which the compare operation begins * @param length the number of characters in this to compare. * @param srcText the text to be compared * @param srcStart the offset into `srcText` to start comparison * @param srcLength the number of characters in `src` to compare * @return The result of bitwise character comparison: 0 if this * contains the same characters as `srcText`, -1 if the characters in * this are bitwise less than the characters in `srcText`, +1 if the * characters in this are bitwise greater than the characters * in `srcText`. * @stable ICU 2.0
*/ inline int8_t compare(int32_t start,
int32_t length, const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/** * Compare the characters bitwise in this UnicodeString with the first * `srcLength` characters in `srcChars`. * @param srcChars The characters to compare to this UnicodeString. * @param srcLength the number of characters in `srcChars` to compare * @return The result of bitwise character comparison: 0 if this * contains the same characters as `srcChars`, -1 if the characters in * this are bitwise less than the characters in `srcChars`, +1 if the * characters in this are bitwise greater than the characters * in `srcChars`. * @stable ICU 2.0
*/ inline int8_t compare(ConstChar16Ptr srcChars,
int32_t srcLength) const;
/** * Compare the characters bitwise in the range * [`start`, `start + length`) with the first * `length` characters in `srcChars` * @param start the offset at which the compare operation begins * @param length the number of characters to compare. * @param srcChars the characters to be compared * @return The result of bitwise character comparison: 0 if this * contains the same characters as `srcChars`, -1 if the characters in * this are bitwise less than the characters in `srcChars`, +1 if the * characters in this are bitwise greater than the characters * in `srcChars`. * @stable ICU 2.0
*/ inline int8_t compare(int32_t start,
int32_t length, const char16_t *srcChars) const;
/** * Compare the characters bitwise in the range * [`start`, `start + length`) with the characters * in `srcChars` in the range * [`srcStart`, `srcStart + srcLength`). * @param start the offset at which the compare operation begins * @param length the number of characters in this to compare * @param srcChars the characters to be compared * @param srcStart the offset into `srcChars` to start comparison * @param srcLength the number of characters in `srcChars` to compare * @return The result of bitwise character comparison: 0 if this * contains the same characters as `srcChars`, -1 if the characters in * this are bitwise less than the characters in `srcChars`, +1 if the * characters in this are bitwise greater than the characters * in `srcChars`. * @stable ICU 2.0
*/ inline int8_t compare(int32_t start,
int32_t length, const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/** * Compare the characters bitwise in the range * [`start`, `limit`) with the characters * in `srcText` in the range * [`srcStart`, `srcLimit`). * @param start the offset at which the compare operation begins * @param limit the offset immediately following the compare operation * @param srcText the text to be compared * @param srcStart the offset into `srcText` to start comparison * @param srcLimit the offset into `srcText` to limit comparison * @return The result of bitwise character comparison: 0 if this * contains the same characters as `srcText`, -1 if the characters in * this are bitwise less than the characters in `srcText`, +1 if the * characters in this are bitwise greater than the characters * in `srcText`. * @stable ICU 2.0
*/ inline int8_t compareBetween(int32_t start,
int32_t limit, const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param text Another string to compare this one to. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrder(const UnicodeString& text) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcText Another string to compare this one to. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrder(int32_t start,
int32_t length, const UnicodeString& srcText) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcText Another string to compare this one to. * @param srcStart The start offset in that string at which the compare operation begins. * @param srcLength The number of code units from that string to compare. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrder(int32_t start,
int32_t length, const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param srcChars A pointer to another string to compare this one to. * @param srcLength The number of code units from that string to compare. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrder(ConstChar16Ptr srcChars,
int32_t srcLength) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcChars A pointer to another string to compare this one to. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrder(int32_t start,
int32_t length, const char16_t *srcChars) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcChars A pointer to another string to compare this one to. * @param srcStart The start offset in that string at which the compare operation begins. * @param srcLength The number of code units from that string to compare. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrder(int32_t start,
int32_t length, const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/** * Compare two Unicode strings in code point order. * The result may be different from the results of compare(), operator<, etc. * if supplementary characters are present: * * In UTF-16, supplementary characters (with code points U+10000 and above) are * stored with pairs of surrogate code units. These have values from 0xd800 to 0xdfff, * which means that they compare as less than some other BMP characters like U+feff. * This function compares Unicode strings in code point order. * If either of the UTF-16 strings is malformed (i.e., it contains unpaired surrogates), then the result is not defined. * * @param start The start offset in this string at which the compare operation begins. * @param limit The offset after the last code unit from this string to compare. * @param srcText Another string to compare this one to. * @param srcStart The start offset in that string at which the compare operation begins. * @param srcLimit The offset after the last code unit from that string to compare. * @return a negative/zero/positive integer corresponding to whether * this string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0
*/ inline int8_t compareCodePointOrderBetween(int32_t start,
int32_t limit, const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compare(text.foldCase(options)). * * @param text Another string to compare this one to. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompare(const UnicodeString& text, uint32_t options) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)). * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcText Another string to compare this one to. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompare(int32_t start,
int32_t length, const UnicodeString& srcText,
uint32_t options) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compare(srcText.foldCase(options)). * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcText Another string to compare this one to. * @param srcStart The start offset in that string at which the compare operation begins. * @param srcLength The number of code units from that string to compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompare(int32_t start,
int32_t length, const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
uint32_t options) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)). * * @param srcChars A pointer to another string to compare this one to. * @param srcLength The number of code units from that string to compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompare(ConstChar16Ptr srcChars,
int32_t srcLength,
uint32_t options) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)). * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcChars A pointer to another string to compare this one to. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompare(int32_t start,
int32_t length, const char16_t *srcChars,
uint32_t options) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compare(srcChars.foldCase(options)). * * @param start The start offset in this string at which the compare operation begins. * @param length The number of code units from this string to compare. * @param srcChars A pointer to another string to compare this one to. * @param srcStart The start offset in that string at which the compare operation begins. * @param srcLength The number of code units from that string to compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompare(int32_t start,
int32_t length, const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength,
uint32_t options) const;
/** * Compare two strings case-insensitively using full case folding. * This is equivalent to this->foldCase(options).compareBetween(text.foldCase(options)). * * @param start The start offset in this string at which the compare operation begins. * @param limit The offset after the last code unit from this string to compare. * @param srcText Another string to compare this one to. * @param srcStart The start offset in that string at which the compare operation begins. * @param srcLimit The offset after the last code unit from that string to compare. * @param options A bit set of options: * - U_FOLD_CASE_DEFAULT or 0 is used for default options: * Comparison in code unit order with default case folding. * * - U_COMPARE_CODE_POINT_ORDER * Set to choose code point order instead of code unit order * (see u_strCompare for details). * * - U_FOLD_CASE_EXCLUDE_SPECIAL_I * * @return A negative, zero, or positive integer indicating the comparison result. * @stable ICU 2.0
*/ inline int8_t caseCompareBetween(int32_t start,
int32_t limit, const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLimit,
uint32_t options) const;
/** * Determine if this starts with the characters in `text` * @param text The text to match. * @return true if this starts with the characters in `text`, * false otherwise * @stable ICU 2.0
*/ inline UBool startsWith(const UnicodeString& text) const;
/** * Determine if this starts with the characters in `srcText` * in the range [`srcStart`, `srcStart + srcLength`). * @param srcText The text to match. * @param srcStart the offset into `srcText` to start matching * @param srcLength the number of characters in `srcText` to match * @return true if this starts with the characters in `text`, * false otherwise * @stable ICU 2.0
*/ inline UBool startsWith(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/** * Determine if this starts with the characters in `srcChars` * @param srcChars The characters to match. * @param srcLength the number of characters in `srcChars` * @return true if this starts with the characters in `srcChars`, * false otherwise * @stable ICU 2.0
*/ inline UBool startsWith(ConstChar16Ptr srcChars,
int32_t srcLength) const;
/** * Determine if this ends with the characters in `srcChars` * in the range [`srcStart`, `srcStart + srcLength`). * @param srcChars The characters to match. * @param srcStart the offset into `srcText` to start matching * @param srcLength the number of characters in `srcChars` to match * @return true if this ends with the characters in `srcChars`, false otherwise * @stable ICU 2.0
*/ inline UBool startsWith(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/** * Determine if this ends with the characters in `text` * @param text The text to match. * @return true if this ends with the characters in `text`, * false otherwise * @stable ICU 2.0
*/ inline UBool endsWith(const UnicodeString& text) const;
/** * Determine if this ends with the characters in `srcText` * in the range [`srcStart`, `srcStart + srcLength`). * @param srcText The text to match. * @param srcStart the offset into `srcText` to start matching * @param srcLength the number of characters in `srcText` to match * @return true if this ends with the characters in `text`, * false otherwise * @stable ICU 2.0
*/ inline UBool endsWith(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength) const;
/** * Determine if this ends with the characters in `srcChars` * @param srcChars The characters to match. * @param srcLength the number of characters in `srcChars` * @return true if this ends with the characters in `srcChars`, * false otherwise * @stable ICU 2.0
*/ inline UBool endsWith(ConstChar16Ptr srcChars,
int32_t srcLength) const;
/** * Determine if this ends with the characters in `srcChars` * in the range [`srcStart`, `srcStart + srcLength`). * @param srcChars The characters to match. * @param srcStart the offset into `srcText` to start matching * @param srcLength the number of characters in `srcChars` to match * @return true if this ends with the characters in `srcChars`, * false otherwise * @stable ICU 2.0
*/ inline UBool endsWith(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength) const;
/* Searching - bitwise only */
/** * Locate in this the first occurrence of the characters in `text`, * using bitwise comparison. * @param text The text to search for. * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(const UnicodeString& text) const;
/** * Locate in this the first occurrence of the characters in `text` * starting at offset `start`, using bitwise comparison. * @param text The text to search for. * @param start The offset at which searching will start. * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(const UnicodeString& text,
int32_t start) const;
/** * Locate in this the first occurrence in the range * [`start`, `start + length`) of the characters * in `text`, using bitwise comparison. * @param text The text to search for. * @param start The offset at which searching will start. * @param length The number of characters to search * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(const UnicodeString& text,
int32_t start,
int32_t length) const;
/** * Locate in this the first occurrence in the range * [`start`, `start + length`) of the characters * in `srcText` in the range * [`srcStart`, `srcStart + srcLength`), * using bitwise comparison. * @param srcText The text to search for. * @param srcStart the offset into `srcText` at which * to start matching * @param srcLength the number of characters in `srcText` to match * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
int32_t start,
int32_t length) const;
/** * Locate in this the first occurrence of the characters in * `srcChars` * starting at offset `start`, using bitwise comparison. * @param srcChars The text to search for. * @param srcLength the number of characters in `srcChars` to match * @param start the offset into this at which to start matching * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(const char16_t *srcChars,
int32_t srcLength,
int32_t start) const;
/** * Locate in this the first occurrence in the range * [`start`, `start + length`) of the characters * in `srcChars`, using bitwise comparison. * @param srcChars The text to search for. * @param srcLength the number of characters in `srcChars` * @param start The offset at which searching will start. * @param length The number of characters to search * @return The offset into this of the start of `srcChars`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(ConstChar16Ptr srcChars,
int32_t srcLength,
int32_t start,
int32_t length) const;
/** * Locate in this the first occurrence in the range * [`start`, `start + length`) of the characters * in `srcChars` in the range * [`srcStart`, `srcStart + srcLength`), * using bitwise comparison. * @param srcChars The text to search for. * @param srcStart the offset into `srcChars` at which * to start matching * @param srcLength the number of characters in `srcChars` to match * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/
int32_t indexOf(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength,
int32_t start,
int32_t length) const;
/** * Locate in this the first occurrence of the BMP code point `c`, * using bitwise comparison. * @param c The code unit to search for. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(char16_t c) const;
/** * Locate in this the first occurrence of the code point `c`, * using bitwise comparison. * * @param c The code point to search for. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(UChar32 c) const;
/** * Locate in this the first occurrence of the BMP code point `c`, * starting at offset `start`, using bitwise comparison. * @param c The code unit to search for. * @param start The offset at which searching will start. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(char16_t c,
int32_t start) const;
/** * Locate in this the first occurrence of the code point `c` * starting at offset `start`, using bitwise comparison. * * @param c The code point to search for. * @param start The offset at which searching will start. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(UChar32 c,
int32_t start) const;
/** * Locate in this the first occurrence of the BMP code point `c` * in the range [`start`, `start + length`), * using bitwise comparison. * @param c The code unit to search for. * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(char16_t c,
int32_t start,
int32_t length) const;
/** * Locate in this the first occurrence of the code point `c` * in the range [`start`, `start + length`), * using bitwise comparison. * * @param c The code point to search for. * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t indexOf(UChar32 c,
int32_t start,
int32_t length) const;
/** * Locate in this the last occurrence of the characters in `text`, * using bitwise comparison. * @param text The text to search for. * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(const UnicodeString& text) const;
/** * Locate in this the last occurrence of the characters in `text` * starting at offset `start`, using bitwise comparison. * @param text The text to search for. * @param start The offset at which searching will start. * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(const UnicodeString& text,
int32_t start) const;
/** * Locate in this the last occurrence in the range * [`start`, `start + length`) of the characters * in `text`, using bitwise comparison. * @param text The text to search for. * @param start The offset at which searching will start. * @param length The number of characters to search * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(const UnicodeString& text,
int32_t start,
int32_t length) const;
/** * Locate in this the last occurrence in the range * [`start`, `start + length`) of the characters * in `srcText` in the range * [`srcStart`, `srcStart + srcLength`), * using bitwise comparison. * @param srcText The text to search for. * @param srcStart the offset into `srcText` at which * to start matching * @param srcLength the number of characters in `srcText` to match * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(const UnicodeString& srcText,
int32_t srcStart,
int32_t srcLength,
int32_t start,
int32_t length) const;
/** * Locate in this the last occurrence of the characters in `srcChars` * starting at offset `start`, using bitwise comparison. * @param srcChars The text to search for. * @param srcLength the number of characters in `srcChars` to match * @param start the offset into this at which to start matching * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(const char16_t *srcChars,
int32_t srcLength,
int32_t start) const;
/** * Locate in this the last occurrence in the range * [`start`, `start + length`) of the characters * in `srcChars`, using bitwise comparison. * @param srcChars The text to search for. * @param srcLength the number of characters in `srcChars` * @param start The offset at which searching will start. * @param length The number of characters to search * @return The offset into this of the start of `srcChars`, * or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(ConstChar16Ptr srcChars,
int32_t srcLength,
int32_t start,
int32_t length) const;
/** * Locate in this the last occurrence in the range * [`start`, `start + length`) of the characters * in `srcChars` in the range * [`srcStart`, `srcStart + srcLength`), * using bitwise comparison. * @param srcChars The text to search for. * @param srcStart the offset into `srcChars` at which * to start matching * @param srcLength the number of characters in `srcChars` to match * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of the start of `text`, * or -1 if not found. * @stable ICU 2.0
*/
int32_t lastIndexOf(const char16_t *srcChars,
int32_t srcStart,
int32_t srcLength,
int32_t start,
int32_t length) const;
/** * Locate in this the last occurrence of the BMP code point `c`, * using bitwise comparison. * @param c The code unit to search for. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(char16_t c) const;
/** * Locate in this the last occurrence of the code point `c`, * using bitwise comparison. * * @param c The code point to search for. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(UChar32 c) const;
/** * Locate in this the last occurrence of the BMP code point `c` * starting at offset `start`, using bitwise comparison. * @param c The code unit to search for. * @param start The offset at which searching will start. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(char16_t c,
int32_t start) const;
/** * Locate in this the last occurrence of the code point `c` * starting at offset `start`, using bitwise comparison. * * @param c The code point to search for. * @param start The offset at which searching will start. * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(UChar32 c,
int32_t start) const;
/** * Locate in this the last occurrence of the BMP code point `c` * in the range [`start`, `start + length`), * using bitwise comparison. * @param c The code unit to search for. * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(char16_t c,
int32_t start,
int32_t length) const;
/** * Locate in this the last occurrence of the code point `c` * in the range [`start`, `start + length`), * using bitwise comparison. * * @param c The code point to search for. * @param start the offset into this at which to start matching * @param length the number of characters in this to search * @return The offset into this of `c`, or -1 if not found. * @stable ICU 2.0
*/ inline int32_t lastIndexOf(UChar32 c,
int32_t start,
int32_t length) const;
/* Character access */
/** * Return the code unit at offset `offset`. * If the offset is not valid (0..length()-1) then U+ffff is returned. * @param offset a valid offset into the text * @return the code unit at offset `offset` * or 0xffff if the offset is not valid for this string * @stable ICU 2.0
*/ inline char16_t charAt(int32_t offset) const;
/** * Return the code unit at offset `offset`. * If the offset is not valid (0..length()-1) then U+ffff is returned. * @param offset a valid offset into the text * @return the code unit at offset `offset` * @stable ICU 2.0
*/ inline char16_t operator[] (int32_t offset) const;
/** * Return the code point that contains the code unit * at offset `offset`. * If the offset is not valid (0..length()-1) then U+ffff is returned. * @param offset a valid offset into the text * that indicates the text offset of any of the code units * that will be assembled into a code point (21-bit value) and returned * @return the code point of text at `offset` * or 0xffff if the offset is not valid for this string * @stable ICU 2.0
*/
UChar32 char32At(int32_t offset) const;
/** * Adjust a random-access offset so that * it points to the beginning of a Unicode character. * The offset that is passed in points to * any code unit of a code point, * while the returned offset will point to the first code unit * of the same code point. * In UTF-16, if the input offset points to a second surrogate * of a surrogate pair, then the returned offset will point * to the first surrogate. * @param offset a valid offset into one code point of the text * @return offset of the first code unit of the same code point * @see U16_SET_CP_START * @stable ICU 2.0
*/
int32_t getChar32Start(int32_t offset) const;
/** * Adjust a random-access offset so that * it points behind a Unicode character. * The offset that is passed in points behind * any code unit of a code point, * while the returned offset will point behind the last code unit * of the same code point. * In UTF-16, if the input offset points behind the first surrogate * (i.e., to the second surrogate) * of a surrogate pair, then the returned offset will point * behind the second surrogate (i.e., to the first surrogate). * @param offset a valid offset after any code unit of a code point of the text * @return offset of the first code unit after the same code point * @see U16_SET_CP_LIMIT * @stable ICU 2.0
*/
int32_t getChar32Limit(int32_t offset) const;
/** * Move the code unit index along the string by delta code points. * Interpret the input index as a code unit-based offset into the string, * move the index forward or backward by delta code points, and * return the resulting index. * The input index should point to the first code unit of a code point, * if there is more than one. * * Both input and output indexes are code unit-based as for all * string indexes/offsets in ICU (and other libraries, like MBCS char*). * If delta<0 then the index is moved backward (toward the start of the string). * If delta>0 then the index is moved forward (toward the end of the string). * * This behaves like CharacterIterator::move32(delta, kCurrent). * * Behavior for out-of-bounds indexes: * `moveIndex32` pins the input index to 0..length(), i.e., * if the input index<0 then it is pinned to 0; * if it is index>length() then it is pinned to length(). * Afterwards, the index is moved by `delta` code points * forward or backward, * but no further backward than to 0 and no further forward than to length(). * The resulting index return value will be in between 0 and length(), inclusively. * * Examples: * \code * // s has code points 'a' U+10000 'b' U+10ffff U+2029 * UnicodeString s(u"a\U00010000b\U0010ffff\u2029"); * * // initial index: position of U+10000 * int32_t index=1; * * // the following examples will all result in index==4, position of U+10ffff * * // skip 2 code points from some position in the string * index=s.moveIndex32(index, 2); // skips U+10000 and 'b' * * // go to the 3rd code point from the start of s (0-based) * index=s.moveIndex32(0, 3); // skips 'a', U+10000, and 'b' * * // go to the next-to-last code point of s * index=s.moveIndex32(s.length(), -2); // backward-skips U+2029 and U+10ffff * \endcode * * @param index input code unit index * @param delta (signed) code point count to move the index forward or backward * in the string * @return the resulting code unit index * @stable ICU 2.0
*/
int32_t moveIndex32(int32_t index, int32_t delta) const;
/* Substring extraction */
/** * Copy the characters in the range * [`start`, `start + length`) into the array `dst`, * beginning at `dstStart`. * If the string aliases to `dst` itself as an external buffer, * then extract() will not copy the contents. * * @param start offset of first character which will be copied into the array * @param length the number of characters to extract * @param dst array in which to copy characters. The length of `dst` * must be at least (`dstStart + length`). * @param dstStart the offset in `dst` where the first character * will be extracted * @stable ICU 2.0
*/ inlinevoid extract(int32_t start,
int32_t length,
Char16Ptr dst,
int32_t dstStart = 0) const;
/** * Copy the contents of the string into dest. * This is a convenience function that * checks if there is enough space in dest, * extracts the entire string if possible, * and NUL-terminates dest if possible. * * If the string fits into dest but cannot be NUL-terminated * (length()==destCapacity) then the error code is set to U_STRING_NOT_TERMINATED_WARNING. * If the string itself does not fit into dest * (length()>destCapacity) then the error code is set to U_BUFFER_OVERFLOW_ERROR. * * If the string aliases to `dest` itself as an external buffer, * then extract() will not copy the contents. * * @param dest Destination string buffer. * @param destCapacity Number of char16_ts available at dest. * @param errorCode ICU error code. * @return length() * @stable ICU 2.0
*/
int32_t
extract(Char16Ptr dest, int32_t destCapacity,
UErrorCode &errorCode) const;
/** * Copy the characters in the range * [`start`, `start + length`) into the UnicodeString * `target`. * @param start offset of first character which will be copied * @param length the number of characters to extract * @param target UnicodeString into which to copy characters. * @stable ICU 2.0
*/ inlinevoid extract(int32_t start,
int32_t length,
UnicodeString& target) const;
/** * Copy the characters in the range [`start`, `limit`) * into the array `dst`, beginning at `dstStart`. * @param start offset of first character which will be copied into the array * @param limit offset immediately following the last character to be copied * @param dst array in which to copy characters. The length of `dst` * must be at least (`dstStart + (limit - start)`). * @param dstStart the offset in `dst` where the first character * will be extracted * @stable ICU 2.0
*/ inlinevoid extractBetween(int32_t start,
int32_t limit,
char16_t *dst,
int32_t dstStart = 0) const;
/** * Copy the characters in the range [`start`, `limit`) * into the UnicodeString `target`. Replaceable API. * @param start offset of first character which will be copied * @param limit offset immediately following the last character to be copied * @param target UnicodeString into which to copy characters. * @stable ICU 2.0
*/ virtualvoid extractBetween(int32_t start,
int32_t limit,
UnicodeString& target) const override;
/** * Copy the characters in the range * [`start`, `start + startLength`) into an array of characters. * All characters must be invariant (see utypes.h). * Use US_INV as the last, signature-distinguishing parameter. * * This function does not write any more than `targetCapacity` * characters but returns the length of the entire output string * so that one can allocate a larger buffer and call the function again * if necessary. * The output string is NUL-terminated if possible. * * @param start offset of first character which will be copied * @param startLength the number of characters to extract * @param target the target buffer for extraction, can be nullptr * if targetLength is 0 * @param targetCapacity the length of the target buffer * @param inv Signature-distinguishing parameter, use US_INV. * @return the output string length, not including the terminating NUL * @stable ICU 3.2
*/
int32_t extract(int32_t start,
int32_t startLength, char *target,
int32_t targetCapacity, enum EInvariant inv) const;
#if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
/** * Copy the characters in the range * [`start`, `start + length`) into an array of characters * in the platform's default codepage. * This function does not write any more than `targetLength` * characters but returns the length of the entire output string * so that one can allocate a larger buffer and call the function again * if necessary. * The output string is NUL-terminated if possible. * * @param start offset of first character which will be copied * @param startLength the number of characters to extract * @param target the target buffer for extraction * @param targetLength the length of the target buffer * If `target` is nullptr, then the number of bytes required for * `target` is returned. * @return the output string length, not including the terminating NUL * @stable ICU 2.0
*/
int32_t extract(int32_t start,
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5
¤ Dauer der Verarbeitung: 0.40 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.