Char Sniffer
A Small easy Maven plugin to check char codes in text files.
How to use?
For instance to restrict char codes (0-255) in text file License.txt situated in the root project folder, you can use such configuration
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>char-sniffer</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>sniff</goal>
</goals>
<configuration>
<files>
<file>${basedir}/License.txt</file>
</files>
<failForEmptyFile>true</failForEmptyFile>
<minCharCode>0</minCharCode>
<maxCharCode>255</maxCharCode>
</configuration>
</execution>
</executions>
</plugin>
Also it is possible to define chars which will be only allowed in text files
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>char-sniffer</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>sniff</goal>
</goals>
<configuration>
<files>
<file>${basedir}/License.txt</file>
</files>
<abc>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ,.'":;/@[]()-=*%0123456789Ü</abc>
</configuration>
</execution>
</executions>
</plugin>
It is possible to disable some chars in text files. For instance below described how to disable © and ™ in text files.
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>char-sniffer</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>sniff</goal>
</goals>
<configuration>
<files>
<file>${basedir}/License.txt</file>
</files>
<noAbc>™Ⓒ</noAbc>
</configuration>
</execution>
</executions>
</plugin>
To be sure that UTF-8 codes of text files are ok, it is possible to use special flag validateUtf8
, it will check that all UTF-8 chars have normal codes and there is not any broken char.
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>char-sniffer</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<goals>
<goal>sniff</goal>
</goals>
<configuration>
<files>
<file>${basedir}/License.txt</file>
</files>
<validateUtf8>true</validateUtf8>
</configuration>
</execution>
</executions>
</plugin>