From: <man...@us...> - 2013-11-14 19:15:59
|
Revision: 3216 http://sourceforge.net/p/modplug/code/3216 Author: manxorist Date: 2013-11-14 19:15:48 +0000 (Thu, 14 Nov 2013) Log Message: ----------- [Ref] Convert a lot of places to the shorter charset conversion syntax. [Ref] Some tiny realted cleanups. Modified Paths: -------------- trunk/OpenMPT/common/mptFstream.h trunk/OpenMPT/common/mptPathString.cpp trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/mptString.h trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/FileDialog.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Tagging.cpp trunk/OpenMPT/soundlib/WAVTools.cpp trunk/OpenMPT/unarchiver/unrar.cpp Modified: trunk/OpenMPT/common/mptFstream.h =================================================================== --- trunk/OpenMPT/common/mptFstream.h 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/common/mptFstream.h 2013-11-14 19:15:48 UTC (rev 3216) @@ -59,7 +59,7 @@ template<typename Tbase> inline void fstream_open(Tbase & base, const std::string & filename, std::ios_base::openmode mode) { - detail::fstream_open<Tbase>(base, mpt::String::Decode(filename, mpt::CharsetLocale), mode); + detail::fstream_open<Tbase>(base, mpt::ToWide(mpt::CharsetLocale, filename), mode); } template<typename Tbase> Modified: trunk/OpenMPT/common/mptPathString.cpp =================================================================== --- trunk/OpenMPT/common/mptPathString.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/common/mptPathString.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -76,7 +76,7 @@ //----------------------------------------------------------------- { #if defined(WIN32) - return _wfopen(filename.AsNative().c_str(), mode ? mpt::String::Decode(mode, mpt::CharsetLocale).c_str() : nullptr); + return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetLocale, mode).c_str() : nullptr); #else // !WIN32 return fopen(filename.AsNative().c_str(), mode); #endif // WIN32 @@ -88,7 +88,7 @@ #if defined(WIN32) return _wfopen(filename.AsNative().c_str(), mode); #else // !WIN32 - return fopen(filename.AsNative().c_str(), mode ? mpt::String::Encode(mode, mpt::CharsetLocale).c_str() : nullptr); + return fopen(filename.AsNative().c_str(), mode ? mpt::ToLocale(mode).c_str() : nullptr); #endif // WIN32 } Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/common/mptString.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -292,47 +292,6 @@ } -#if defined(_MFC_VER) - -CString ToCString(const std::string &src, Charset charset) -{ - #ifdef UNICODE - return mpt::String::Decode(src, charset).c_str(); - #else - return mpt::String::Convert(src, charset, mpt::CharsetLocale).c_str(); - #endif -} - -CString ToCString(const std::wstring &src) -{ - #ifdef UNICODE - return src.c_str(); - #else - return mpt::String::Encode(src, mpt::CharsetLocale).c_str(); - #endif -} - -std::string FromCString(const CString &src, Charset charset) -{ - #ifdef UNICODE - return mpt::String::Encode(src.GetString(), charset); - #else - return mpt::String::Convert(src.GetString(), mpt::CharsetLocale, charset); - #endif -} - -std::wstring FromCString(const CString &src) -{ - #ifdef UNICODE - return src.GetString(); - #else - return mpt::String::Decode(src.GetString(), mpt::CharsetLocale); - #endif -} - -#endif - - } // namespace String @@ -439,7 +398,7 @@ } std::string ToString(const char & x) { return std::string(1, x); } -std::string ToString(const wchar_t & x) { return mpt::String::Encode(std::wstring(1, x), mpt::CharsetLocale); } +std::string ToString(const wchar_t & x) { return mpt::ToLocale(std::wstring(1, x)); } std::string ToString(const bool & x) { return ToStringHelper(x); } std::string ToString(const signed char & x) { return ToStringHelper(x); } std::string ToString(const unsigned char & x) { return ToStringHelper(x); } @@ -455,7 +414,7 @@ std::string ToString(const double & x) { return ToStringHelper(x); } std::string ToString(const long double & x) { return ToStringHelper(x); } -std::wstring ToWString(const char & x) { return mpt::String::Decode(std::string(1, x), mpt::CharsetLocale); } +std::wstring ToWString(const char & x) { return mpt::ToWide(mpt::CharsetLocale, std::string(1, x)); } std::wstring ToWString(const wchar_t & x) { return std::wstring(1, x); } std::wstring ToWString(const bool & x) { return ToWStringHelper(x); } std::wstring ToWString(const signed char & x) { return ToWStringHelper(x); } Modified: trunk/OpenMPT/common/mptString.h =================================================================== --- trunk/OpenMPT/common/mptString.h 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/common/mptString.h 2013-11-14 19:15:48 UTC (rev 3216) @@ -162,12 +162,21 @@ std::string To(Charset to, Charset from, const std::string &str); #if defined(_MFC_VER) + +// Convert to a MFC CString. The CString encoding depends on UNICODE. +// This should also be used when converting to TCHAR strings. +// If UNICODE is defined, this is a completely lossless operation. static inline CString ToCString(const CString &str) { return str; } CString ToCString(const std::wstring &str); CString ToCString(Charset from, const std::string &str); + +// Convert from a MFC CString. The CString encoding depends on UNICODE. +// This should also be used when converting from TCHAR strings. +// If UNICODE is defined, this is a completely lossless operation. std::wstring ToWide(const CString &str); std::string ToLocale(const CString &str); std::string To(Charset to, const CString &str); + #endif @@ -177,31 +186,17 @@ // Encode a wide unicode string into the specified encoding. // Invalid unicode code points, or code points not representable are silently substituted. // The wide encoding is UTF-16 or UTF-32, based on sizeof(wchar_t). -std::string Encode(const std::wstring &src, Charset to); +MPT_DEPRECATED std::string Encode(const std::wstring &src, Charset to); // Decode a 8-bit or multi-byte encoded string from the specified charset into a wide unicode string. // Invalid char sequences are silently substituted. // The wide encoding is UTF-16 or UTF-32, based on sizeof(wchar_t). -std::wstring Decode(const std::string &src, Charset from); +MPT_DEPRECATED std::wstring Decode(const std::string &src, Charset from); // Convert from one 8-bit charset to another. // This is semantically equivalent to Encode(Decode(src, from), to). -std::string Convert(const std::string &src, Charset from, Charset to); +MPT_DEPRECATED std::string Convert(const std::string &src, Charset from, Charset to); -#if defined(_MFC_VER) -// Convert to a MFC CString. The CString encoding depends on UNICODE. -// This should also be used when converting to TCHAR strings. -// If UNICODE is defined, this is a completely lossless operation. -CString ToCString(const std::string &src, Charset charset); -CString ToCString(const std::wstring &src); - -// Convert from a MFC CString. The CString encoding depends on UNICODE. -// This should also be used when converting from TCHAR strings. -// If UNICODE is defined, this is a completely lossless operation. -std::string FromCString(const CString &src, Charset charset); -std::wstring FromCString(const CString &src); -#endif - } // namespace String } // namespace mpt Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -231,7 +231,7 @@ else if ( encoding == "cp437" ) { charset = mpt::CharsetCP437; } else if ( encoding == "windows-1252" ) { charset = mpt::CharsetWindows1252; } else { charset = mpt::CharsetASCII; } // fallback - return mpt::String::Convert( encoded, charset, mpt::CharsetUTF8 ); + return mpt::To( mpt::CharsetUTF8, charset, encoded ); } void module_impl::apply_mixer_settings( std::int32_t samplerate, int channels ) { if ( Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -206,7 +206,7 @@ mpt::PathString CAutoSaver::BuildFileName(CModDoc &modDoc) //-------------------------------------------------------- { - std::wstring timeStamp = mpt::String::FromCString((CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S")); + std::wstring timeStamp = mpt::ToWide((CTime::GetCurrentTime()).Format("%Y%m%d.%H%M%S")); mpt::PathString name; if(m_bUseOriginalPath) Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -1663,7 +1663,7 @@ if(!errText.IsEmpty()) { std::wstring err = L"The following problems have been encountered while trying to load the key binding file " + filenameDescription + L":\n"; - err += mpt::String::FromCString(errText); + err += mpt::ToWide(errText); Reporting::Warning(err); } Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -1345,7 +1345,7 @@ CSoundFile &sndFile = m_pModDoc.GetrSoundFile(); if(nSeq == MAX_SEQUENCES + 2) { - std::wstring str = L"Delete sequence " + StringifyW(sndFile.Order.GetCurrentSequenceIndex()) + L": " + mpt::String::Decode(sndFile.Order.GetName(), mpt::CharsetLocale) + L"?"; + std::wstring str = L"Delete sequence " + StringifyW(sndFile.Order.GetCurrentSequenceIndex()) + L": " + mpt::ToWide(mpt::CharsetLocale, sndFile.Order.GetName()) + L"?"; if (Reporting::Confirm(str) == cnfYes) sndFile.Order.RemoveSequence(); else Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -1065,9 +1065,9 @@ SanitizeFilename(sSampleName); SanitizeFilename(sSampleFilename); - fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_number%", mpt::String::FromCString(sSampleNumber))); - fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_filename%", mpt::String::FromCString(sSampleFilename))); - fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_name%", mpt::String::FromCString(sSampleName))); + fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_number%", mpt::ToWide(sSampleNumber))); + fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_filename%", mpt::ToWide(sSampleFilename))); + fileName = mpt::PathString::FromWide(mpt::String::Replace(fileName.ToWide(), L"%sample_name%", mpt::ToWide(sSampleName))); } if(!mpt::PathString::CompareNoCase(ext, MPT_PATHSTRING("raw"))) ok = m_sndFile.SaveRAWSample(smp, fileName); Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -39,7 +39,7 @@ { CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); - const mpt::PathString timestampDir = mpt::PathString::FromWide(mpt::String::FromCString((CTime::GetCurrentTime()).Format("%Y-%m-%d %H.%M.%S\\"))); + const mpt::PathString timestampDir = mpt::PathString::FromWide(mpt::ToWide((CTime::GetCurrentTime()).Format("%Y-%m-%d %H.%M.%S\\"))); mpt::PathString baseRescuePath; { // Create a crash directory @@ -53,7 +53,7 @@ baseRescuePath += timestampDir; if(!PathIsDirectoryW(baseRescuePath.AsNative().c_str()) && !CreateDirectoryW(baseRescuePath.AsNative().c_str(), nullptr)) { - errorMessage.AppendFormat("\n\nCould not create the following directory for saving debug information and modified files to:\n%s", mpt::String::ToCString(baseRescuePath.ToWide())); + errorMessage.AppendFormat("\n\nCould not create the following directory for saving debug information and modified files to:\n%s", mpt::ToCString(baseRescuePath.ToWide())); } } Modified: trunk/OpenMPT/mptrack/FileDialog.h =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.h 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/FileDialog.h 2013-11-14 19:15:48 UTC (rev 3216) @@ -37,15 +37,15 @@ // Default extension to use if none is specified. FileDialog &DefaultExtension(const mpt::PathString &ext) { defaultExtension = ext.ToWide(); return *this; } FileDialog &DefaultExtension(const std::wstring &ext) { defaultExtension = ext; return *this; } - FileDialog &DefaultExtension(const std::string &ext) { defaultExtension = mpt::String::Decode(ext, mpt::CharsetLocale); return *this; } + FileDialog &DefaultExtension(const std::string &ext) { defaultExtension = mpt::ToWide(mpt::CharsetLocale, ext); return *this; } // Default suggested filename. FileDialog &DefaultFilename(const mpt::PathString &name) { defaultFilename = name.ToWide(); return *this; } FileDialog &DefaultFilename(const std::wstring &name) { defaultFilename = name; return *this; } - FileDialog &DefaultFilename(const std::string &name) { defaultFilename = mpt::String::Decode(name, mpt::CharsetLocale); return *this; } + FileDialog &DefaultFilename(const std::string &name) { defaultFilename = mpt::ToWide(mpt::CharsetLocale, name); return *this; } // List of possible extensions. Format: "description|extensions|...|description|extensions||" FileDialog &ExtensionFilter(const mpt::PathString &filter) { extFilter = filter.ToWide(); return *this; } FileDialog &ExtensionFilter(const std::wstring &filter) { extFilter = filter; return *this; } - FileDialog &ExtensionFilter(const std::string &filter) { extFilter = mpt::String::Decode(filter, mpt::CharsetLocale); return *this; } + FileDialog &ExtensionFilter(const std::string &filter) { extFilter = mpt::ToWide(mpt::CharsetLocale, filter); return *this; } // Default directory of the dialog. FileDialog &WorkingDirectory(const mpt::PathString &dir) { workingDirectory = dir; return *this; } // Pointer to a variable holding the index of the last extension filter to use. Holds the selected filter after the dialog has been closed. @@ -103,7 +103,7 @@ std::wstring caption; public: - BrowseForFolder(const mpt::PathString &dir, const CString &caption) : workingDirectory(dir), caption(mpt::String::FromCString(caption)) { } + BrowseForFolder(const mpt::PathString &dir, const CString &caption) : workingDirectory(dir), caption(mpt::ToWide(caption)) { } // Show the folder selection dialog. bool Show(); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -707,10 +707,10 @@ } -static std::string FormatSetting(const SettingPath &path, const SettingValue &val) -//-------------------------------------------------------------------------------- +static CString FormatSetting(const SettingPath &path, const SettingValue &val) +//---------------------------------------------------------------------------- { - return mpt::String::Encode(path.FormatAsString() + L" = " + val.FormatAsString(), mpt::CharsetLocale); + return mpt::ToCString(path.FormatAsString() + L" = " + val.FormatAsString()); } @@ -730,7 +730,7 @@ m_IndexToPath.clear(); for(SettingsContainer::SettingsMap::const_iterator it = theApp.GetSettings().begin(); it != theApp.GetSettings().end(); ++it) { - int index = m_List.AddString(FormatSetting(it->first, it->second).c_str()); + int index = m_List.AddString(FormatSetting(it->first, it->second)); m_IndexToPath[index] = it->first; } } @@ -762,15 +762,15 @@ } const SettingPath path = m_IndexToPath[index]; SettingValue val = theApp.GetSettings().GetMap().find(path)->second; - CInputDlg inputDlg(this, mpt::String::Encode(path.FormatAsString(), mpt::CharsetLocale).c_str(), mpt::String::Encode(val.FormatValueAsString(), mpt::CharsetLocale).c_str()); + CInputDlg inputDlg(this, mpt::ToCString(path.FormatAsString()), mpt::ToCString(val.FormatValueAsString())); if(inputDlg.DoModal() != IDOK) { return; } - val.SetFromString(mpt::String::Decode(inputDlg.resultString.GetString(), mpt::CharsetLocale)); + val.SetFromString(mpt::ToWide(inputDlg.resultString)); theApp.GetSettings().Write(path, val); m_List.DeleteString(index); - m_List.InsertString(index, FormatSetting(path, val).c_str()); + m_List.InsertString(index, FormatSetting(path, val)); m_List.SetCurSel(index); OnSettingsChanged(); } Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -224,7 +224,7 @@ } { - std::string name = mpt::String::Encode(it->name, mpt::CharsetLocale); + CString name = mpt::ToCString(it->name); cbi.mask = CBEIF_IMAGE | CBEIF_LPARAM | CBEIF_TEXT | CBEIF_SELECTEDIMAGE | CBEIF_OVERLAY; cbi.iItem = iItem; cbi.cchTextMax = 0; @@ -247,7 +247,7 @@ cbi.iImage = IMAGE_WAVEOUT; // No image available for now, // prepend API name to name. - name = mpt::String::Encode(it->apiName, mpt::CharsetLocale) + " - " + name; + name = mpt::ToCString(it->apiName) + TEXT(" - ") + name; break; default: cbi.iImage = IMAGE_WAVEOUT; @@ -257,8 +257,9 @@ cbi.iOverlay = cbi.iImage; cbi.iIndent = 0; cbi.lParam = it->id.GetIdRaw(); - mpt::String::Copy(s, name); - cbi.pszText = s; + TCHAR tmp[256]; + _tcscpy(tmp, name); + cbi.pszText = tmp; int pos = m_CbnDevice.InsertItem(&cbi); if(cbi.lParam == m_nSoundDevice.GetIdRaw()) { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -1470,7 +1470,7 @@ SetDlgItemText(IDC_EDIT2, CString("Build Date: ") + MptVersion::GetBuildDateString().c_str()); SetDlgItemText(IDC_EDIT3, CString("OpenMPT ") + MptVersion::GetVersionStringExtended().c_str()); m_static.SubclassDlgItem(IDC_CREDITS,this); - m_static.SetCredits((mpt::String::Replace(mpt::String::Convert(MptVersion::GetFullCreditsString(), mpt::CharsetUTF8, mpt::CharsetLocale), "\n", "|") + "|" + mpt::String::Replace(MptVersion::GetContactString(), "\n", "|" ) + "||||||").c_str()); + m_static.SetCredits((mpt::String::Replace(mpt::To(mpt::CharsetLocale, mpt::CharsetUTF8, MptVersion::GetFullCreditsString()), "\n", "|") + "|" + mpt::String::Replace(MptVersion::GetContactString(), "\n", "|" ) + "||||||").c_str()); m_static.SetSpeed(DISPLAY_SLOW); m_static.SetColor(BACKGROUND_COLOR, RGB(138, 165, 219)); // Background Colour m_static.SetTransparent(); // Set parts of bitmaps with RGB(192,192,192) transparent Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -738,7 +738,7 @@ } else { - sLoadReport += L"-Unable to import " + fileNameExt + L": " + mpt::String::FromCString(GetSclImportFailureMsg(a)) + L".\n"; + sLoadReport += L"-Unable to import " + fileNameExt + L": " + mpt::ToWide(GetSclImportFailureMsg(a)) + L".\n"; } } else // scl import successful. Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -448,7 +448,7 @@ for(UINT iMidi = 0; iMidi < 128; iMidi++) { DWORD dwImage = IMAGE_NOINSTRUMENT; - s = StringifyW(iMidi) + L": " + mpt::String::Decode(szMidiProgramNames[iMidi], mpt::CharsetASCII); + s = StringifyW(iMidi) + L": " + mpt::ToWide(mpt::CharsetASCII, szMidiProgramNames[iMidi]); const LPARAM param = (MODITEM_MIDIINSTRUMENT << MIDILIB_SHIFT) | iMidi; if(!midiLib.MidiMap[iMidi].empty()) { @@ -482,7 +482,7 @@ for (UINT iPerc=24; iPerc<=84; iPerc++) { DWORD dwImage = IMAGE_NOSAMPLE; - s = mpt::String::Decode(szDefaultNoteNames[iPerc], mpt::CharsetASCII) + L": " + mpt::String::Decode(szMidiPercussionNames[iPerc - 24], mpt::CharsetASCII); + s = mpt::ToWide(mpt::CharsetASCII, szDefaultNoteNames[iPerc]) + L": " + mpt::ToWide(mpt::CharsetASCII, szMidiPercussionNames[iPerc - 24]); const LPARAM param = (MODITEM_MIDIPERCUSSION << MIDILIB_SHIFT) | iPerc; if(!midiLib.MidiMap[iPerc | 0x80].empty()) { @@ -1589,7 +1589,7 @@ if(pIns) { WCHAR s[MAX_INSTRUMENTNAME + 10]; - swprintf(s, CountOf(s), L"%3d: %s", ins, mpt::String::Decode(pIns->name, mpt::CharsetLocale).c_str()); + swprintf(s, CountOf(s), L"%3d: %s", ins, mpt::ToWide(mpt::CharsetLocale, pIns->name).c_str()); ModTreeInsert(s, IMAGE_INSTRUMENTS); } } @@ -1599,7 +1599,7 @@ if(sample.pSample) { WCHAR s[MAX_SAMPLENAME + 10]; - swprintf(s, CountOf(s), L"%3d: %s", smp, mpt::String::Decode(m_SongFile->m_szNames[smp], mpt::CharsetLocale).c_str()); + swprintf(s, CountOf(s), L"%3d: %s", smp, mpt::ToWide(mpt::CharsetLocale, m_SongFile->m_szNames[smp]).c_str()); ModTreeInsert(s, IMAGE_SAMPLES); } } @@ -1674,7 +1674,7 @@ } else if(wfd.nFileSizeHigh > 0 || wfd.nFileSizeLow >= 16) { // Get lower-case file extension without dot. - const std::string ext = mpt::String::Encode(mpt::PathString::FromNative(wfd.cFileName).GetFileExt().ToWide(), mpt::CharsetUTF8); + const std::string ext = mpt::To(mpt::CharsetUTF8, mpt::PathString::FromNative(wfd.cFileName).GetFileExt().ToWide()); char s[16]; mpt::String::Copy(s, ext); Modified: trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/sounddev/SoundDeviceASIO.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -64,7 +64,7 @@ } const std::wstring keyname = keynameBuf; #ifdef ASIO_LOG - Log("ASIO: Found \"%s\":\n", mpt::String::Encode(keynameBuf, mpt::CharsetLocale).c_str()); + Log("ASIO: Found \"%s\":\n", mpt::ToLocale(keyname).c_str()); #endif HKEY hksub = NULL; @@ -80,7 +80,7 @@ if(ERROR_SUCCESS == RegQueryValueExW(hksub, L"Description", 0, &datatype, (LPBYTE)descriptionBuf, &datasize)) { #ifdef ASIO_LOG - Log(" description =\"%s\":\n", mpt::String::Encode(descriptionBuf, mpt::CharsetLocale).c_str()); + Log(" description =\"%s\":\n", mpt::ToLocale(description).c_str()); #endif description = descriptionBuf; } else @@ -97,7 +97,7 @@ if(Util::IsCLSID(internalID)) { #ifdef ASIO_LOG - Log(" clsid=\"%s\"\n", mpt::String::Encode(idBuf, mpt::CharsetLocale).c_str()); + Log(" clsid=\"%s\"\n", mpt::ToLocale(internalID).c_str()); #endif if(SoundDeviceIndexIsValid(devices.size())) @@ -157,7 +157,7 @@ #ifdef ASIO_LOG Log("CASIODevice::Open(%d:\"%s\"): %d-bit, %d channels, %dHz\n", - GetDeviceIndex(), mpt::String::Encode(GetDeviceInternalID(), mpt::CharsetLocale).c_str(), (int)m_Settings.sampleFormat.GetBitsPerSample(), m_Settings.Channels, m_Settings.Samplerate); + GetDeviceIndex(), mpt::ToLocale(GetDeviceInternalID()).c_str(), (int)m_Settings.sampleFormat.GetBitsPerSample(), m_Settings.Channels, m_Settings.Samplerate); #endif OpenDevice(); Modified: trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/sounddev/SoundDevicePortAudio.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -311,13 +311,8 @@ if(!Pa_GetDeviceInfo(dev)) return false; result.id = SoundDeviceID(HostApiToSndDevType(hostapi), index); - result.name = mpt::String::Decode( - mpt::String::Format("%s%s", - Pa_GetDeviceInfo(dev)->name, - Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev ? " (Default)" : "" - ), - mpt::CharsetUTF8); - result.apiName = mpt::String::Decode(HostApiToString(Pa_GetDeviceInfo(dev)->hostApi).c_str(), mpt::CharsetUTF8); + result.name = mpt::ToWide(mpt::CharsetUTF8, std::string(Pa_GetDeviceInfo(dev)->name) + std::string(Pa_GetHostApiInfo(Pa_GetDeviceInfo(dev)->hostApi)->defaultOutputDevice == (PaDeviceIndex)dev ? " (Default)" : "")); + result.apiName = mpt::ToWide(mpt::CharsetUTF8, HostApiToString(Pa_GetDeviceInfo(dev)->hostApi)); return true; } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -479,8 +479,8 @@ file.WriteExtraInformation(sample, GetType()); FileTags tags; - tags.title = mpt::String::Decode(m_szNames[nSample], mpt::CharsetLocale); - tags.encoder = mpt::String::Decode(MptVersion::GetOpenMPTVersionStr(), mpt::CharsetLocale); + tags.title = mpt::ToWide(mpt::CharsetLocale, m_szNames[nSample]); + tags.encoder = mpt::ToWide(mpt::CharsetLocale, MptVersion::GetOpenMPTVersionStr()); file.WriteMetatags(tags); return true; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -889,8 +889,8 @@ std::string sUrl = "http://resources.openmpt.org/plugins/search.php?p="; for(std::vector<PLUGINDEX>::iterator i = notFoundIDs.begin(); i != notFoundIDs.end(); ++i) { - sUrl += mpt::String::Format("%08X", LittleEndian(m_MixPlugins[*i].Info.dwPluginId2)); - sUrl += mpt::String::Convert(m_MixPlugins[*i].GetLibraryName(), mpt::CharsetLocale, mpt::CharsetUTF8); + sUrl += mpt::fmt::HEX0<8>(LittleEndian(m_MixPlugins[*i].Info.dwPluginId2)); + sUrl += mpt::To(mpt::CharsetUTF8, mpt::CharsetLocale, m_MixPlugins[*i].GetLibraryName()); sUrl += "%0a"; } CTrackApp::OpenURL(mpt::PathString::FromUTF8(sUrl)); Modified: trunk/OpenMPT/soundlib/Tagging.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tagging.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/soundlib/Tagging.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -17,7 +17,7 @@ FileTags::FileTags() //------------------ { - encoder = mpt::String::Decode(MptVersion::GetOpenMPTVersionStr(), mpt::CharsetLocale); + encoder = mpt::ToWide(mpt::CharsetASCII, MptVersion::GetOpenMPTVersionStr()); } #endif // MODPLUG_NO_FILESAVE Modified: trunk/OpenMPT/soundlib/WAVTools.cpp =================================================================== --- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -504,7 +504,7 @@ void WAVWriter::WriteTag(RIFFChunk::id_type id, const std::wstring &wideText) //--------------------------------------------------------------------------- { - std::string text = mpt::String::Encode(wideText, mpt::CharsetWindows1252); + std::string text = mpt::To(mpt::CharsetWindows1252, wideText); if(!text.empty()) { const size_t length = text.length() + 1; Modified: trunk/OpenMPT/unarchiver/unrar.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unrar.cpp 2013-11-14 18:31:11 UTC (rev 3215) +++ trunk/OpenMPT/unarchiver/unrar.cpp 2013-11-14 19:15:48 UTC (rev 3216) @@ -76,7 +76,7 @@ Array<wchar> rarComment; if(rarData->Arc.GetComment(&rarComment)) { - comment = mpt::String::Encode(std::wstring(&rarComment[0], rarComment.Size()), mpt::CharsetLocale); + comment = mpt::ToLocale(std::wstring(&rarComment[0], rarComment.Size())); } // Scan all files @@ -84,7 +84,7 @@ while(rarData->Arc.SearchBlock(HEAD_FILE) > 0) { ArchiveFileInfo fileInfo; - fileInfo.name = mpt::String::Encode(rarData->Arc.FileHead.FileName, mpt::CharsetLocale); + fileInfo.name = mpt::ToLocale(std::wstring(rarData->Arc.FileHead.FileName)); fileInfo.type = ArchiveFileNormal; fileInfo.size = rarData->Arc.FileHead.UnpSize; contents.push_back(fileInfo); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |