diff --git a/SkinInstaller/Application.cpp b/SkinInstaller/Application.cpp index 564ab8f7..b0e5751e 100644 --- a/SkinInstaller/Application.cpp +++ b/SkinInstaller/Application.cpp @@ -293,3 +293,37 @@ 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 85efad5c..d07e9e72 100644 --- a/SkinInstaller/Application.h +++ b/SkinInstaller/Application.h @@ -53,5 +53,7 @@ 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 a5b785e1..2403c835 100644 --- a/SkinInstaller/DialogInstall.cpp +++ b/SkinInstaller/DialogInstall.cpp @@ -21,7 +21,6 @@ #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" @@ -389,7 +388,7 @@ bool CDialogInstall::ReadPackage() return false; } - m_PackageUnzFile = unzOpen(StringUtil::NarrowUTF8(fileName).c_str()); + m_PackageUnzFile = unzOpen(ConvertToAscii(fileName).c_str()); if (!m_PackageUnzFile) { return false; @@ -410,7 +409,7 @@ bool CDialogInstall::ReadPackage() unz_file_info ufi; if (unzGetCurrentFileInfo(m_PackageUnzFile, &ufi, cBuffer, MAX_PATH, NULL, 0, NULL, 0) == UNZ_OK) { - MultiByteToWideChar(CP_UTF8, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); while (WCHAR* pos = wcschr(buffer, L'/')) *pos = L'\\'; return true; } @@ -718,7 +717,7 @@ bool CDialogInstall::InstallPackage() unz_file_info ufi; if (unzGetCurrentFileInfo(m_PackageUnzFile, &ufi, cBuffer, MAX_PATH, NULL, 0, NULL, 0) == UNZ_OK) { - MultiByteToWideChar(CP_UTF8, 0, cBuffer, strlen(cBuffer) + 1, buffer, MAX_PATH); + MultiByteToWideChar(CP_ACP, 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 9ce05212..e40d8ea4 100644 --- a/SkinInstaller/DialogPackage.cpp +++ b/SkinInstaller/DialogPackage.cpp @@ -20,7 +20,6 @@ #include "Application.h" #include "DialogPackage.h" #include "DialogInstall.h" -#include "../Common/StringUtil.h" #include "resource.h" #include "../Version.h" @@ -265,7 +264,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(StringUtil::NarrowUTF8(m_TargetFile).c_str(), APPEND_STATUS_CREATE); + m_ZipFile = zipOpen(ConvertToAscii(m_TargetFile.c_str()).c_str(), APPEND_STATUS_CREATE); auto cleanup = [&]()->bool { @@ -380,16 +379,16 @@ unsigned __stdcall CDialogPackage::PackagerThreadProc(void* pParam) bool CDialogPackage::AddFileToPackage(const WCHAR* filePath, const WCHAR* zipPath) { - std::string zipPathUTF8 = StringUtil::NarrowUTF8(zipPath); - for (int i = 0, isize = zipPathUTF8.length(); i < isize; ++i) + std::string zipPathAscii = ConvertToAscii(zipPath); + for (int i = 0, isize = zipPathAscii.length(); i < isize; ++i) { - if (zipPathUTF8[i] == '\\') + if (zipPathAscii[i] == '\\') { - zipPathUTF8[i] = '/'; + zipPathAscii[i] = '/'; } } - int open = zipOpenNewFileInZip(m_ZipFile, zipPathUTF8.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + int open = zipOpenNewFileInZip(m_ZipFile, zipPathAscii.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); if (open != ZIP_OK) { return false; @@ -744,7 +743,7 @@ INT_PTR CALLBACK CDialogPackage::SelectPluginDlgProc(HWND hWnd, UINT uMsg, WPARA bool x32 = LOWORD(wParam) == IDC_PACKAGESELECTPLUGIN_32BITBROWSE_BUTTON; - LOADED_IMAGE* loadedImage = ImageLoad(StringUtil::NarrowUTF8(buffer).c_str(), NULL); + LOADED_IMAGE* loadedImage = ImageLoad(ConvertToAscii(buffer).c_str(), NULL); if (loadedImage) { WORD machine = loadedImage->FileHeader->FileHeader.Machine; diff --git a/SkinInstaller/SkinInstaller.vcxproj b/SkinInstaller/SkinInstaller.vcxproj index a60ca291..80f2aae3 100644 --- a/SkinInstaller/SkinInstaller.vcxproj +++ b/SkinInstaller/SkinInstaller.vcxproj @@ -134,7 +134,6 @@ - @@ -171,7 +170,6 @@ - diff --git a/SkinInstaller/SkinInstaller.vcxproj.filters b/SkinInstaller/SkinInstaller.vcxproj.filters index dc601432..b830088f 100644 --- a/SkinInstaller/SkinInstaller.vcxproj.filters +++ b/SkinInstaller/SkinInstaller.vcxproj.filters @@ -22,9 +22,6 @@ {73cc243e-5b60-4fbc-ae48-069c6decc4ed} - - {65d4ccc5-15bd-4268-a539-ebf090e28d5d} - @@ -90,9 +87,6 @@ Source Files - - Common - @@ -161,9 +155,6 @@ Header Files - - Common -