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

#define U8_NEXT ( s,
i,
length,
 ) 

Value:

{ \
    (c)=(uint8_t)(s)[(i)++]; \
    if((c)>=0x80) { \
        uint8_t __t1, __t2; \
        if( /* handle U+1000..U+CFFF inline */ \
            (0xe0<(c) && (c)<=0xec) && \
            (((i)+1)<(length)) && \
            (__t1=(uint8_t)((s)[i]-0x80))<=0x3f && \
            (__t2=(uint8_t)((s)[(i)+1]-0x80))<= 0x3f \
        ) { \
            /* no need for (c&0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */ \
            (c)=(UChar)(((c)<<12)|(__t1<<6)|__t2); \
            (i)+=2; \
        } else if( /* handle U+0080..U+07FF inline */ \
            ((c)<0xe0 && (c)>=0xc2) && \
            ((i)<(length)) && \
            (__t1=(uint8_t)((s)[i]-0x80))<=0x3f \
        ) { \
            (c)=(UChar)((((c)&0x1f)<<6)|__t1); \
            ++(i); \
        } else if(U8_IS_LEAD(c)) { \
            /* function call for "complicated" and error cases */ \
            (c)=utf8_nextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -1); \
        } else { \
            (c)=U_SENTINEL; \
        } \
    } \
}
Get a code point from a string at a code point boundary offset, and advance the offset to the next code point boundary. (Post-incrementing forward iteration.) "Safe" macro, checks for illegal sequences and for string boundaries.

The offset may point to the lead byte of a multi-byte sequence, in which case the macro will read the whole sequence. If the offset points to a trail byte or an illegal UTF-8 sequence, then c is set to a negative value.

Parameters:
s const uint8_t * string
i string offset, must be i<length
length string length
c output UChar32 variable, set to <0 in case of an error
See also:
U8_NEXT_UNSAFE ICU 2.4

Definition at line 283 of file utf8.h.

Referenced by UnicodeSet::spanUTF8().


Generated by  Doxygen 1.6.0   Back to index