Libraryless. Click here for Pure Java version (2559L/16K).
1 | // this should be on by default now I think, but it may break |
2 | // legacy code... |
3 | static new ThreadLocal<Bool> htmlencode_forParams_useV2; |
4 | |
5 | sS htmlencode_forParams(S s) { |
6 | if (s == null) ret ""; |
7 | if (isTrue(htmlencode_forParams_useV2!)) |
8 | ret htmlencode_forParams_v2(s); |
9 | |
10 | StringBuilder out = new StringBuilder(Math.max(16, s.length())); |
11 | for (int i = 0; i < s.length(); i++) { |
12 | char c = s.charAt(i); |
13 | if (c > 127 || c == '"' || c == '<' || c == '>') { |
14 | out.append("&#"); |
15 | out.append((int) c); |
16 | out.append(';'); |
17 | } else |
18 | out.append(c); |
19 | } |
20 | ret out.toString(); |
21 | } |
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: | 482 / 1376 |
Version history: | 3 change(s) |
Referenced in: | [show references] |