From 57335f45f2fa19848632fecb805733ae15bad7ee Mon Sep 17 00:00:00 2001 From: Jeff Davidson Date: Sun, 27 Dec 2020 13:41:47 -0800 Subject: [PATCH] Use the same filename conversion when loading and saving files. MyFrame::LoadPuzzle uses wx2file to convert wxString filenames to std::string filenames suitable for use with native C++ APIs, but MyFrame::DoSavePuzzle was using puz::encode_utf8(wx2puz(...)) which appears to mangle accents on Windows. Use wx2file everywhere. Also make line endings consistent so VS stops complaining. --- src/MyFrame.cpp | 50 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/MyFrame.cpp b/src/MyFrame.cpp index 9e71e000..23d4406d 100644 --- a/src/MyFrame.cpp +++ b/src/MyFrame.cpp @@ -385,7 +385,7 @@ MyFrame::MyFrame() m_isTimerRunning(false), m_autoStartTimer(false), m_autoSaveTimer(this, ID_AUTOSAVE_TIMER), - m_autoSaveInterval(0), + m_autoSaveInterval(0), m_showCompletionStatus(true), m_mgr(), m_fileHistory(10, ID_FILE_HISTORY_1) @@ -434,9 +434,9 @@ MyFrame::MyFrame() SetIcon(wxIcon(xword_xpm)); #endif // __WXMSW__ && ! __WXPM__ - // Try loading the previously saved layout, otherwise default to Full View + // Try loading the previously saved layout, otherwise default to Full View if (! LoadLayout("(Previous)")) - LoadLayout("Full View"); + LoadLayout("Full View"); // Show a blank puzzle ShowPuzzle(); @@ -680,18 +680,18 @@ MyFrame::DoSavePuzzle(const wxString & filename, m_puz.SetTime(m_time); m_puz.SetTimerRunning(IsTimerRunning()); - std::string fn = puz::encode_utf8(wx2puz(filename)); + std::string fn = wx2file(filename); if (! puz::Puzzle::CanSave(fn)) fn.clear(); if (fn.empty()) - fn = puz::encode_utf8(wx2puz( + fn = wx2file( wxFileSelector( _T("Save Puzzle As"), wxEmptyString, wxEmptyString, _T("puz"), GetSaveTypeString(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT) - )); + ); if (fn.empty()) return; @@ -699,7 +699,7 @@ MyFrame::DoSavePuzzle(const wxString & filename, wxStopWatch sw; m_puz.Save(fn, handler); - m_filename = puz2wx(puz::decode_utf8(fn)); + m_filename = fn; m_isModified = false; EnableSave(false); @@ -1150,10 +1150,10 @@ MyFrame::ShowNotes() void MyFrame::CheckPuzzle() -{ - if (!m_showCompletionStatus) { - m_status->SetAlert(""); - return; +{ + if (!m_showCompletionStatus) { + m_status->SetAlert(""); + return; } GridStats stats; m_XGridCtrl->GetStats(&stats); @@ -1490,7 +1490,7 @@ MyFrame::ManageWindows() .MinSize(50, 50) .Layer(2) .Top() - .Resizable() + .Resizable() .Caption(_T("Clue Prompt")) .Name(_T("Clue")) ); @@ -1681,7 +1681,7 @@ MyFrame::LoadConfig() // Misc config.Timer.autoStart.AddCallback(this, &MyFrame::SetAutoStartTimer); - config.autoSaveInterval.AddCallback(this, &MyFrame::SetAutoSaveInterval); + config.autoSaveInterval.AddCallback(this, &MyFrame::SetAutoSaveInterval); config.Status.showCompletionStatus.AddCallback(this, &MyFrame::SetShowCompletionStatus); // File History @@ -2531,18 +2531,18 @@ MyFrame::OnTimerNotify(wxTimerEvent & WXUNUSED(evt)) { m_XGridCtrl->SetPaused(true); } -} - -// Status bar -//----------- -void -MyFrame::SetShowCompletionStatus(bool show) -{ - m_showCompletionStatus = show; - if (m_puz.IsOk()) - { - CheckPuzzle(); - } +} + +// Status bar +//----------- +void +MyFrame::SetShowCompletionStatus(bool show) +{ + m_showCompletionStatus = show; + if (m_puz.IsOk()) + { + CheckPuzzle(); + } } // AutoSave