private static int determineConsecutiveTextCount ( CharSequence msg , int startpos ) { int len = msg . length ( ) ; int idx = startpos ; while ( idx < len ) { char ch = msg . charAt ( idx ) ; int numericCount = 0 ; while ( numericCount < 13 && isDigit ( ch ) && idx < len ) { numericCount ++ ; idx ++ ; if ( idx < len ) { ch = msg . charAt ( idx ) ; } } if ( numericCount >= 13 ) { return idx - startpos - numericCount ; } if ( numericCount > 0 ) { //Heuristic: All text-encodable chars or digits are binary encodable continue ; } ch = msg . charAt ( idx ) ; //Check if character is encodable if ( ! isText ( ch ) ) { break ; } idx ++ ; } return idx - startpos ; }
Determines the number of consecutive characters that are encodable using text compaction .