public int currentCodePoint ( ) { int ch = current ( ) ; if ( UTF16 . isLeadSurrogate ( ( char ) ch ) ) { // advance the index to get the // next code point next ( ) ; // due to post increment semantics // current() after next() actually // returns the char we want int ch2 = current ( ) ; // current should never change // the current index so back off previous ( ) ; if ( UTF16 . isTrailSurrogate ( ( char ) ch2 ) ) { // we found a surrogate pair // return the codepoint return Character . toCodePoint ( ( char ) ch , ( char ) ch2 ) ; } } return ch ; }
Returns the codepoint at the current index . If the current index is invalid DONE is returned . If the current index points to a lead surrogate and there is a following trail surrogate then the code point is returned . Otherwise the code unit at index is returned . Index is not changed .