From 3aa97e44e730f1a57d4ab59e076cbde5ce07deea Mon Sep 17 00:00:00 2001 From: Andrey Prygunkov Date: Tue, 29 Dec 2015 22:53:36 +0100 Subject: [PATCH] #136: adjustment in par2-module using built-in latin1-to-utf8 conversion routine instead of Windows function (which depend on current code page). --- daemon/util/FileSystem.cpp | 12 ------------ daemon/util/FileSystem.h | 1 - lib/par2/descriptionpacket.cpp | 4 ++-- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/daemon/util/FileSystem.cpp b/daemon/util/FileSystem.cpp index 3c35eb06..e54ffd34 100644 --- a/daemon/util/FileSystem.cpp +++ b/daemon/util/FileSystem.cpp @@ -830,18 +830,6 @@ CString FileSystem::WidePathToUtfPath(const wchar_t* wpath) int copied = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, utfstr, 1024, NULL, NULL); return utfstr; } - -CString FileSystem::AnsiPathToUtfPath(const char* ansipath) -{ - wchar_t wstr[1024]; - char utfstr[1024]; - int copied = MultiByteToWideChar(CP_ACP, 0, ansipath, -1, wstr, 1024); - if (copied > 0) - { - copied = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, utfstr, 1024, NULL, NULL); - } - return copied > 0 ? utfstr : ansipath; -} #endif diff --git a/daemon/util/FileSystem.h b/daemon/util/FileSystem.h index 8bdb64f1..6096173e 100644 --- a/daemon/util/FileSystem.h +++ b/daemon/util/FileSystem.h @@ -79,7 +79,6 @@ public: #ifdef WIN32 static WString UtfPathToWidePath(const char* utfpath); static CString WidePathToUtfPath(const wchar_t* wpath); - static CString AnsiPathToUtfPath(const char* ansipath); #endif }; diff --git a/lib/par2/descriptionpacket.cpp b/lib/par2/descriptionpacket.cpp index a14c54e0..163fca12 100644 --- a/lib/par2/descriptionpacket.cpp +++ b/lib/par2/descriptionpacket.cpp @@ -19,7 +19,7 @@ #include "nzbget.h" #include "par2cmdline.h" -#include "FileSystem.h" +#include "Util.h" #ifdef _MSC_VER #ifdef _DEBUG @@ -109,7 +109,7 @@ bool DescriptionPacket::Load(DiskFile *diskfile, u64 offset, PACKET_HEADER &head return false; #ifdef WIN32 - filename = *FileSystem::AnsiPathToUtfPath((char*)((FILEDESCRIPTIONPACKET*)packetdata)->name); + filename = *WebUtil::Latin1ToUtf8((char*)((FILEDESCRIPTIONPACKET*)packetdata)->name); #endif // Are the file and 16k hashes consistent