Libraryless. Click here for Pure Java version (9957L/56K).
static LineAndColumn charIndexToLineAndColumn(S text, int charIndex) { int line = 1, col = 1; charIndex = min(charIndex, l(text)); for i to charIndex: { if (text.charAt(i) == '\n') { ++line; col = 1; } else ++col; } ret LineAndColumn(line, col); }
Began life as a copy of #1033994
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036420 |
Snippet name: | charIndexToLineAndColumn |
Eternal ID of this version: | #1036420/4 |
Text MD5: | d0a9907552d7121c48429951186b2421 |
Transpilation MD5: | 0b96cb9cf1001ce86925061bb3817117 |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-12-11 18:15:29 |
Source code size: | 294 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 122 / 184 |
Version history: | 3 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |