diff --git a/WeChatFerry/spy/util.cpp b/WeChatFerry/spy/util.cpp index 7b22be5..ff324ac 100644 --- a/WeChatFerry/spy/util.cpp +++ b/WeChatFerry/spy/util.cpp @@ -35,6 +35,21 @@ string Wstring2String(wstring ws) return s; } +string GB2312ToUtf8(const char *gb2312) +{ + int size_needed = 0; + + size_needed = MultiByteToWideChar(CP_ACP, 0, gb2312, -1, NULL, 0); + wstring ws(size_needed, 0); + MultiByteToWideChar(CP_ACP, 0, gb2312, -1, &ws[0], size_needed); + + size_needed = WideCharToMultiByte(CP_UTF8, 0, &ws[0], -1, NULL, 0, NULL, NULL); + string s(size_needed, 0); + WideCharToMultiByte(CP_UTF8, 0, &ws[0], -1, &s[0], size_needed, NULL, NULL); + + return s; +} + static int GetWeChatPath(wchar_t *path) { int ret = -1; diff --git a/WeChatFerry/spy/util.h b/WeChatFerry/spy/util.h index 11f03cd..5d79b4a 100644 --- a/WeChatFerry/spy/util.h +++ b/WeChatFerry/spy/util.h @@ -28,6 +28,7 @@ DWORD GetMemoryIntByAddress(HANDLE hProcess, DWORD address); std::wstring GetUnicodeInfoByAddress(HANDLE hProcess, DWORD address); std::wstring String2Wstring(std::string s); std::string Wstring2String(std::wstring ws); +std::string GB2312ToUtf8(const char *gb2312); std::string GetStringByAddress(DWORD address); std::string GetStringByStrAddr(DWORD addr); std::string GetStringByWstrAddr(DWORD addr);