1
0
mirror of https://github.com/libretro/RetroArch synced 2025-03-31 10:20:41 +00:00

more unicode fixes

This commit is contained in:
Brad Parker 2016-12-02 21:11:55 -05:00
parent 041fb36531
commit cc7bf6b4fa
7 changed files with 41 additions and 24 deletions

@ -15,6 +15,8 @@
#ifdef _WIN32
#include <encodings/win32.h>
#include <tchar.h>
#include <direct.h>
#else
#include <unistd.h>
@ -207,9 +209,7 @@ void fill_pathname_application_path(char *s, size_t len)
#endif
#ifdef _WIN32
DWORD ret;
#ifdef UNICODE
wchar_t ws[PATH_MAX_LENGTH] = {0};
#endif
LPTSTR ws = (LPTSTR)calloc(len, sizeof(TCHAR));
#endif
#ifdef __HAIKU__
image_info info;
@ -218,16 +218,26 @@ void fill_pathname_application_path(char *s, size_t len)
(void)i;
if (!len)
{
#ifdef _WIN32
if (ws)
free(ws);
#endif
return;
}
#ifdef _WIN32
ret = GetModuleFileName(GetModuleHandle(NULL), ws, len - 1);
memset(s, 0, len);
#ifdef UNICODE
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, sizeof(ws) / sizeof(ws[0]));
ret = GetModuleFileNameW(GetModuleHandleW(NULL), ws, sizeof(ws) / sizeof(ws[0]));
utf16_to_char_string(ws, s, len);
#else
ret = GetModuleFileName(GetModuleHandle(NULL), s, len - 1);
memcpy(s, ws, len);
#endif
if (ws)
free(ws);
s[ret] = '\0';
#elif defined(__APPLE__)
if (bundle)

@ -13,6 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <encodings/win32.h>
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
@ -719,15 +720,16 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
}
else
{
char dev_name[CCHDEVICENAME] = {0};
WCHAR_TO_CHAR_ALLOC(current_mon->szDevice, dev_name)
*style = WS_POPUP | WS_VISIBLE;
utf16_to_char_string((const uint16_t*)current_mon->szDevice, dev_name, sizeof(dev_name));
if (!win32_monitor_set_fullscreen(*width, *height,
refresh, dev_name))
{}
if (dev_name)
free(dev_name);
/* Display settings might have changed, get new coordinates. */
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)current_mon);
*mon_rect = current_mon->rcMonitor;

@ -18,6 +18,7 @@
#include <stddef.h>
#include <string.h>
#include <encodings/win32.h>
#include <tchar.h>
#include <windowsx.h>
#include <dinput.h>
@ -152,17 +153,17 @@ static bool guid_is_xinput_device(const GUID* product_guid)
for (i = 0; i < num_raw_devs; i++)
{
RID_DEVICE_INFO rdi;
char devName[128] = {0};
TCHAR devName[128] = {0};
UINT rdiSize = sizeof(rdi);
UINT nameSize = sizeof(devName);
rdi.cbSize = sizeof (rdi);
if ((raw_devs[i].dwType == RIM_TYPEHID) &&
(GetRawInputDeviceInfoA(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)product_guid->Data1)) &&
(GetRawInputDeviceInfoA(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
(strstr(devName, "IG_") != NULL) )
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
(_tcsstr(devName, TEXT("IG_")) != NULL) )
{
free(raw_devs);
raw_devs = NULL;

@ -26,6 +26,7 @@
#include <stddef.h>
#include <string.h>
#include <encodings/win32.h>
#include <boolean.h>
#include <retro_inline.h>
#include <compat/strl.h>

@ -20,6 +20,7 @@
#include <string.h>
#ifdef _WIN32
#include <encodings/win32.h>
#include <direct.h>
#else
#include <unistd.h>

@ -103,11 +103,13 @@ int retro_readdir(struct RDIR *rdir)
const char *retro_dirent_get_name(struct RDIR *rdir)
{
#if defined(_WIN32)
memset(rdir->path, 0, sizeof(rdir->path));
#ifdef UNICODE
memset(rdir->path, 0, sizeof(rdir->path));
utf16_to_char_string((const uint16_t*)rdir->entry.cFileName, rdir->path, sizeof(rdir->path));
#endif
return rdir->path;
#else
return rdir->entry.cFileName;
#endif
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
return rdir->entry.d_name;
#else

@ -76,10 +76,10 @@ struct RFILE
#define HAVE_BUFFERED_IO 1
#ifdef _WIN32
#define MODE_STR_READ L"r"
#define MODE_STR_READ_UNBUF L"rb"
#define MODE_STR_WRITE_UNBUF L"wb"
#define MODE_STR_WRITE_PLUS L"w+"
#define MODE_STR_READ TEXT("r")
#define MODE_STR_READ_UNBUF TEXT("rb")
#define MODE_STR_WRITE_UNBUF TEXT("wb")
#define MODE_STR_WRITE_PLUS TEXT("w+")
#else
#define MODE_STR_READ "r"
#define MODE_STR_READ_UNBUF "rb"
@ -116,10 +116,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
int mode_int = 0;
#if defined(HAVE_BUFFERED_IO)
#ifdef _WIN32
const wchar_t *mode_str = NULL;
wchar_t path_wide[PATH_MAX_LENGTH] = {0};
#else
const char *mode_str = NULL;
const TCHAR *mode_str = NULL;
#endif
#endif
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));
@ -212,8 +209,11 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
{
#ifdef _WIN32
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, sizeof(path_wide) / sizeof(path_wide[0]));
CHAR_TO_WCHAR_ALLOC(path, path_wide)
stream->fp = _wfopen(path_wide, mode_str);
if (path_wide)
free(path_wide);
#else
stream->fp = fopen(path, mode_str);
#endif