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

U_STABLE UChar32 U_EXPORT2 utext_next32 ( UText ut  ) 

Get the code point at the current iteration position of the UText, and advance the position to the first index following the character.

If the position is at the end of the text (the index following the last character, which is also the length of the text), return U_SENTINEL (-1) and do not advance the index.

This is a post-increment operation.

An inline macro version of this function, UTEXT_NEXT32(), is available for performance critical use.

Parameters:
ut the text to be accessed.
Returns:
the Unicode code point at the iteration position.
See also:
UTEXT_NEXT32 ICU 3.4

Definition at line 262 of file utext.cpp.

References UTextFuncs::access, UText::chunkContents, UText::chunkLength, UText::chunkNativeLimit, UText::chunkOffset, FALSE, UText::pFuncs, TRUE, U16_GET_SUPPLEMENTARY, U16_IS_LEAD, U16_IS_TRAIL, and U_SENTINEL.

                        {
    UChar32       c;

    if (ut->chunkOffset >= ut->chunkLength) {
        if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) {
            return U_SENTINEL;
        }
    }

    c = ut->chunkContents[ut->chunkOffset++];
    if (U16_IS_LEAD(c) == FALSE) {
        // Normal case, not supplementary.
        //   (A trail surrogate seen here is just returned as is, as a surrogate value.
        //    It cannot be part of a pair.)
        return c;
    }

    if (ut->chunkOffset >= ut->chunkLength) {
        if (ut->pFuncs->access(ut, ut->chunkNativeLimit, TRUE) == FALSE) {
            // c is an unpaired lead surrogate at the end of the text.
            // return it as it is.
            return c;
        }
    }
    UChar32 trail = ut->chunkContents[ut->chunkOffset];
    if (U16_IS_TRAIL(trail) == FALSE) {
        // c was an unpaired lead surrogate, not at the end of the text.
        // return it as it is (unpaired).  Iteration position is on the
        // following character, possibly in the next chunk, where the
        //  trail surrogate would have been if it had existed.
        return c;
    }

    UChar32 supplementary = U16_GET_SUPPLEMENTARY(c, trail);
    ut->chunkOffset++;   // move iteration position over the trail surrogate.
    return supplementary;
    }


Generated by  Doxygen 1.6.0   Back to index