static S fixNewLines(S s) { int i = indexOf(s, '\r'); if (i < 0) ret s; int l = s.length(); StringBuilder out = new(l); out.append(s, 0, i); for (; i < l; i++) { char c = s.charAt(i); if (c != '\r') out.append(c); else { out.append('\n'); if (i+1 < l && s.charAt(i+1) == '\n') ++i; } } ret out.toString(); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006746 |
Snippet name: | fixNewLines - convert both sole \r and \r\n to \n |
Eternal ID of this version: | #1006746/4 |
Text MD5: | 5982ac1dede891004b234a6fd935da8e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-12 15:01:59 |
Source code size: | 373 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 682 / 713 |
Version history: | 3 change(s) |
Referenced in: | [show references] |