Libraryless. Click here for Pure Java version (50L/1K).
static S htmlencode_noQuotes_unoptimized(String s) { if (s == null) ret ""; StringBuilder out = new StringBuilder(Math.max(16, s.length())); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '<') out.append("<"); else if (c == '>') out.append(">"); else if (c > 127 || c == '&') { int cp = s.codePointAt(i); out.append("&#x"); out.append(intToHex_flexLength(cp)); out.append(';'); i += Character.charCount(cp)-1; } else out.append(c); } ret out.toString(); }
Began life as a copy of #1011153
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032927 |
Snippet name: | htmlencode_noQuotes_unoptimized |
Eternal ID of this version: | #1032927/1 |
Text MD5: | 6bacfc280e804afb3fd8fb5470222166 |
Transpilation MD5: | 5b32c40fb0094755edacecaa1305f5f5 |
Author: | stefan |
Category: | javax / html |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-10 23:49:19 |
Source code size: | 567 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 154 / 192 |
Referenced in: | [show references] |