diff --git a/SkinInstaller/Application.cpp b/SkinInstaller/Application.cpp index b0e5751e..564ab8f7 100644 --- a/SkinInstaller/Application.cpp +++ b/SkinInstaller/Application.cpp @@ -293,37 +293,3 @@ OSPLATFORM GetOSPlatform() return OSPLATFORM_UNKNOWN; } - -std::string ConvertToAscii(LPCTSTR str) -{ - std::string szAscii; - - if (str && *str) - { - int strLen = (int)wcslen(str); - int bufLen = WideCharToMultiByte(CP_ACP, 0, str, strLen, NULL, 0, NULL, NULL); - if (bufLen > 0) - { - szAscii.resize(bufLen); - WideCharToMultiByte(CP_ACP, 0, str, strLen, &szAscii[0], bufLen, NULL, NULL); - } - } - return szAscii; -} - -std::wstring ConvertToWide(LPCSTR str) -{ - std::wstring szWide; - - if (str && *str) - { - int strLen = (int)strlen(str); - int bufLen = MultiByteToWideChar(CP_ACP, 0, str, strLen, NULL, 0); - if (bufLen > 0) - { - szWide.resize(bufLen); - MultiByteToWideChar(CP_ACP, 0, str, strLen, &szWide[0], bufLen); - } - } - return szWide; -} \ No newline at end of file diff --git a/SkinInstaller/Application.h b/SkinInstaller/Application.h index d07e9e72..85efad5c 100644 --- a/SkinInstaller/Application.h +++ b/SkinInstaller/Application.h @@ -53,7 +53,5 @@ OSPLATFORM GetOSPlatform(); bool IsRunning(const WCHAR* name, HANDLE* hMutex); bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false); -std::string ConvertToAscii(LPCTSTR str); -std::wstring ConvertToWide(LPCSTR str); #endif diff --git a/SkinInstaller/DialogInstall.cpp b/SkinInstaller/DialogInstall.cpp index 2403c835..a5b785e1 100644 --- a/SkinInstaller/DialogInstall.cpp +++ b/SkinInstaller/DialogInstall.cpp @@ -21,6 +21,7 @@ #include "DialogInstall.h" #include "../Library/pcre-8.10/config.h" #include "../Library/pcre-8.10/pcre.h" +#include "../Common/StringUtil.h" #include "resource.h" #include "../Version.h" @@ -388,7 +389,7 @@ bool CDialogInstall::ReadPackage() return false; } - m_PackageUnzFile = unzOpen(ConvertToAscii(fileName).c_str()); + m_PackageUnzFile = unzOpen(StringUtil::NarrowUTF8(fileName).c_str()); if (!m_PackageUnzFile) { return false; @@ -409,7 +410,7 @@ bool CDialogInstall::ReadPackage() unz_file_info ufi; if (unzGetCurrentFileInfo(m_PackageUnzFile, &ufi, cBuffer, MAX_PATH, NULL, 0, NULL, 0) == UNZ_OK) { - MultiByteToWideChar(CP_ACP, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); + MultiByteToWideChar(CP_UTF8, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); while (WCHAR* pos = wcschr(buffer, L'/')) *pos = L'\\'; return true; } @@ -717,7 +718,7 @@ bool CDialogInstall::InstallPackage() unz_file_info ufi; if (unzGetCurrentFileInfo(m_PackageUnzFile, &ufi, cBuffer, MAX_PATH, NULL, 0, NULL, 0) == UNZ_OK) { - MultiByteToWideChar(CP_ACP, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); + MultiByteToWideChar(CP_UTF8, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); while (WCHAR* pos = wcschr(buffer, L'/')) *pos = L'\\'; return true; } diff --git a/SkinInstaller/DialogPackage.cpp b/SkinInstaller/DialogPackage.cpp index e40d8ea4..9ce05212 100644 --- a/SkinInstaller/DialogPackage.cpp +++ b/SkinInstaller/DialogPackage.cpp @@ -20,6 +20,7 @@ #include "Application.h" #include "DialogPackage.h" #include "DialogInstall.h" +#include "../Common/StringUtil.h" #include "resource.h" #include "../Version.h" @@ -264,7 +265,7 @@ bool CDialogPackage::CreatePackage() WritePrivateProfileString(L"rmskin", L"MinimumWindows", m_MinimumWindows.c_str(), tempFile); // Create archive and add options file and header bitmap - m_ZipFile = zipOpen(ConvertToAscii(m_TargetFile.c_str()).c_str(), APPEND_STATUS_CREATE); + m_ZipFile = zipOpen(StringUtil::NarrowUTF8(m_TargetFile).c_str(), APPEND_STATUS_CREATE); auto cleanup = [&]()->bool { @@ -379,16 +380,16 @@ unsigned __stdcall CDialogPackage::PackagerThreadProc(void* pParam) bool CDialogPackage::AddFileToPackage(const WCHAR* filePath, const WCHAR* zipPath) { - std::string zipPathAscii = ConvertToAscii(zipPath); - for (int i = 0, isize = zipPathAscii.length(); i < isize; ++i) + std::string zipPathUTF8 = StringUtil::NarrowUTF8(zipPath); + for (int i = 0, isize = zipPathUTF8.length(); i < isize; ++i) { - if (zipPathAscii[i] == '\\') + if (zipPathUTF8[i] == '\\') { - zipPathAscii[i] = '/'; + zipPathUTF8[i] = '/'; } } - int open = zipOpenNewFileInZip(m_ZipFile, zipPathAscii.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + int open = zipOpenNewFileInZip(m_ZipFile, zipPathUTF8.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); if (open != ZIP_OK) { return false; @@ -743,7 +744,7 @@ INT_PTR CALLBACK CDialogPackage::SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARA bool x32 = LOWORD(wParam) == IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON; - LOADED_IMAGE* loadedImage = ImageLoad(ConvertToAscii(buffer).c_str(), NULL); + LOADED_IMAGE* loadedImage = ImageLoad(StringUtil::NarrowUTF8(buffer).c_str(), NULL); if (loadedImage) { WORD machine = loadedImage->FileHeader->FileHeader.Machine; diff --git a/SkinInstaller/SkinInstaller.vcxproj b/SkinInstaller/SkinInstaller.vcxproj index 80f2aae3..a60ca291 100644 --- a/SkinInstaller/SkinInstaller.vcxproj +++ b/SkinInstaller/SkinInstaller.vcxproj @@ -134,6 +134,7 @@ + @@ -170,6 +171,7 @@ + diff --git a/SkinInstaller/SkinInstaller.vcxproj.filters b/SkinInstaller/SkinInstaller.vcxproj.filters index b830088f..dc601432 100644 --- a/SkinInstaller/SkinInstaller.vcxproj.filters +++ b/SkinInstaller/SkinInstaller.vcxproj.filters @@ -22,6 +22,9 @@ {73cc243e-5b60-4fbc-ae48-069c6decc4ed} + + {65d4ccc5-15bd-4268-a539-ebf090e28d5d} + @@ -87,6 +90,9 @@ Source Files + + Common + @@ -155,6 +161,9 @@ Header Files + + Common +