summaryrefslogtreecommitdiff
path: root/src/PlatformUtils-win.cc
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2013-05-27 03:03:16 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2013-05-27 03:03:16 (GMT)
commit53e778af703e40e91c2021d4ab12f8d30e14bd60 (patch)
treef07ff59a00c00a20fc1e1fb38b2481c03e979fd0 /src/PlatformUtils-win.cc
parentcd831d6922e52d85c73846e17354ddc434debb80 (diff)
fix bugs in win version
Diffstat (limited to 'src/PlatformUtils-win.cc')
-rw-r--r--src/PlatformUtils-win.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/PlatformUtils-win.cc b/src/PlatformUtils-win.cc
index d06df51..a314ebe 100644
--- a/src/PlatformUtils-win.cc
+++ b/src/PlatformUtils-win.cc
@@ -1,7 +1,9 @@
#include "PlatformUtils.h"
#include "printutils.h"
#include <windows.h>
+#ifndef _WIN32_IE
#define _WIN32_IE 0x0501 // SHGFP_TYPE_CURRENT
+#endif
#include <shlobj.h>
// convert from windows api w_char strings (usually utf16) to utf8 std::string
@@ -11,22 +13,25 @@ std::string winapi_wstr_to_utf8( std::wstring wstr )
UINT CodePage = CP_UTF8;
DWORD dwFlags = 0;
- LPCSTR lpMultiByteStr = NULL;
- int cbMultiByte = 0;
- LPWSTR lpWideCharStr = &wstr[0];
+ LPCWSTR lpWideCharStr = &wstr[0];
int cchWideChar = (int)wstr.size();
+ LPSTR lpMultiByteStr = NULL;
+ int cbMultiByte = 0;
+ LPCSTR lpDefaultChar = NULL;
+ LPBOOL lpUsedDefaultChar = NULL;
- int numbytes = MultiByteToWideChar( CodePage, dwFlags, lpMultiByteStr,
- cbMultiByte, lpWideCharStr, cchWideChar );
+ int numbytes = WideCharToMultiByte( CodePage, dwFlags, lpWideCharStr,
+ cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar );
- cbMultiByte = numbytes;
lpMultiByteStr = &utf8_str[0];
+ cbMultiByte = numbytes;
- int result = MultiByteToWideChar( CodePage, dwFlags, lpMultiByteStr,
- cbMultiByte, lpWideCharStr, cchWideChar );
+ int result = WideCharToMultiByte( CodePage, dwFlags, lpWideCharStr,
+ cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar );
if (result != numbytes) {
PRINT("ERROR: error converting w_char str to utf8 string");
+ PRINTB("ERROR: error code %i",GetLastError());
}
return utf8_str;
contact: Jan Huwald // Impressum