View Javadoc
1   /*xml
2   <module name="Checker">
3     <module name="TreeWalker">
4       <module name="AvoidEscapedUnicodeCharacters">
5         <property name="allowIfAllCharactersEscaped" value="true"/>
6       </module>
7     </module>
8   </module>
9   */
10  
11  package com.puppycrawl.tools.checkstyle.checks.avoidescapedunicodecharacters;
12  
13  // xdoc section -- start
14  public class Example4 {
15    // OK, a normal String below
16    String unitAbbrev = "μs";
17    // violation below, not all characters are escaped ('s'). 'should be avoided.'
18    String unitAbbrev1 = "\u03bcs";
19    // ok, because below are escape characters and allowIfAllCharacters = true.
20    String unitAbbrev2 = "\u03bc\u03bc\u03bc";
21    // violation below
22    String unitAbbrev3 = "\u03bcs"; // it is  μs
23    // violation below, not all characters are escaped ('s'). 'should be avoided.'
24    String unitAbbrev4 = "\u03bc\u03bcs";
25    public static int content() {
26      char content = 'r';
27      // OK, all control characters are escaped below
28      return '\ufeff' + content;
29    }
30  }
31  // xdoc section -- end