more unicode fixes

This commit is contained in:
Brad Parker 2016-12-02 23:00:09 -05:00
parent e351407f67
commit d20acaa63d
5 changed files with 21 additions and 7 deletions

View File

@ -163,7 +163,15 @@ static bool guid_is_xinput_device(const GUID* product_guid)
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)product_guid->Data1)) &&
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
#ifdef _MSC_VER
(_tcsstr(devName, TEXT("IG_")) != NULL) )
#else
#ifdef UNICODE
(wcsstr((const wchar_t*)devName, L"IG_") != NULL) )
#else
(strstr(devName, "IG_" != NULL) )
#endif
#endif
{
free(raw_devs);
raw_devs = NULL;

View File

@ -47,7 +47,7 @@ struct RDIR *retro_opendir(const char *name)
#if defined(_WIN32)
#ifdef UNICODE
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW) / sizeof(pathW[0]));
MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW));
rdir->directory = FindFirstFileW(pathW, &rdir->entry);
#else
rdir->directory = FindFirstFile(path_buf, &rdir->entry);

View File

@ -197,15 +197,19 @@ bool mkdir_norecurse(const char *dir)
{
int ret;
#if defined(_WIN32)
#ifdef _MSC_VER
CHAR_TO_WCHAR_ALLOC(dir, dir_wide)
#ifdef _MSC_VER
ret = _tmkdir(dir_wide);
#else
#ifdef UNICODE
ret = _wmkdir(dir_wide);
#else
ret = _mkdir(dir_wide);
#endif
if (dir_wide)
free(dir_wide);
#else
ret = _mkdir(dir);
#endif
#elif defined(IOS)
ret = mkdir(dir, 0755);

View File

@ -25,9 +25,9 @@
#ifndef _XBOX
#ifdef _WIN32
/*#define UNICODE
#define UNICODE
#include <tchar.h>
#include <wchar.h>*/
#include <wchar.h>
#ifdef __cplusplus
extern "C" {
@ -47,7 +47,7 @@ extern "C" {
size_t ws##_size = (NULL != s && s[0] ? strlen(s) : 0) + 1; \
wchar_t *ws = (wchar_t*)calloc(ws##_size, 2); \
if (NULL != s && s[0]) \
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, ws##_size / sizeof(wchar_t));
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, ws##_size);
#define WCHAR_TO_CHAR_ALLOC(ws, s) \
size_t s##_size = ((NULL != ws && ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \

View File

@ -118,6 +118,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
#if defined(HAVE_BUFFERED_IO)
#ifdef _WIN32
const TCHAR *mode_str = NULL;
#else
const char *mode_str = NULL;
#endif
#endif
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));