From f47154dadd6718490ecdaeed0c575a24e3a559a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20St=C3=B6ggl?= Date: Fri, 7 Jun 2024 22:58:50 +0200 Subject: [PATCH] Preserve encoding of localized EAC log files EAC log files are encoded using UTF-16LE since version 1.0 beta 1. Since #51 (commit 9f80400) this encoding is preserved in case of EAC log files, which contain a log checksum. However, only English log files have been supported so far. - Also preserve the encoding of EAC log files in different languages, if they contain a log checksum. - Resolves #330 --- CUETools.Processor/CUESheet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CUETools.Processor/CUESheet.cs b/CUETools.Processor/CUESheet.cs index c408f9c5..f8623f5e 100644 --- a/CUETools.Processor/CUESheet.cs +++ b/CUETools.Processor/CUESheet.cs @@ -2389,7 +2389,7 @@ public static void WriteText(CUEConfig _config, string path, string text) bool utf8Required = (_config.alwaysWriteUTF8CUEFile && Path.GetExtension(path) == ".cue") || (CUESheet.Encoding.GetString(CUESheet.Encoding.GetBytes(text)) != text); var encoding = utf8Required ? new UTF8Encoding(_config.writeUTF8BOM) : 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")) + if (Path.GetExtension(path) == ".log" && text.StartsWith("Exact Audio Copy") && text.EndsWith(" ====\r\n")) encoding = Encoding.Unicode; using (StreamWriter sw1 = new StreamWriter(path, false, encoding)) sw1.Write(text);