Skip to content

Commit

Permalink
CUETools, Correct filenames: Support UTF-8
Browse files Browse the repository at this point in the history
So far, the CUETools action "Correct filenames" supports reading of
cuesheets in ANSI or UTF-8-BOM format. In case of UTF-8 files without
BOM, issues with special characters can occur.

- Add support for UTF-8 encoded cuesheets without BOM.
- Use method `CUESheet.StreamReader_UTF_ANSI()`.
  Detect, if file is `UTF-8-BOM` or `UTF-8` without BOM. Otherwise
  fall back to default encoding, which is typically `ANSI`.
- This is a follow-up to #140 (commit d6470d5)
- Fixes #326
  • Loading branch information
c72578 committed May 31, 2024
1 parent 2987a5c commit 1851aed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CUETools.Processor/CUESheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1921,7 +1921,7 @@ public static Encoding Encoding
}
}

private static StreamReader StreamReader_UTF_ANSI(string path)
public static StreamReader StreamReader_UTF_ANSI(string path)
{
// StreamReader() detects the encoding of files properly, if a BOM is present.
// Enable detection of UTF-8 files without BOM. Otherwise fall back to default encoding, which is typically ANSI.
Expand Down
2 changes: 1 addition & 1 deletion CUETools/frmCUETools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ private void WriteAudioFilesThread(object o)
if (Path.GetExtension(pathIn).ToLower() != ".cue")
throw new Exception("is not a .cue file");
string cue = null;
using (StreamReader sr = new StreamReader(pathIn, CUESheet.Encoding))
using (StreamReader sr = CUESheet.StreamReader_UTF_ANSI(pathIn))
cue = sr.ReadToEnd();
string extension;
string fixedCue;
Expand Down

0 comments on commit 1851aed

Please sign in to comment.