Libraryless. Click here for Pure Java version (2559L/16K).
// this should be on by default now I think, but it may break // legacy code... static new ThreadLocal<Bool> htmlencode_forParams_useV2; sS htmlencode_forParams(S s) { if (s == null) ret ""; if (isTrue(htmlencode_forParams_useV2!)) ret htmlencode_forParams_v2(s); StringBuilder out = new StringBuilder(Math.max(16, s.length())); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c > 127 || c == '"' || c == '<' || c == '>') { out.append("&#"); out.append((int) c); out.append(';'); } else out.append(c); } ret out.toString(); }
Began life as a copy of #1001263
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1012893 |
| Snippet name: | htmlencode_forParams |
| Eternal ID of this version: | #1012893/4 |
| Text MD5: | 9ed6ddf1aa5e7470cf0e7b3e35ed04fe |
| Transpilation MD5: | afe6e8b044483a10ca542da0721c83b4 |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-11-28 12:56:05 |
| Source code size: | 642 bytes / 21 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 732 / 1678 |
| Version history: | 3 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1030301 - htmlencode_forParams_v2 - also encodes entities |