List of utility methods to do HTML Encode
String | htmlSpecialChars(String html) html Special Chars StringBuilder builder = new StringBuilder(html); for (int index = 0; index < builder.length(); index++) { String toInsert; switch (builder.charAt(index)) { case '<': toInsert = "<"; break; case '>': ... |
String | htmlspecialchars(String input) htmlspecialchars if (input == null) return null; String retval = input.replace("&", "&"); retval = retval.replace("\"", """); retval = retval.replace("<", "<"); retval = retval.replace(">", ">"); retval = retval.replace(">", ">"); retval = retval.replace("=", "="); ... |
String | htmlspecialchars(String s) translate some HTML characters (similar to same PHP function) The translations performed are: '&' (ampersand) becomes '&' NOT YET IMPLEMENTED '"' (double quote) becomes '"' NOT YET IMPLEMENTED ''' (single quote) becomes ''' NOT YET IMPLEMENTED '<' (less than) becomes '<' '>' (greater than) becomes '>' s = s.replaceAll("<", "<"); s = s.replaceAll(">", ">"); return s; |
String | htmlspecialchars(String str) htmlspecialchars str = str.replaceAll("&", "&"); str = str.replaceAll("<", "<"); str = str.replaceAll(">", ">"); str = str.replaceAll("\"", """); return str; |
String | textToHtml(final String s) Converts a text message into an HTML message, replacing all newlines with <br> tags and escaping the '<' and '>' characters; final StringBuilder sb = new StringBuilder(); for (final char c : s.toCharArray()) { switch (c) { case '\n': sb.append("<br/>"); break; case '<': sb.append("<"); ... |
String | textToHtml(String html) text To Html if (html != null) { html = html.replace("\u00e5", "å"); html = html.replace("\u00e4", "ä"); html = html.replace("\u00f6", "ö"); html = html.replace("\u00c5", "Å"); html = html.replace("\u00c4", "Ä"); html = html.replace("\u00d6", "Ö"); return html; |
String | textToHTML(String message) Scans a text, generating HTML that respects leading/consecutive spaces and newlines, while escaping actual HTML constructs. StringBuffer html = new StringBuffer(); boolean collectSpaces = true; for (int i = 0; i < message.length(); i++) { String bit; char c = message.charAt(i); switch (c) { case '\r': continue; ... |
String | textToHtml(String s) wrap contents as an html document return stringToHTMLString(s);
|
String | textToHtml(String text) Converts plaintext to HTML, preserving whitespace semantics as much as possible. return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") .replaceAll("\\n", "<br />").replaceAll("\\t", " ").replaceAll(" ", " ") .replaceAll(" (?! )", " ").replaceAll(" $", " ").replaceAll("^ ", " "); |
String | textToHTML(String text) text To HTML if (text == null) { return null; int length = text.length(); boolean prevSlashR = false; String out = ""; for (int i = 0; i < length; i++) { char ch = text.charAt(i); ... |