List of utility methods to do HTML Escape
String | htmlEscape(final String text) Escapes the text into proper HTML, converting characters into character entities when required. return text.replaceAll("&", "&") .replaceAll("<", "<").replaceAll(">", ">"); |
String | htmlEscape(Object obj) html Escape if (obj == null) { return ""; } else { return obj.toString().replaceAll("&", "&").replaceAll(">", ">").replaceAll("<", "<") .replaceAll("\"", """); |
String | htmlEscape(String html) html Escape String htmlEscaped = ""; for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); if (c == '\n') { htmlEscaped += "<br>"; } else if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') { htmlEscaped += "&#" + ((int) c) + ';'; } else { ... |
String | htmlescape(String html) htmlescape return html.replace("&", "&").replace("\"", """).replace("'", "'").replace("<", "<") .replace(">", ">"); |
String | htmlEscape(String input) Convert &, ", < and > to their respective HTML escape sequences. if (input == null) return ""; String res = input; res = res.replaceAll("&", "&"); res = res.replaceAll("\"", """); res = res.replaceAll("<", "<"); res = res.replaceAll(">", ">"); return res; ... |
String | htmlEscape(String input) html Escape StringBuilder sb = new StringBuilder(input.length()); for (char c : input.toCharArray()) { if (replacements.containsKey(c)) { sb.append(replacements.get(c)); } else { sb.append(c); return sb.toString(); |
String | htmlEscape(String input) Escape input string suitable for HTML output. String ret = input.replaceAll("&", "&"); ret = ret.replaceAll("<", "<"); ret = ret.replaceAll(">", ">"); return ret; |
String | htmlEscape(String input) Escape the HTML specific characters (like <) but keeps the UTF-8 content (for characters like é). if (input == null) { return null; String result = input.replace("&", "&"); result = result.replace("<", "<"); result = result.replace(">", ">"); result = result.replace("\"", """); return result; ... |
String | htmlEscape(String nonHTMLsrc) This method will take the input and escape characters that have an HTML entity representation. if (nonHTMLsrc == null) return null; StringBuffer res = new StringBuffer(); int l = nonHTMLsrc.length(); int idx; char c; for (int i = 0; i < l; i++) { c = nonHTMLsrc.charAt(i); ... |
String | htmlEscape(String s) Bare-bones version of getDisplayableHtmlString() above. if (s == null) return null; int len = s.length(); StringBuffer sb = new StringBuffer(len); for (int i = 0; i < len; i++) { char c = s.charAt(i); switch (c) { case '<': ... |