From 9f80400629e23fd107f82e7a1942cb024283ac25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20St=C3=B6ggl?= Date: Sun, 19 Apr 2020 21:55:11 +0200 Subject: [PATCH] [CUETools] Preserve EAC log file encoding EAC log files are encoded using UTF-16LE. Preserve this encoding in case of EAC log files, which contain a log checksum. This way, the copied log file stays unchanged and the checksum can still be verified using EAC's CheckLog.exe --- CUETools.Processor/CUESheet.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CUETools.Processor/CUESheet.cs b/CUETools.Processor/CUESheet.cs index a5d2971..4fd3b06 100644 --- a/CUETools.Processor/CUESheet.cs +++ b/CUETools.Processor/CUESheet.cs @@ -2310,6 +2310,9 @@ namespace CUETools.Processor { bool utf8Required = CUESheet.Encoding.GetString(CUESheet.Encoding.GetBytes(text)) != text; var encoding = utf8Required ? Encoding.UTF8 : CUESheet.Encoding; + // Preserve original UTF-16LE encoding of EAC log files, which contain a log checksum + if ((text.StartsWith("Exact Audio Copy") || text.StartsWith("EAC extraction logfile")) && text.Contains("==== Log checksum")) + encoding = Encoding.Unicode; using (StreamWriter sw1 = new StreamWriter(path, false, encoding)) sw1.Write(text); }