StringEscapeUtil { public static String unescapeURL(String str) { try { return unescapeURLInternal(str, null); } catch (UnsupportedEncodingException e) { return str; } }  static String escapeJava(String str); static String escapeJava(String str, boolean strict); static void escapeJava(String str, Appendable out); static void escapeJava(String str, Appendable out, boolean strict); static String escapeJavaScript(String str); static String escapeJavaScript(String str, boolean strict); static void escapeJavaScript(String str, Appendable out); static void escapeJavaScript(String str, Appendable out, boolean strict); static String unescapeJava(String str); static void unescapeJava(String str, Appendable out); static String unescapeJavaScript(String str); static void unescapeJavaScript(String str, Appendable out); static String escapeHtml(String str); static void escapeHtml(String str, Appendable out); static String escapeXml(String str); static void escapeXml(String str, Appendable out); static String escapeEntities(Entities entities, String str); static void escapeEntities(Entities entities, String str, Appendable out); static String unescapeHtml(String str); static void unescapeHtml(String str, Appendable out); static String unescapeXml(String str); static void unescapeXml(String str, Appendable out); static String unescapeEntities(Entities entities, String str); static void unescapeEntities(Entities entities, String str, Appendable out); static String escapeSql(String str); static void escapeSql(String str, Appendable out); static String escapeURL(String str); static String escapeURL(String str, String encoding); static String escapeURL(String str, String encoding, boolean strict); static void escapeURL(String str, String encoding, Appendable out); static void escapeURL(String str, String encoding, Appendable out, boolean strict); static String unescapeURL(String str); static String unescapeURL(String str, String encoding); static void unescapeURL(String str, String encoding, Appendable out);  }
@Test public void unescapeURL() throws Exception { assertEquals(null, StringEscapeUtil.unescapeURL(null)); try { StringEscapeUtil.unescapeURL("test", null, null); fail(); } catch (IllegalArgumentException e) { assertThat(e, TestUtil.exception("The Appendable must not be null")); } }
@Test public void unescapeURLEncoding() { LocaleUtil.setContext(Locale.CHINA, "GBK"); assertEquals("中华人民共和国", StringEscapeUtil.unescapeURL("%D6%D0%BB%AA%C8%CB%C3%F1%B9%B2%BA%CD%B9%FA")); LocaleUtil.setContext(Locale.US, "8859_1"); assertEquals("\u00D6\u00D0\u00BB\u00AA\u00C8\u00CB\u00C3\u00F1\u00B9\u00B2\u00BA\u00CD\u00B9\u00FA", StringEscapeUtil.unescapeURL("%D6%D0%BB%AA%C8%CB%C3%F1%B9%B2%BA%CD%B9%FA")); LocaleUtil.resetContext(); }