List of utility methods to do HTML Escape
String | htmlEscape(String S) html Escape if (null == S) { return S; int N = S.length(); StringBuilder sb = new StringBuilder(N); for (int i = 0; i < N; i++) { char c = S.charAt(i); if (c == '&') { ... |
String | htmlEscape(String s) Turn special characters into HTML character references. if (s == null) { return null; StringBuffer escaped = new StringBuffer(s.length()); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ((c >= 0 && c <= 33) || (c >= 35 && c <= 37) || (c >= 39 && c <= 59) || (c == 61) || (c >= 63 && c <= 159)) { ... |
String | htmlescape(String s) Turns funky characters into HTML entity equivalents e.g. if (s == null) return ""; StringBuffer buf = new StringBuffer(); int n = s.length(); for (int i = 0; i < n; ++i) { char ch = s.charAt(i); String entity = (String) i2e.get(Integer.valueOf(ch)); if (entity == null) { ... |
String | htmlEscape(String source) Turns funky characters into HTML entity equivalents. E.g. StringBuffer buf = new StringBuffer(); if (source != null) { for (int i = 0; i < source.length(); ++i) { char ch = source.charAt(i); String entity = (String) i2e.get(new Integer((int) ch)); if (entity == null) { if (((int) ch) > 128) buf.append("&#" + ((int) ch) + ";"); ... |
String | htmlEscape(String str) html Escape StringBuilder esc = new StringBuilder(); for (int i = 0; i < str.length(); ++i) { final char c = str.charAt(i); switch (c) { case '<': esc.append("<"); break; case '>': ... |
String | htmlEscape(String str) Escape ampersands and less-than characters in a string using HTML-style & and < constructs. String rval = ""; String s = str; while (true) { int ix1 = s.indexOf((int) '&'); int ix2 = s.indexOf((int) '<'); if (ix1 < 0 && ix2 < 0) { break; int ix; if (ix1 < 0) { ix = ix2; } else if (ix2 < 0) { ix = ix1; } else { ix = ix1 < ix2 ? ix1 : ix2; rval += s.substring(0, ix); s = s.substring(ix); if (s.startsWith("&")) { rval += "&"; } else { rval += "<"; s = s.substring(1); rval += s; return rval; |
String | htmlEscape(String str) html Escape return str.replace(">", ">").replace("<", "<").replace("&", "&"); |
String | htmlEscape(String string) html Escape StringBuilder builder = new StringBuilder(); for (int i = 0; i < string.length(); i++) { char nonEscaped = string.charAt(i); String escaped = charToHtmlEntity(nonEscaped); if (escaped == null) builder.append(nonEscaped); else builder.append(escaped); ... |
String | htmlEscape(String tag) Replace characters having special meaning inside HTML tags with their escaped equivalents, using character entities such as '&'. final StringBuffer result = new StringBuffer(); if (tag == null) { return null; } else { for (int i = 0; i < tag.length(); i++) { char character = tag.charAt(i); if (character == '<') { result.append("<"); ... |
String | htmlEscape(String text) Performs necessary escaping to render arbitrary plain text as plain text without any markup. StringBuilder buf = new StringBuilder(text.length() + 64); for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (ch == '<') buf.append("<"); else if (ch == '&') buf.append("&"); else ... |