List of utility methods to do HTML Encode
String | HTMLBREncode(String str) HTMLBR Encode return str.replaceAll("\r\n", "\r\n<br class=\"br\"/>\r\n"); |
void | htmlEncode(final String source, StringBuffer target) Html encode, with StringBuffer as target (faster) if (source == null || source.length() == 0) return; int length = source.length(); char[] charArray = new char[length]; source.getChars(0, length, charArray, 0); int startIndex = 0; int currentIndex = 0; while (currentIndex < length) { ... |
String | htmlEncode(Object input) html Encode if (input == null) { return ""; String strInput = input.toString().trim(); StringBuilder output = new StringBuilder(); int len = strInput.length(); char ch; for (int i = 0; i < len; i++) { ... |
String | htmlEncode(String html) Replaces all HTML-sensitive characters with their entity equivalents if (html == null) { return null; StringBuffer buf = new StringBuffer((int) (html.length() * 1.1)); int stringLength = html.length(); for (int i = 0; i < stringLength; ++i) { char c = html.charAt(i); switch (c) { ... |
String | htmlEncode(String html) Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages. if (hasText(html)) { String result = html.replace("&", HTML_AMPERSAND); result = result.replace("<", HTML_GREATER_THAN); result = result.replace(">", HTML_LESS_THAN); result = result.replace("'", HTML_DASH_POINT); return result; return null; ... |
String | htmlEncode(String input) html Encode return input.replace("&", "&").replace("<", "<").replace(">", ">").replace(" ", " ") .replace(LINE_BREAK, "<br>" + LINE_BREAK); |
String | htmlEncode(String input) HTML-encode a string. String output = input.replaceAll("&", "&"); output = output.replaceAll("<", "<"); output = output.replaceAll(">", ">"); output = output.replaceAll("\"", """); output = output.replaceAll("'", "'"); return output; |
String | htmlEncode(String s) html Encode StringBuffer out = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c > 127 || c == '"' || c == '<' || c == '>') { out.append("&#" + (int) c + ";"); } else { out.append(c); return out.toString(); |
String | htmlEncode(String s) html Encode StringBuffer sb = new StringBuffer(); int len = s.length(); for (int counter = 0; counter < len; counter++) { char c = s.charAt(counter); switch (c) { case '<': sb.append("<"); break; ... |
String | htmlEncode(String s) Returns HTML encoded version of the specified String s. StringBuffer encodedString = new StringBuffer(""); char[] chars = s.toCharArray(); for (char c : chars) { if (c == '<') { encodedString.append("<"); } else if (c == '>') { encodedString.append(">"); } else { ... |