@Test public void testEscape_html() { System.out.println("escape_html"); String html = "<html>\"Tom & Jerry\"\n</html>"; String expResult = "&lt;html&gt;&quot;Tom&nbsp;&amp;&nbsp;Jerry&quot;<br/>&lt;/html&gt;"; String result = StringUtils.escape_html(html); assertEquals(expResult, result); }
public static String escape_html(String html) { StringBuilder sb = new StringBuilder(); char ch; int len = html.length(); int i; for (i = 0; i < len; i++) { ch = html.charAt(i); switch (ch) { case ' ': sb.append("&nbsp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '"': sb.append("&quot;"); break; case '&': sb.append("&amp;"); break; case '\n': sb.append("<br/>"); break; default: sb.append(ch); break; } } return sb.toString(); }
StringUtils { public static String escape_html(String html) { StringBuilder sb = new StringBuilder(); char ch; int len = html.length(); int i; for (i = 0; i < len; i++) { ch = html.charAt(i); switch (ch) { case ' ': sb.append("&nbsp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '"': sb.append("&quot;"); break; case '&': sb.append("&amp;"); break; case '\n': sb.append("<br/>"); break; default: sb.append(ch); break; } } return sb.toString(); } }
StringUtils { public static String escape_html(String html) { StringBuilder sb = new StringBuilder(); char ch; int len = html.length(); int i; for (i = 0; i < len; i++) { ch = html.charAt(i); switch (ch) { case ' ': sb.append("&nbsp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '"': sb.append("&quot;"); break; case '&': sb.append("&amp;"); break; case '\n': sb.append("<br/>"); break; default: sb.append(ch); break; } } return sb.toString(); }  }
StringUtils { public static String escape_html(String html) { StringBuilder sb = new StringBuilder(); char ch; int len = html.length(); int i; for (i = 0; i < len; i++) { ch = html.charAt(i); switch (ch) { case ' ': sb.append("&nbsp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '"': sb.append("&quot;"); break; case '&': sb.append("&amp;"); break; case '\n': sb.append("<br/>"); break; default: sb.append(ch); break; } } return sb.toString(); }  static String displayParsedInt(String strIn); static String escape_html(String html); static String getEST(Throwable th); static String getExtendedStackTrace(Throwable th); static String joinString(Collection<T> objects, String delim); static String asciiString(byte[] asciiBytes); static byte[] asciiBytes(String asciiStr); static boolean strEquals(String a, String b); static String lineWrap(String strIn,int cols); }
StringUtils { public static String escape_html(String html) { StringBuilder sb = new StringBuilder(); char ch; int len = html.length(); int i; for (i = 0; i < len; i++) { ch = html.charAt(i); switch (ch) { case ' ': sb.append("&nbsp;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '"': sb.append("&quot;"); break; case '&': sb.append("&amp;"); break; case '\n': sb.append("<br/>"); break; default: sb.append(ch); break; } } return sb.toString(); }  static String displayParsedInt(String strIn); static String escape_html(String html); static String getEST(Throwable th); static String getExtendedStackTrace(Throwable th); static String joinString(Collection<T> objects, String delim); static String asciiString(byte[] asciiBytes); static byte[] asciiBytes(String asciiStr); static boolean strEquals(String a, String b); static String lineWrap(String strIn,int cols);  }