Libraryless. Click here for Pure Java version (50L/1K).
1 | static S htmlencode_noQuotes_unoptimized(String s) { |
2 | if (s == null) ret ""; |
3 | StringBuilder out = new StringBuilder(Math.max(16, s.length())); |
4 | for (int i = 0; i < s.length(); i++) { |
5 | char c = s.charAt(i); |
6 | if (c == '<') out.append("<"); |
7 | else if (c == '>') out.append(">"); |
8 | else if (c > 127 || c == '&') { |
9 | int cp = s.codePointAt(i); |
10 | out.append("&#x"); |
11 | out.append(intToHex_flexLength(cp)); |
12 | out.append(';'); |
13 | i += Character.charCount(cp)-1; |
14 | } else |
15 | out.append(c); |
16 | } |
17 | ret out.toString(); |
18 | } |
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: | 155 / 194 |
Referenced in: | [show references] |