Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE UChar* U_EXPORT2 u_memrchr32 ( const UChar *  s,
UChar32  c,
int32_t  count 

Find the last occurrence of a code point in a string. A surrogate code point is found only if its match in the text is not part of a surrogate pair. A NUL character is found at the string terminator.

s The string to search (contains count UChars).
c The code point to find.
count The length of the string.
A pointer to the last occurrence of c in s or NULL if c is not in s. ICU 2.4
See also:



Definition at line 431 of file ustring.c.

References NULL, U16_LEAD, U16_TRAIL, and UCHAR_MAX_VALUE.

    if((uint32_t)c<=U_BMP_MAX) {
        /* find BMP code point */
        return u_memrchr(s, (UChar)c, count);
    } else if(count<2) {
        /* too short for a surrogate pair */
        return NULL;
    } else if((uint32_t)c<=UCHAR_MAX_VALUE) {
        /* find supplementary code point as surrogate pair */
        const UChar *limit=s+count-1;
        UChar lead=U16_LEAD(c), trail=U16_TRAIL(c);

        do {
            if(*limit==trail && *(limit-1)==lead) {
                return (UChar *)(limit-1);
        } while(s!=--limit);
        return NULL;
    } else {
        /* not a Unicode code point, not findable */
        return NULL;

Generated by  Doxygen 1.6.0   Back to index