|
|
|
@ -34,9 +34,11 @@ import java.util.*;
@@ -34,9 +34,11 @@ import java.util.*;
|
|
|
|
|
public class FileChecker { |
|
|
|
|
// kann für JUnitTest abgeschaltet werden
|
|
|
|
|
public static boolean isSystemExitWanted = true; |
|
|
|
|
private static final String CONTROLREGEX = "[^\\n\\r\\t]]&&\\p{C}]"; |
|
|
|
|
// private static final String CONTROLREGEX = "[[^\\n\\r\\t]]&&[\\u0000-\\u001F]]";
|
|
|
|
|
private static final String CONTROLREGEX = "[\\p{C}&&[^\\n\\r\\t]]"; |
|
|
|
|
|
|
|
|
|
// private static final Pattern CONTROLPATTERN = Pattern.compile(CONTROLREGEX);
|
|
|
|
|
private static Pattern CONTROLPATTERN = Pattern.compile("[[^\\n\\r\\t]&&\\p{C}]"); |
|
|
|
|
private static Pattern CONTROLPATTERN = Pattern.compile("[\\p{C}&&[^\\n\\r\\t]]"); |
|
|
|
|
private static final Options options = new Options(); |
|
|
|
|
|
|
|
|
|
private boolean isDryRun = false; |
|
|
|
@ -79,7 +81,7 @@ public class FileChecker {
@@ -79,7 +81,7 @@ public class FileChecker {
|
|
|
|
|
|
|
|
|
|
private static void initOptions() { |
|
|
|
|
options.addOption("ie", "input-encoding", true, "Encoding der Eingabedatei/en (default ISO-8859-15)"); |
|
|
|
|
options.addOption("oe", "ouput-encoding", true, "ZielEncoding (default UTF8)"); |
|
|
|
|
options.addOption("oe", "output-encoding", true, "ZielEncoding (default UTF8)"); |
|
|
|
|
options.addOption("l", "log", true, "debug|info (default)|severe"); |
|
|
|
|
options.addOption("n", "dry-run", false, "Ausführung ohne Änderungen"); |
|
|
|
|
options.addOption("s", "safe-run", false, "Bei Fehlern Originaldateien als .orig behalten"); |
|
|
|
@ -249,7 +251,7 @@ public class FileChecker {
@@ -249,7 +251,7 @@ public class FileChecker {
|
|
|
|
|
System.out.println("Ungültiges outputEncoding: " + outputEncoding); |
|
|
|
|
exitIfWanted(); |
|
|
|
|
} |
|
|
|
|
if (outputEncoding.equalsIgnoreCase("UTF-8")) { |
|
|
|
|
if (!outputEncoding.equalsIgnoreCase("UTF-8")) { |
|
|
|
|
isOutputEncodingUTF8 = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -318,6 +320,8 @@ public class FileChecker {
@@ -318,6 +320,8 @@ public class FileChecker {
|
|
|
|
|
if (outwriter != null) { |
|
|
|
|
if (hasControlChar) { |
|
|
|
|
line = line.replaceAll(CONTROLREGEX, ""); |
|
|
|
|
// Ersetzt alle Steuerzeichen von 0 bis 31 durch einen leeren String
|
|
|
|
|
// line=line.replaceAll("[\\u0000-\\u001F]", "");
|
|
|
|
|
} |
|
|
|
|
if (isReplaceTabsWanted) { |
|
|
|
|
line = line.replace('\t', ' '); |
|
|
|
|