List of utility methods to do HTML Escape
String | htmlescapeAll(String s1) Turns all characters into HTML entity equivalents if (s1 == null) return null; StringBuffer buf = new StringBuffer(); int i; for (i = 0; i < s1.length(); ++i) { char ch = s1.charAt(i); buf.append("&#" + ((int) ch) + ";"); return buf.toString(); |
String | htmlEscapeBasicMarkup(final String text) Performs necessary escaping to render arbitrary plain text as plain text without any markup. final StringBuilder buf = new StringBuilder(text.length() + 64); for (int i = 0; i < text.length(); i++) { final char ch = text.charAt(i); switch (ch) { case '<': buf.append("<"); break; case '&': ... |
String | HTMLEscapeBr(String original) HTML Escape Br if (original == null) return ""; StringBuffer out = new StringBuffer(""); char[] chars = original.toCharArray(); for (int i = 0; i < chars.length; i++) { boolean found = true; switch (chars[i]) { case '\n': ... |
StringBuffer | htmlEscapeSpace(String uri) html Escape Space StringBuffer sbURI = new StringBuffer((int) (uri.length() * 1.5)); char ch; for (int i = 0; i < uri.length(); ++i) { ch = uri.charAt(i); if (ch == ' ') { sbURI.append("%20"); } else if (ch == '\\') { sbURI.append('/'); ... |
String | htmlUnescape(String safeHtml) html Unescape if (safeHtml == null) return null; if (safeHtml.indexOf("<") != -1) { safeHtml = safeHtml.replace("<", "<"); if (safeHtml.indexOf(">") != -1) { safeHtml = safeHtml.replace(">", ">"); if (safeHtml.indexOf(""") != -1) { safeHtml = safeHtml.replace(""", "\""); if (safeHtml.indexOf("'") != -1) { safeHtml = safeHtml.replace("'", "'"); if (safeHtml.indexOf("&") != -1) { safeHtml = safeHtml.replace("&", "&"); return safeHtml; |