/** * Perform a CSS Identifier 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 Identifier basic escape set: * <ul> * <li>The <em>Backslash Escapes</em>: <tt>\ </tt> (<tt>U+0020</tt>), <tt>\!</tt> * (<tt>U+0021</tt>), <tt>\"</tt> (<tt>U+0022</tt>), <tt>\#</tt> * (<tt>U+0023</tt>), <tt>\$</tt> (<tt>U+0024</tt>), <tt>\%</tt> * (<tt>U+0025</tt>), <tt>\&</tt> (<tt>U+0026</tt>), <tt>\'</tt> * (<tt>U+0027</tt>), <tt>\(</tt> (<tt>U+0028</tt>), <tt>\)</tt> * (<tt>U+0029</tt>), <tt>\*</tt> (<tt>U+002A</tt>), <tt>\+</tt> * (<tt>U+002B</tt>), <tt>\,</tt> (<tt>U+002C</tt>), <tt>\.</tt> * (<tt>U+002E</tt>), <tt>\/</tt> (<tt>U+002F</tt>), <tt>\;</tt> * (<tt>U+003B</tt>), <tt>\<</tt> (<tt>U+003C</tt>), <tt>\=</tt> * (<tt>U+003D</tt>), <tt>\></tt> (<tt>U+003E</tt>), <tt>\?</tt> * (<tt>U+003F</tt>), <tt>\@</tt> (<tt>U+0040</tt>), <tt>\[</tt> * (<tt>U+005B</tt>), <tt>\\</tt> (<tt>U+005C</tt>), <tt>\]</tt> * (<tt>U+005D</tt>), <tt>\^</tt> (<tt>U+005E</tt>), <tt>\`</tt> * (<tt>U+0060</tt>), <tt>\{</tt> (<tt>U+007B</tt>), <tt>\|</tt> * (<tt>U+007C</tt>), <tt>\}</tt> (<tt>U+007D</tt>) and <tt>\~</tt> * (<tt>U+007E</tt>). Note that the <tt>\-</tt> (<tt>U+002D</tt>) escape sequence * exists, but will only be used when an identifier starts with two hypens or hyphen + * digit. Also, the <tt>\_</tt> (<tt>U+005F</tt>) escape will only be used at the * beginning of an identifier to avoid problems with Internet Explorer 6. In the same * sense, note that the <tt>\:</tt> (<tt>U+003A</tt>) escape sequence is also * defined in the standard, but will not be used for escaping as Internet Explorer * < 8 does not recognize it. * <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>\FF </tt> Hexadecimal * Escapes. * * <p>This method calls {@link #escapeCssIdentifier(char[], int, int, java.io.Writer, * CssIdentifierEscapeType, CssIdentifierEscapeLevel)} with the following preconfigured values: * * <ul> * <li><tt>type</tt>: {@link CssIdentifierEscapeType#BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA} * <li><tt>level</tt>: {@link * CssIdentifierEscapeLevel#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 escapeCssIdentifier( final char[] text, final int offset, final int len, final Writer writer) throws IOException { escapeCssIdentifier( text, offset, len, writer, CssIdentifierEscapeType.BACKSLASH_ESCAPES_DEFAULT_TO_COMPACT_HEXA, CssIdentifierEscapeLevel.LEVEL_2_ALL_NON_ASCII_PLUS_BASIC_ESCAPE_SET); }
private CssFinder toCSS() { return new CssFinder("." + CssEscape.escapeCssIdentifier(this.unescapedClassName)); }