int (CharSequence seq, int startOffset, int endOffset, int tabSize) { int result = 0; for (int i = startOffset; i < endOffset; i++) { if (seq.charAt(i) == '\t') { result = (result / tabSize + 1) * tabSize; } else { result++; } } return result; }