예제 #1
0
 /**
  * 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 "&amp;lt;Fran&amp;ccedil;ais&amp;gt;" will become
  * "&lt;Fran&ccedil;ais&gt;"
  *
  * <p>If an entity is unrecognized, it is left alone, and inserted verbatim into the result
  * string. e.g. "&amp;gt;&amp;zzzz;x" will become "&gt;&amp;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 "&amp;lt;Fran&amp;ccedil;ais&amp;gt;" will become
  * "&lt;Fran&ccedil;ais&gt;"
  *
  * <p>If an entity is unrecognized, it is left alone, and inserted verbatim into the result
  * string. e.g. "&amp;gt;&amp;zzzz;x" will become "&gt;&amp;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);
 }