static int lineNrToCharIndex(S s, int lineNr) { int i = 0; while (--lineNr > 0) i = smartIndexOf(s, '\n', i)+1; ret i; }