Ejemplo n.º 1
0
 /**
  * Perform a CSS String level 2 (basic set and all non-ASCII chars) <strong>escape</strong>
  * operation on a <tt>char[]</tt> input.
  *
  * <p><em>Level 2</em> means this method will escape:
  *
  * <ul>
  *   <li>The CSS String basic escape set:
  *       <ul>
  *         <li>The <em>Backslash Escapes</em>: <tt>&#92;&quot;</tt> (<tt>U+0022</tt>) and
  *             <tt>&#92;&#39;</tt> (<tt>U+0027</tt>).
  *         <li>Two ranges of non-displayable, control characters: <tt>U+0000</tt> to
  *             <tt>U+001F</tt> and <tt>U+007F</tt> to <tt>U+009F</tt>.
  *       </ul>
  *   <li>All non ASCII characters.
  * </ul>
  *
  * <p>This escape will be performed by using Backslash escapes whenever possible. For escaped
  * characters that do not have an associated Backslash, default to <tt>&#92;FF </tt> Hexadecimal
  * Escapes.
  *
  * <p>This method calls {@link #escapeCssString(char[], int, int, java.io.Writer,
  * CssStringEscapeType, CssStringEscapeLevel)} with the following preconfigured values:
  *
  * <ul>
  *   <li><tt>type</tt>: {@link CssStringEscapeType#BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA}
  *   <li><tt>level</tt>: {@link CssStringEscapeLevel#LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET}
  * </ul>
  *
  * <p>This method is <strong>thread-safe</strong>.
  *
  * @param text the <tt>char[]</tt> to be escaped.
  * @param offset the position in <tt>text</tt> at which the escape operation should start.
  * @param len the number of characters in <tt>text</tt> that should be escaped.
  * @param writer the <tt>java.io.Writer</tt> to which the escaped result will be written. Nothing
  *     will be written at all to this writer if <tt>text</tt> is <tt>null</tt>.
  * @throws IOException if an input/output exception occurs
  */
 public static void escapeCssString(
     final char[] text, final int offset, final int len, final Writer writer) throws IOException {
   escapeCssString(
       text,
       offset,
       len,
       writer,
       CssStringEscapeType.BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA,
       CssStringEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET);
 }