ICU-400 add u_strchr32()

X-SVN-Rev: 1706
This commit is contained in:
Markus Scherer 2000-06-29 19:00:55 +00:00
parent 68fe01cfa0
commit c685f44e89
2 changed files with 27 additions and 0 deletions

View file

@ -76,6 +76,20 @@ u_strchr(const UChar *s,
U_CAPI UChar * U_EXPORT2
u_strstr(const UChar *s, const UChar *substring);
/**
* Find the first occurence of a specified code point in a string.
*
* @param s The string to search.
* @param c The code point (0..0x10ffff) to find.
* @return A pointer to the first occurrence of <code>c</code> in <code>s</code>,
* or a <code>NULL</code> pointer if there is no such character.
* If <code>c</code> is represented with several UChars, then the returned
* pointer will point to the first of them.
* @draft
*/
U_CAPI UChar * U_EXPORT2
u_strchr32(const UChar *s, UChar32 c);
/**
* Compare two ustrings for bitwise equality.
*

View file

@ -103,6 +103,19 @@ u_strstr(const UChar *s, const UChar *substring) {
}
}
U_CAPI UChar * U_EXPORT2
u_strchr32(const UChar *s, UChar32 c) {
if(!UTF_NEED_MULTIPLE_UCHAR(c)) {
return u_strchr(s, (UChar)c);
} else {
UChar buffer[UTF_MAX_CHAR_LENGTH + 1];
UTextOffset i = 0;
UTF_APPEND_CHAR_UNSAFE(buffer, i, c);
buffer[i] = 0;
return u_strstr(s, buffer);
}
}
int32_t
u_strcmp(const UChar *s1,
const UChar *s2)