### Question:
Entities { static String escape(String string, Document.OutputSettings out) { return escape(string, out.encoder(), out.escapeMode()); } private  Entities(); static boolean isNamedEntity(String name); static Character getCharacterByName(String name);  }### Answer:
@Test public void escape() { String text = "Hello &<> Å å π 新 there ¾"; String escapedAscii = Entities.escape(text, Charset.forName("ascii").newEncoder(), Entities.EscapeMode.base); String escapedAsciiFull = Entities.escape(text, Charset.forName("ascii").newEncoder(), Entities.EscapeMode.extended); String escapedAsciiXhtml = Entities.escape(text, Charset.forName("ascii").newEncoder(), Entities.EscapeMode.xhtml); String escapedUtf = Entities.escape(text, Charset.forName("UTF-8").newEncoder(), Entities.EscapeMode.base); assertEquals("Hello &amp;&lt;&gt; &Aring; &aring; &#960; &#26032; there &frac34;", escapedAscii); assertEquals("Hello &amp;&lt;&gt; &angst; &aring; &pi; &#26032; there &frac34;", escapedAsciiFull); assertEquals("Hello &amp;&lt;&gt; &#197; &#229; &#960; &#26032; there &#190;", escapedAsciiXhtml); assertEquals("Hello &amp;&lt;&gt; &Aring; &aring; π 新 there &frac34;", escapedUtf); }
@Test public void caseSensitive() { String unescaped = "Ü ü & &"; assertEquals("&Uuml; &uuml; &amp; &amp;", Entities.escape(unescaped, Charset.forName("ascii").newEncoder(), Entities.EscapeMode.extended)); String escaped = "&Uuml; &uuml; &amp; &AMP"; assertEquals("Ü ü & &", Entities.unescape(escaped)); }