static S singleQuote(O o) { if (o == null) return "null"; ret singleQuote(str(o)); } static S singleQuote(S s) { if (s == null) return "null"; StringBuilder out = new StringBuilder((int) (l(s)*1.5+2)); singleQuote_impl(s, out); ret out.toString(); } static void singleQuote_impl(S s, StringBuilder out) { out.append('\''); int l = s.length(); for (int i = 0; i < l; i++) { char c = s.charAt(i); if (c == '\\' || c == '\'') out.append('\\').append(c); else if (c == '\r') out.append("\\r"); else if (c == '\n') out.append("\\n"); else out.append(c); } out.append('\''); }
Began life as a copy of #1005595
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009089 |
Snippet name: | singleQuote - enclose string in single quotes ('); doesn't escape "; not a Java construct |
Eternal ID of this version: | #1009089/5 |
Text MD5: | 3a817199794449dd9a4d2973f9c63edc |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-02 17:17:49 |
Source code size: | 667 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 449 / 507 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |