Skip to content

Commit

Permalink
Preserve encoding of localized EAC log files
Browse files Browse the repository at this point in the history
EAC log files are encoded using UTF-16LE since version 1.0 beta 1.
Since gchudov#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.
- Just in case an EAC log file with a checksum has been converted
  to EOL LF, which is fine for CheckLog.exe, preserve UTF-16LE too.
- Resolves gchudov#330
  • Loading branch information
c72578 committed Jun 10, 2024
1 parent 6db48e5 commit 4deaf3f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion CUETools.Processor/CUESheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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") || text.EndsWith(" ====\n")))
encoding = Encoding.Unicode;
using (StreamWriter sw1 = new StreamWriter(path, false, encoding))
sw1.Write(text);
Expand Down

0 comments on commit 4deaf3f

Please sign in to comment.