📄 ustring.h
字号:
* @param string The string in which to search, NUL-terminated. * @param matchSet A NUL-terminated string defining a set of code points * for which to search in the text string. * @return A pointer to the character in <code>string</code> that matches one of the * characters in <code>matchSet</code>, or NULL if no such character is found. * @stable ICU 2.0 */U_STABLE UChar * U_EXPORT2u_strpbrk(const UChar *string, const UChar *matchSet);/** * Returns the number of consecutive characters in <code>string</code>, * beginning with the first, that do not occur somewhere in <code>matchSet</code>. * Works just like C's strcspn but with Unicode. * * @param string The string in which to search, NUL-terminated. * @param matchSet A NUL-terminated string defining a set of code points * for which to search in the text string. * @return The number of initial characters in <code>string</code> that do not * occur in <code>matchSet</code>. * @see u_strspn * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2u_strcspn(const UChar *string, const UChar *matchSet);/** * Returns the number of consecutive characters in <code>string</code>, * beginning with the first, that occur somewhere in <code>matchSet</code>. * Works just like C's strspn but with Unicode. * * @param string The string in which to search, NUL-terminated. * @param matchSet A NUL-terminated string defining a set of code points * for which to search in the text string. * @return The number of initial characters in <code>string</code> that do * occur in <code>matchSet</code>. * @see u_strcspn * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2u_strspn(const UChar *string, const UChar *matchSet);/** * The string tokenizer API allows an application to break a string into * tokens. Unlike strtok(), the saveState (the current pointer within the * original string) is maintained in saveState. In the first call, the * argument src is a pointer to the string. In subsequent calls to * return successive tokens of that string, src must be specified as * NULL. The value saveState is set by this function to maintain the * function's position within the string, and on each subsequent call * you must give this argument the same variable. This function does * handle surrogate pairs. This function is similar to the strtok_r() * the POSIX Threads Extension (1003.1c-1995) version. * * @param src String containing token(s). This string will be modified. * After the first call to u_strtok_r(), this argument must * be NULL to get to the next token. * @param delim Set of delimiter characters (Unicode code points). * @param saveState The current pointer within the original string, * which is set by this function. The saveState * parameter should the address of a local variable of type * UChar *. (i.e. defined "Uhar *myLocalSaveState" and use * &myLocalSaveState for this parameter). * @return A pointer to the next token found in src, or NULL * when there are no more tokens. * @stable ICU 2.0 */U_STABLE UChar * U_EXPORT2u_strtok_r(UChar *src, const UChar *delim, UChar **saveState);/** * Compare two Unicode strings for bitwise equality (code unit order). * * @param s1 A string to compare. * @param s2 A string to compare. * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive * value if <code>s1</code> is bitwise greater than <code>s2</code>. * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2u_strcmp(const UChar *s1, const UChar *s2);/** * Compare two Unicode strings in code point order. * See u_strCompare for details. * * @param s1 A string to compare. * @param s2 A string to compare. * @return a negative/zero/positive integer corresponding to whether * the first string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);/** * Compare two Unicode strings (binary order). * * The comparison can be done in code unit order or in code point order. * They differ only in UTF-16 when * comparing supplementary code points (U+10000..U+10ffff) * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). * In code unit order, high BMP code points sort after supplementary code points * because they are stored as pairs of surrogates which are at U+d800..U+dfff. * * This functions works with strings of different explicitly specified lengths * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. * NUL-terminated strings are possible with length arguments of -1. * * @param s1 First source string. * @param length1 Length of first source string, or -1 if NUL-terminated. * * @param s2 Second source string. * @param length2 Length of second source string, or -1 if NUL-terminated. * * @param codePointOrder Choose between code unit order (FALSE) * and code point order (TRUE). * * @return <0 or 0 or >0 as usual for string comparisons * * @stable ICU 2.2 */U_STABLE int32_t U_EXPORT2u_strCompare(const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, UBool codePointOrder);/** * Compare two Unicode strings (binary order) * as presented by UCharIterator objects. * Works otherwise just like u_strCompare(). * * Both iterators are reset to their start positions. * When the function returns, it is undefined where the iterators * have stopped. * * @param iter1 First source string iterator. * @param iter2 Second source string iterator. * @param codePointOrder Choose between code unit order (FALSE) * and code point order (TRUE). * * @return <0 or 0 or >0 as usual for string comparisons * * @see u_strCompare * * @stable ICU 2.6 */U_STABLE int32_t U_EXPORT2u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder);#ifndef U_COMPARE_CODE_POINT_ORDER/* see also unistr.h and unorm.h *//** * Option bit for u_strCaseCompare, u_strcasecmp, unorm_compare, etc: * Compare strings in code point order instead of code unit order. * @stable ICU 2.2 */#define U_COMPARE_CODE_POINT_ORDER 0x8000#endif/** * Compare two strings case-insensitively using full case folding. * This is equivalent to * u_strCompare(u_strFoldCase(s1, options), * u_strFoldCase(s2, options), * (options&U_COMPARE_CODE_POINT_ORDER)!=0). * * The comparison can be done in UTF-16 code unit order or in code point order. * They differ only when comparing supplementary code points (U+10000..U+10ffff) * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). * In code unit order, high BMP code points sort after supplementary code points * because they are stored as pairs of surrogates which are at U+d800..U+dfff. * * This functions works with strings of different explicitly specified lengths * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. * NUL-terminated strings are possible with length arguments of -1. * * @param s1 First source string. * @param length1 Length of first source string, or -1 if NUL-terminated. * * @param s2 Second source string. * @param length2 Length of second source string, or -1 if NUL-terminated. * * @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 * * @param pErrorCode Must be a valid pointer to an error code value, * which must not indicate a failure before the function call. * * @return <0 or 0 or >0 as usual for string comparisons * * @stable ICU 2.2 */U_STABLE int32_t U_EXPORT2u_strCaseCompare(const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, uint32_t options, UErrorCode *pErrorCode);/** * Compare two ustrings for bitwise equality. * Compares at most <code>n</code> characters. * * @param ucs1 A string to compare. * @param ucs2 A string to compare. * @param n The maximum number of characters to compare. * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive * value if <code>s1</code> is bitwise greater than <code>s2</code>. * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2u_strncmp(const UChar *ucs1, const UChar *ucs2, int32_t n);/** * Compare two Unicode strings in code point order. * This is different in UTF-16 from u_strncmp() if supplementary characters are present. * For details, see u_strCompare(). * * @param s1 A string to compare. * @param s2 A string to compare. * @param n The maximum number of characters to compare. * @return a negative/zero/positive integer corresponding to whether * the first string is less than/equal to/greater than the second one * in code point order * @stable ICU 2.0 */U_STABLE int32_t U_EXPORT2u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);/** * Compare two strings case-insensitively using full case folding. * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)). * * @param s1 A string to compare. * @param s2 A 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 */U_STABLE int32_t U_EXPORT2u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);/** * Compare two strings case-insensitively using full case folding. * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options), * u_strFoldCase(s2, at most n, options)). * * @param s1 A string to compare. * @param s2 A string to compare. * @param n The maximum number of characters each string to case-fold and then 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 */U_STABLE int32_t U_EXPORT2u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);/** * Compare two strings case-insensitively using full case folding. * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options), * u_strFoldCase(s2, n, options)). * * @param s1 A string to compare. * @param s2 A string to compare. * @param length The number of characters in each string to case-fold and then 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 */U_STABLE int32_t U_EXPORT2u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options);/** * Copy a ustring. Adds a null terminator. * * @param dst The destination string. * @param src The source string. * @return A pointer to <code>dst</code>. * @stable ICU 2.0 */U_STABLE UChar* U_EXPORT2u_strcpy(UChar *dst, const UChar *src);/** * Copy a ustring. * Copies at most <code>n</code> characters. The result will be null terminated * if the length of <code>src</code> is less than <code>n</code>. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -