1 | static S quoteBorderless(O o) { |
2 | if (o == null) return "null"; |
3 | ret quoteBorderless(str(o)); |
4 | } |
5 | |
6 | static S quoteBorderless(S s) { |
7 | if (s == null) return "null"; |
8 | StringBuilder out = new StringBuilder((int) (l(s)*1.5)); |
9 | quoteBorderless_impl(s, out); |
10 | ret out.toString(); |
11 | } |
12 | |
13 | static void quoteBorderless_impl(S s, StringBuilder out) { |
14 | int l = s.length(); |
15 | for (int i = 0; i < l; i++) { |
16 | char c = s.charAt(i); |
17 | if (c == '\\' || c == '"') |
18 | out.append('\\').append(c); |
19 | else if (c == '\r') |
20 | out.append("\\r"); |
21 | else if (c == '\n') |
22 | out.append("\\n"); |
23 | else |
24 | out.append(c); |
25 | } |
26 | } |
Began life as a copy of #1005595
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
Snippet ID: | #1012823 |
Snippet name: | quoteBorderless - quote() without surrounding double quotes |
Eternal ID of this version: | #1012823/1 |
Text MD5: | f1cecf5549888474b834cf303ffdac5a |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-13 23:36:58 |
Source code size: | 642 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 521 / 713 |
Referenced in: | [show references] |