diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index b346ce234a..85351c7fa8 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -424,15 +424,15 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float const int start = dlg.m_filename.length() - 4; if (start > 0) { - std::string test = dlg.m_filename.substr(start); + std::wstring test = dlg.m_filename.substr(start); std::transform(test.begin(), test.end(), test.begin(), (char(_cdecl*)(int))tolower); - if (test.compare(".avi") != 0) - dlg.m_filename += ".avi"; + if (test.compare(L".avi") != 0) + dlg.m_filename += L".avi"; } else - dlg.m_filename += ".avi"; + dlg.m_filename += L".avi"; - FILE* test = fopen(dlg.m_filename.c_str(), "w"); + FILE* test = _wfopen(dlg.m_filename.c_str(), L"w"); if (test) fclose(test); else @@ -507,7 +507,7 @@ bool GSCapture::BeginCapture(float fps, GSVector2i recommendedResolution, float CComQIPtr(m_src)->DeliverNewSegment(); m_capturing = true; - filename = dlg.m_filename.erase(dlg.m_filename.length() - 3, 3) + "wav"; + filename = convert_utf16_to_utf8(dlg.m_filename.erase(dlg.m_filename.length() - 3, 3) + L"wav"); return true; #elif defined(__unix__) // Note I think it doesn't support multiple depth creation diff --git a/plugins/GSdx/Window/GSCaptureDlg.cpp b/plugins/GSdx/Window/GSCaptureDlg.cpp index af81899b71..cbbc29782b 100644 --- a/plugins/GSdx/Window/GSCaptureDlg.cpp +++ b/plugins/GSdx/Window/GSCaptureDlg.cpp @@ -22,8 +22,6 @@ #include "stdafx.h" #include "GSdx.h" #include "GSCaptureDlg.h" -#include -#include #define BeginEnumSysDev(clsid, pMoniker) \ {CComPtr pDevEnum4$##clsid; \ @@ -39,10 +37,8 @@ void GSCaptureDlg::InvalidFile() { - wchar_t tmp[512]; - std::wstring tmpstr(m_filename.begin(), m_filename.end()); - swprintf_s(tmp, L"GSdx couldn't open file for capturing: %ls.\nCapture aborted.", tmpstr.c_str()); - MessageBox(GetActiveWindow(), tmp, L"GSdx System Message", MB_OK | MB_SETFOREGROUND); + const std::wstring message = L"GSdx couldn't open file for capturing: " + m_filename + L".\nCapture aborted."; + MessageBox(GetActiveWindow(), message.c_str(), L"GSdx System Message", MB_OK | MB_SETFOREGROUND); } GSCaptureDlg::GSCaptureDlg() @@ -50,7 +46,7 @@ GSCaptureDlg::GSCaptureDlg() { m_width = theApp.GetConfigI("CaptureWidth"); m_height = theApp.GetConfigI("CaptureHeight"); - m_filename = theApp.GetConfigS("CaptureFileName"); + m_filename = convert_utf8_to_utf16(theApp.GetConfigS("CaptureFileName")); } int GSCaptureDlg::GetSelCodec(Codec& c) @@ -106,8 +102,7 @@ void GSCaptureDlg::OnInit() SetTextAsInt(IDC_WIDTH, m_width); SetTextAsInt(IDC_HEIGHT, m_height); - std::wstring tmp = std::wstring(m_filename.begin(), m_filename.end()); - SetText(IDC_FILENAME, tmp.c_str()); + SetText(IDC_FILENAME, m_filename.c_str()); m_codecs.clear(); @@ -185,15 +180,11 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code) ofn.lpstrFilter = L"Avi files (*.avi)\0*.avi\0"; ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST; - std::wstring tmp = std::wstring(m_filename.begin(), m_filename.end()); - wcscpy(ofn.lpstrFile, tmp.c_str()); + wcscpy(ofn.lpstrFile, m_filename.c_str()); if (GetSaveFileName(&ofn)) { - tmp = ofn.lpstrFile; - using convert_type = std::codecvt_utf8; - std::wstring_convert converter; - m_filename = converter.to_bytes(tmp); - SetText(IDC_FILENAME, tmp.c_str()); + m_filename = ofn.lpstrFile; + SetText(IDC_FILENAME, m_filename.c_str()); } return true; @@ -254,7 +245,7 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code) theApp.SetConfig("CaptureWidth", m_width); theApp.SetConfig("CaptureHeight", m_height); - theApp.SetConfig("CaptureFileName", m_filename.c_str()); + theApp.SetConfig("CaptureFileName", convert_utf16_to_utf8(m_filename).c_str()); if (ris != 2) theApp.SetConfig("CaptureVideoCodecDisplayName", c.DisplayName); diff --git a/plugins/GSdx/Window/GSCaptureDlg.h b/plugins/GSdx/Window/GSCaptureDlg.h index 17a6ce43f7..03d8efc391 100644 --- a/plugins/GSdx/Window/GSCaptureDlg.h +++ b/plugins/GSdx/Window/GSCaptureDlg.h @@ -50,7 +50,7 @@ public: int m_width; int m_height; - std::string m_filename; + std::wstring m_filename; INT_PTR m_colorspace; CComPtr m_enc; }; diff --git a/plugins/GSdx/Window/GSDialog.cpp b/plugins/GSdx/Window/GSDialog.cpp index 07b0e02b06..55f39d97c9 100644 --- a/plugins/GSdx/Window/GSDialog.cpp +++ b/plugins/GSdx/Window/GSDialog.cpp @@ -125,9 +125,9 @@ bool GSDialog::OnCommand(HWND hWnd, UINT id, UINT code) return false; } -std::string GSDialog::GetText(UINT id) +std::wstring GSDialog::GetText(UINT id) { - std::string s; + std::wstring s; wchar_t* buff = NULL; @@ -137,8 +137,7 @@ std::string GSDialog::GetText(UINT id) if(GetDlgItemText(m_hWnd, id, buff, size)) { - std::wstring tmp(buff); - s = std::string(tmp.begin(), tmp.end()); + s = buff; size = limit; } @@ -150,7 +149,7 @@ std::string GSDialog::GetText(UINT id) int GSDialog::GetTextAsInt(UINT id) { - return atoi(GetText(id).c_str()); + return _wtoi(GetText(id).c_str()); } void GSDialog::SetText(UINT id, const wchar_t* str) diff --git a/plugins/GSdx/Window/GSDialog.h b/plugins/GSdx/Window/GSDialog.h index 5f994aff7c..ffa6297ad4 100644 --- a/plugins/GSdx/Window/GSDialog.h +++ b/plugins/GSdx/Window/GSDialog.h @@ -45,7 +45,7 @@ public: INT_PTR DoModal(); - std::string GetText(UINT id); + std::wstring GetText(UINT id); int GetTextAsInt(UINT id); void SetText(UINT id, const wchar_t* str);