proper unicode literal and wstring to wxstring conversions.

Fixes issue 5156.
This commit is contained in:
LPFaint99
2012-01-27 00:30:52 -08:00
parent fd616ccb0c
commit 04a7e33f0b
4 changed files with 29 additions and 32 deletions

View File

@ -448,7 +448,7 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
#else #else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // 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 // it returns CP-932, in order to use iconv we need to use CP932
wxCSConv SJISConv(L"CP932"); wxCSConv SJISConv(wxT("CP932"));
#endif #endif
GameListItem& rISOFile = *m_ISOFiles[_Index]; GameListItem& rISOFile = *m_ISOFiles[_Index];
@ -468,10 +468,13 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
// Set the game's banner in the second column // Set the game's banner in the second column
SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex); SetItemColumnImage(_Index, COLUMN_BANNER, ImageIndex);
std::wstring wname; std::wstring wstring_name;
const std::wstring& wdescription = rISOFile.GetDescription(); const std::wstring& wstring_description = rISOFile.GetDescription();
std::string company; std::string company;
wxString name;
wxString description;
// We show the company string on Gamecube only // We show the company string on Gamecube only
// On Wii we show the description instead as the company string is empty // On Wii we show the description instead as the company string is empty
if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC) if (rISOFile.GetPlatform() == GameListItem::GAMECUBE_DISC)
@ -482,13 +485,11 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
case DiscIO::IVolume::COUNTRY_TAIWAN: case DiscIO::IVolume::COUNTRY_TAIWAN:
case DiscIO::IVolume::COUNTRY_JAPAN: case DiscIO::IVolume::COUNTRY_JAPAN:
{ {
rISOFile.GetName(wname, -1); rISOFile.GetName(wstring_name, -1);
wxString name = wxString(rISOFile.GetName(0).c_str(), SJISConv); name = wxString(rISOFile.GetName(0).c_str(), SJISConv);
m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str())); m_gameList.append(StringFromFormat("%s (J)\n", (const char *)name.c_str()));
SetItem(_Index, COLUMN_TITLE, name, -1); description = wxString(company.size() ? company.c_str() :
SetItem(_Index, COLUMN_NOTES, wxString(company.size() ? rISOFile.GetDescription(0).c_str(), SJISConv);
company.c_str() : rISOFile.GetDescription(0).c_str(),
SJISConv), -1);
} }
break; break;
case DiscIO::IVolume::COUNTRY_USA: case DiscIO::IVolume::COUNTRY_USA:
@ -496,28 +497,24 @@ void CGameListCtrl::InsertItemInReportView(long _Index)
default: default:
{ {
wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
rISOFile.GetName(wname, SelectedLanguage); rISOFile.GetName(wstring_name, SelectedLanguage);
SetItem(_Index, COLUMN_TITLE, name = wxString(rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252);
wxString(
rISOFile.GetName(SelectedLanguage).c_str(), WindowsCP1252),
-1);
m_gameList.append(StringFromFormat("%s (%c)\n", m_gameList.append(StringFromFormat("%s (%c)\n",
rISOFile.GetName(SelectedLanguage).c_str(), (rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA)?'U':'E')); rISOFile.GetName(SelectedLanguage).c_str(), (rISOFile.GetCountry() == DiscIO::IVolume::COUNTRY_USA)?'U':'E'));
SetItem(_Index, COLUMN_NOTES, description = wxString(company.size() ? company.c_str() :
wxString(company.size() ? rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252);
company.c_str() :
rISOFile.GetDescription(SelectedLanguage).c_str(), WindowsCP1252),
-1);
} }
break; break;
} }
if (wname.length()) if (wstring_name.length())
SetItem(_Index, COLUMN_TITLE, wname, -1); name = wstring_name.c_str();
if (wdescription.length()) if (wstring_description.length())
SetItem(_Index, COLUMN_NOTES, wdescription, -1); description = wstring_description.c_str();
SetItem(_Index, COLUMN_TITLE, name, -1);
SetItem(_Index, COLUMN_NOTES, description, -1);
#ifndef _WIN32 #ifndef _WIN32
// Emulation state // Emulation state

View File

@ -158,7 +158,7 @@ CISOProperties::CISOProperties(const std::string fileName, wxWindow* parent, wxW
std::wstring wname; std::wstring wname;
wxString name; wxString name;
if (OpenGameListItem->GetName(wname)) if (OpenGameListItem->GetName(wname))
name = wname; name = wname.c_str();
else else
name = wxString(OpenISO->GetName().c_str(), wxConvUTF8); name = wxString(OpenISO->GetName().c_str(), wxConvUTF8);
m_Name->SetValue(name); m_Name->SetValue(name);
@ -1280,7 +1280,7 @@ void CISOProperties::ChangeBannerDetails(int lang)
#else #else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // 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 // it returns CP-932, in order to use iconv we need to use CP932
wxCSConv SJISConv(L"CP932"); wxCSConv SJISConv(wxT("CP932"));
#endif #endif
switch (OpenGameListItem->GetCountry()) switch (OpenGameListItem->GetCountry())
{ {
@ -1288,11 +1288,11 @@ void CISOProperties::ChangeBannerDetails(int lang)
case DiscIO::IVolume::COUNTRY_JAPAN: case DiscIO::IVolume::COUNTRY_JAPAN:
if (OpenGameListItem->GetName(wname, -1)) if (OpenGameListItem->GetName(wname, -1))
shortName = wname; shortName = wname.c_str();
else else
shortName = wxString(OpenGameListItem->GetName(0).c_str(), SJISConv); 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); comment = wxString(OpenGameListItem->GetDescription(0).c_str(), SJISConv);
maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv); maker = wxString(OpenGameListItem->GetCompany().c_str(), SJISConv);
break; break;
@ -1302,10 +1302,10 @@ void CISOProperties::ChangeBannerDetails(int lang)
{ {
wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252)); wxCSConv WindowsCP1252(wxFontMapper::GetEncodingName(wxFONTENCODING_CP1252));
if (OpenGameListItem->GetName(wname, lang)) if (OpenGameListItem->GetName(wname, lang))
shortName = wname; shortName = wname.c_str();
else else
shortName = wxString(OpenGameListItem->GetName(lang).c_str(), WindowsCP1252); 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); comment = wxString(OpenGameListItem->GetDescription(lang).c_str(), WindowsCP1252);
maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252); maker = wxString(OpenGameListItem->GetCompany().c_str(), WindowsCP1252);
} }

View File

@ -56,7 +56,7 @@ CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
#else #else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // 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 // 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 #endif
m_LogManager = LogManager::GetInstance(); m_LogManager = LogManager::GetInstance();

View File

@ -716,7 +716,7 @@ bool CMemcardManager::ReloadMemcard(const char *fileName, int card)
#else #else
// on linux the wrong string is returned from wxFontMapper::GetEncodingName(wxFONTENCODING_SHIFT_JIS) // 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 // it returns CP-932, in order to use iconv we need to use CP932
wxCSConv SJISConv(L"CP932"); wxCSConv SJISConv(wxT("CP932"));
#endif #endif
wxTitle = wxString(title, ascii ? *wxConvCurrent : SJISConv); wxTitle = wxString(title, ascii ? *wxConvCurrent : SJISConv);
wxComment = wxString(comment, ascii ? *wxConvCurrent : SJISConv); wxComment = wxString(comment, ascii ? *wxConvCurrent : SJISConv);