public static String makeJavaStringLiteral(String text) {
if (text == null) return null;
return "\"" + text
.replace("\\", "\\\\")
.replace("\"", "\\\"")
.replace("\n", "\\n")
.replace("\r", "\\r") + "\"";
}
Snippet is not live.
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
2 comment(s) hidden. show
| Snippet ID: | #2000331 |
| Snippet name: | makeJavaStringLiteral |
| Eternal ID of this version: | #2000331/1 |
| Text MD5: | b9396f44d54e82f99280ae331cf3dcd6 |
| Author: | stefan |
| Category: | |
| Type: | New Tinybrain snippet |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-05-04 17:15:04 |
| Source code size: | 252 bytes / 8 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1716 / 959 |
| Referenced in: | #698 - Standard Function Adder (new, developing) #1000265 - Standard Function Adder #1002427 - Accellerating 629 (SPIKE) #1006654 - Standard functions list 2 (LIVE, continuation of #761) #3000382 - Answer for ferdie (>> t = 1, f = 0) |