@Test public void shouldNotEscapeHighUnicode() { String unicode = "\u30D5\u30EC\u30FC\u30E0\u30EF\u30FC\u30AF\u306E\u30D9\u30F3\u30C1\u30DE\u30FC\u30AF"; the(Escape.html(unicode)).shouldBeEqual(unicode); }
public static void html(StringBuilder sb, String html) { for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; default: sb.append(c); } } }
Escape { public static void html(StringBuilder sb, String html) { for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; default: sb.append(c); } } } }
Escape { public static void html(StringBuilder sb, String html) { for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; default: sb.append(c); } } } private  Escape(); }
Escape { public static void html(StringBuilder sb, String html) { for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; default: sb.append(c); } } } private  Escape(); static void html(StringBuilder sb, String html); static String html(String html); static void xml(StringBuilder sb, String xml); static String xml(String xml); }
Escape { public static void html(StringBuilder sb, String html) { for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); switch (c) { case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case '\'': sb.append("&apos;"); break; case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; default: sb.append(c); } } } private  Escape(); static void html(StringBuilder sb, String html); static String html(String html); static void xml(StringBuilder sb, String xml); static String xml(String xml);  }