From 04a7e33f0b629622ff851f962b9ab707f70a1b35 Mon Sep 17 00:00:00 2001 From: LPFaint99 Date: Fri, 27 Jan 2012 00:30:52 -0800 Subject: [PATCH] proper unicode literal and wstring to wxstring conversions. Fixes issue 5156. --- Source/Core/DolphinWX/Src/GameListCtrl.cpp | 45 +++++++++----------- Source/Core/DolphinWX/Src/ISOProperties.cpp | 12 +++--- Source/Core/DolphinWX/Src/LogWindow.cpp | 2 +- Source/Core/DolphinWX/Src/MemcardManager.cpp | 2 +- 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Source/Core/DolphinWX/Src/GameListCtrl.cpp b/Source/Core/DolphinWX/Src/GameListCtrl.cpp index 9dbbf656e9..8e0a498915 100644 --- a/Source/Core/DolphinWX/Src/GameListCtrl.cpp +++ b/Source/Core/DolphinWX/Src/GameListCtrl.cpp @@ -448,7 +448,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index) #else // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // it returns CP-932, in order to use iconv we need to use CP932 - wxCSConv SJISConv(L"CP932"); + wxCSConv SJISConv(wxT("CP932")); #endif GameListItem& rISOFile = *m_ISOFiles[_Index]; @@ -468,10 +468,13 @@ void CGameListCtrl::InsertItemInReportView(long _Index) // Set the game's banner in the second column SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex); - std::wstring wname; - const std::wstring& wdescription = rISOFile.GetDescription(); + std::wstring wstring_name; + const std::wstring& wstring_description = rISOFile.GetDescription(); std::string company; + wxString name; + wxString description; + // We show the company string on Gamecube only // On Wii we show the description instead as the company string is empty if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) @@ -482,13 +485,11 @@ void CGameListCtrl::InsertItemInReportView(long _Index) case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_JAPAN: { - rISOFile.GetName(wname, -1); - wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv); + rISOFile.GetName(wstring_name, -1); + name = wxString(rISOFile.GetName(0).c_str(), SJISConv); m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str())); - SetItem(_Index, COLUMN_TITLE, name, -1); - SetItem(_Index, COLUMN_NOTES, wxString(company.size() ? - company.c_str() : rISOFile.GetDescription(0).c_str(), - SJISConv), -1); + description = wxString(company.size() ? company.c_str() : + rISOFile.GetDescription(0).c_str(), SJISConv); } break; case DiscIO::IVolume::COUNTRY_USA: @@ -496,28 +497,24 @@ void CGameListCtrl::InsertItemInReportView(long _Index) default: { wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); - rISOFile.GetName(wname, SelectedLanguage); + rISOFile.GetName(wstring_name, SelectedLanguage); - SetItem(_Index, COLUMN_TITLE, - wxString( - rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252), - -1); + name = wxString(rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252); m_gameList.append(StringFromFormat("%s (%c)\n", rISOFile.GetName(SelectedLanguage).c_str(), (rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA)?'U':'E')); - SetItem(_Index, COLUMN_NOTES, - wxString(company.size() ? - company.c_str() : - rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252), - -1); + description = wxString(company.size() ? company.c_str() : + rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252); } break; } - if (wname.length()) - SetItem(_Index, COLUMN_TITLE, wname, -1); - if (wdescription.length()) - SetItem(_Index, COLUMN_NOTES, wdescription, -1); - + if (wstring_name.length()) + name = wstring_name.c_str(); + if (wstring_description.length()) + description = wstring_description.c_str(); + + SetItem(_Index, COLUMN_TITLE, name, -1); + SetItem(_Index, COLUMN_NOTES, description, -1); #ifndef _WIN32 // Emulation state diff --git a/Source/Core/DolphinWX/Src/ISOProperties.cpp b/Source/Core/DolphinWX/Src/ISOProperties.cpp index 85b95f3cb4..b5e5c82d1d 100644 --- a/Source/Core/DolphinWX/Src/ISOProperties.cpp +++ b/Source/Core/DolphinWX/Src/ISOProperties.cpp @@ -158,7 +158,7 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW std::wstring wname; wxString name; if (OpenGameListItem->GetName(wname)) - name = wname; + name = wname.c_str(); else name = wxString(OpenISO->GetName().c_str(), wxConvUTF8); m_Name->SetValue(name); @@ -1280,7 +1280,7 @@ void CISOProperties::ChangeBannerDetails(int lang) #else // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // it returns CP-932, in order to use iconv we need to use CP932 - wxCSConv SJISConv(L"CP932"); + wxCSConv SJISConv(wxT("CP932")); #endif switch (OpenGameListItem->GetCountry()) { @@ -1288,11 +1288,11 @@ void CISOProperties::ChangeBannerDetails(int lang) case DiscIO::IVolume::COUNTRY_JAPAN: if (OpenGameListItem->GetName(wname, -1)) - shortName = wname; + shortName = wname.c_str(); else shortName = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv); - if ((comment = OpenGameListItem->GetDescription()).size() == 0) + if ((comment = OpenGameListItem->GetDescription().c_str()).size() == 0) comment = wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv); maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv); break; @@ -1302,10 +1302,10 @@ void CISOProperties::ChangeBannerDetails(int lang) { wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); if (OpenGameListItem->GetName(wname, lang)) - shortName = wname; + shortName = wname.c_str(); else shortName = wxString(OpenGameListItem->GetName(lang).c_str(), WindowsCP1252); - if ((comment = OpenGameListItem->GetDescription()).size() == 0) + if ((comment = OpenGameListItem->GetDescription().c_str()).size() == 0) comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), WindowsCP1252); maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252); } diff --git a/Source/Core/DolphinWX/Src/LogWindow.cpp b/Source/Core/DolphinWX/Src/LogWindow.cpp index f2a1b3d8b8..0d11ef0142 100644 --- a/Source/Core/DolphinWX/Src/LogWindow.cpp +++ b/Source/Core/DolphinWX/Src/LogWindow.cpp @@ -56,7 +56,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos, #else // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // it returns CP-932, in order to use iconv we need to use CP932 - m_SJISConv = wxCSConv(L"CP932"); + m_SJISConv = wxCSConv(wxT("CP932")); #endif m_LogManager = LogManager::GetInstance(); diff --git a/Source/Core/DolphinWX/Src/MemcardManager.cpp b/Source/Core/DolphinWX/Src/MemcardManager.cpp index 68ae0f9ff2..98390122e2 100644 --- a/Source/Core/DolphinWX/Src/MemcardManager.cpp +++ b/Source/Core/DolphinWX/Src/MemcardManager.cpp @@ -716,7 +716,7 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card) #else // on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // it returns CP-932, in order to use iconv we need to use CP932 - wxCSConv SJISConv(L"CP932"); + wxCSConv SJISConv(wxT("CP932")); #endif wxTitle = wxString(title, ascii ? *wxConvCurrent : SJISConv); wxComment = wxString(comment, ascii ? *wxConvCurrent : SJISConv);