From 39c7b52add1556ebe4852908b90bd383b3e6167b Mon Sep 17 00:00:00 2001 From: chudov Date: Wed, 5 Nov 2008 03:58:08 +0000 Subject: [PATCH] fixed encoding of autogenerated cuesheets (allows utf8 now) not catching exceptions in debug version --- CUETools/frmCUETools.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CUETools/frmCUETools.cs b/CUETools/frmCUETools.cs index 55732d7..34a02ce 100644 --- a/CUETools/frmCUETools.cs +++ b/CUETools/frmCUETools.cs @@ -355,6 +355,7 @@ namespace JDP { MessageBoxIcon.Exclamation); }); } +#if !DEBUG catch (Exception ex) { this.Invoke((MethodInvoker)delegate() { if (_batchPaths.Count == 0) SetupControls(false); @@ -364,6 +365,7 @@ namespace JDP { } }); } +#endif if (_batchPaths.Count != 0) { _batchPaths.RemoveAt(0); @@ -862,7 +864,7 @@ namespace JDP { Array.Sort (audioFiles); string cueName = Path.GetFileName(dir) + ".cuetools" + audioExts[i].Substring(1) + ".cue"; cueName = Path.Combine(dir, cueName); - StreamWriter sw = new StreamWriter(cueName, false, CUESheet.Encoding); + StringWriter sw = new StringWriter(); sw.WriteLine(String.Format("REM COMMENT \"CUETools generated dummy CUE sheet\"")); for (int iFile = 0; iFile < audioFiles.Length; iFile++) { @@ -871,6 +873,10 @@ namespace JDP { sw.WriteLine(String.Format(" INDEX 01 00:00:00")); } sw.Close(); + bool utf8Required = CUESheet.Encoding.GetString(CUESheet.Encoding.GetBytes(sw.ToString())) != sw.ToString(); + StreamWriter sw1 = new StreamWriter(cueName, false, utf8Required ? Encoding.UTF8 : CUESheet.Encoding); + sw1.Write(sw.ToString()); + sw1.Close(); break; } }