|
@@ -148,7 +148,6 @@ public static class Program
|
|
|
foreach (var file in files)
|
|
|
{
|
|
|
var encodingString = magic.Read(file);
|
|
|
- _proccess_encode_logger.Information("{0}: {1}",file, encodingString);
|
|
|
Encoding encoding = Encoding.GetEncoding("windows-1251");
|
|
|
|
|
|
switch (encodingString)
|
|
@@ -161,7 +160,7 @@ public static class Program
|
|
|
encoding = Encoding.GetEncoding("windows-1251");
|
|
|
break;
|
|
|
default:
|
|
|
- _logger.Warning("Encoding not recognized for {0}. Using {1} as default", file, encoding.HeaderName);
|
|
|
+ _logger.Warning("Encoding not recognized for {0} with mime-encoding {1}. Using {2} as default", file, encodingString, encoding.HeaderName);
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -169,6 +168,7 @@ public static class Program
|
|
|
|
|
|
if (Regex.IsMatch(content,$"\\b{word_Find}\\b"))
|
|
|
{
|
|
|
+ _proccess_encode_logger.Information("{0}: {1}", file, encodingString);
|
|
|
File.WriteAllText(file, Regex.Replace(content, $"\\b{word_Find}\\b", word_Replace), encoding);
|
|
|
_logger.Information("Replaced in {0}; mime-encoding: {1}; used encoding: {2}", file, encodingString, encoding.HeaderName);
|
|
|
}
|
|
@@ -188,6 +188,8 @@ public static class Program
|
|
|
innerException = innerException.InnerException;
|
|
|
}
|
|
|
}
|
|
|
+ Console.WriteLine("Press any key to close this window . . .");
|
|
|
+ Console.ReadKey();
|
|
|
}
|
|
|
|
|
|
private static bool ValidateArg(string arg, bool throwException = false, string? argName = null) => !arg.StartsWith('-') && !string.IsNullOrEmpty(arg) || (throwException ? throw new ArgumentException(string.Format("Argument is not vaild {0}",arg),argName ?? nameof(arg)) : false);
|