/** * Unescapes a string containing entity escapes to a string containing the actual Unicode * characters corresponding to the escapes. Supports HTML 4.0 entities. * * <p>For example, the string "&lt;Fran&ccedil;ais&gt;" will become * "<Français>" * * <p>If an entity is unrecognized, it is left alone, and inserted verbatim into the result * string. e.g. "&gt;&zzzz;x" will become ">&zzzz;x". * * @param writer the writer receiving the unescaped string, not null * @param string the <code>String</code> to unescape, may be null * @throws IllegalArgumentException if the writer is null * @throws IOException if an IOException occurs * @see #escapeHtml(String) */ public static void unescapeHtml(Writer writer, String string) throws IOException { if (writer == null) { throw new IllegalArgumentException("The Writer must not be null."); } if (string == null) { return; } Entities.HTML40.unescape(writer, string); }
/** * Unescapes a string containing entity escapes to a string containing the actual Unicode * characters corresponding to the escapes. Supports HTML 4.0 entities. * * <p>For example, the string "&lt;Fran&ccedil;ais&gt;" will become * "<Français>" * * <p>If an entity is unrecognized, it is left alone, and inserted verbatim into the result * string. e.g. "&gt;&zzzz;x" will become ">&zzzz;x". * * @param str the <code>String</code> to unescape, may be null * @return a new unescaped <code>String</code>, <code>null</code> if null string input * @see #escapeHtml(String) */ public static String unescapeHtml(String str) { if (str == null) { return null; } return Entities.HTML40.unescape(str); }