public static int next32 ( CharacterIterator ci ) { // If the current position is at a surrogate pair, move to the trail surrogate // which leaves it in position for underlying iterator's next() to work. int c = ci . current ( ) ; if ( c >= UTF16 . LEAD_SURROGATE_MIN_VALUE && c <= UTF16 . LEAD_SURROGATE_MAX_VALUE ) { c = ci . next ( ) ; if ( c < UTF16 . TRAIL_SURROGATE_MIN_VALUE || c > UTF16 . TRAIL_SURROGATE_MAX_VALUE ) { ci . previous ( ) ; } } // For BMP chars, this next() is the real deal. c = ci . next ( ) ; // If we might have a lead surrogate, we need to peak ahead to get the trail // even though we don't want to really be positioned there. if ( c >= UTF16 . LEAD_SURROGATE_MIN_VALUE ) { c = nextTrail32 ( ci , c ) ; } if ( c >= UTF16 . SUPPLEMENTARY_MIN_VALUE && c != DONE32 ) { // We got a supplementary char. Back the iterator up to the postion // of the lead surrogate. ci . previous ( ) ; } return c ; }
Move the iterator forward to the next code point and return that code point leaving the iterator positioned at char returned . For Supplementary chars the iterator is left positioned at the lead surrogate .