Skip to content

Commit

Permalink
[CUETools] Preserve EAC log file encoding
Browse files Browse the repository at this point in the history
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
  • Loading branch information
c72578 committed May 4, 2020
1 parent a2b12d1 commit 9f80400
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CUETools.Processor/CUESheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,9 @@ public static void WriteText(string path, string text)
{
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);
}
Expand Down

0 comments on commit 9f80400

Please sign in to comment.