Move wstr_to_utf8 to compat.h

This commit is contained in:
Chris Robinson
2018-11-03 12:55:02 -07:00
parent 5482efc921
commit e9d17c5191
2 changed files with 23 additions and 16 deletions
-16
View File
@@ -136,22 +136,6 @@ std::vector<DevMap> PlaybackDevices;
std::vector<DevMap> CaptureDevices;
std::string wstr_to_utf8(const WCHAR *wstr)
{
std::string ret;
int len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
if(len > 0)
{
ret.resize(len);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &ret[0], len, nullptr, nullptr);
ret.pop_back();
}
return ret;
}
HANDLE ThreadHdl;
DWORD ThreadID;
+23
View File
@@ -19,6 +19,29 @@ FILE *al_fopen(const char *fname, const char *mode);
#define HAVE_DYNLOAD 1
#ifdef __cplusplus
} // extern "C"
#include <string>
inline std::string wstr_to_utf8(const WCHAR *wstr)
{
std::string ret;
int len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
if(len > 0)
{
ret.resize(len);
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, &ret[0], len, nullptr, nullptr);
ret.pop_back();
}
return ret;
}
extern "C" {
#endif /* __cplusplus */
#else
#define al_fopen fopen