auto x = "\nx\n y\rz"; assert(x.length == 7); assert(x.scanLineColumnToOffset(Offset(0)) == LineColumn(0, 0)); assert(x.scanLineColumnToOffset(Offset(1)) == LineColumn(1, 0)); assert(x.scanLineColumnToOffset(Offset(2)) == LineColumn(1, 1)); assert(x.scanLineColumnToOffset(Offset(3)) == LineColumn(2, 0)); assert(x.scanLineColumnToOffset(Offset(4)) == LineColumn(2, 1)); assert(x.scanLineColumnToOffset(Offset(6)) == LineColumn(3, 0)); assert(x.scanLineColumnToOffset(Offset(7)) == LineColumn(3, 1));
Convert byte offset offset in txt to (line, column) byte offsets.
The returned line byte offset and column byte offsets both start at zero.
TODO: extend to support UTF-8 in column offset. TODO: Move to Phobos std.txting?