From 20e5ec18e1e28b83ecaa588b87973be2cf295e74 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 17 Apr 2014 21:17:48 -0700 Subject: Handle the lib name as UTF-8 --- Alc/helpers.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/Alc/helpers.c b/Alc/helpers.c index e175c195..79dac143 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -322,8 +322,35 @@ void althread_once(althread_once_t *once, void (*callback)(void)) } +static WCHAR *FromUTF8(const char *str) +{ + WCHAR *out = NULL; + int len; + + if((len=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) > 0) + { + out = calloc(sizeof(WCHAR), len); + MultiByteToWideChar(CP_UTF8, 0, str, -1, out, len); + } + return out; +} + + void *LoadLib(const char *name) -{ return LoadLibraryA(name); } +{ + HANDLE hdl = NULL; + WCHAR *wname; + + wname = FromUTF8(name); + if(!wname) + ERR("Failed to convert UTF-8 filename: \"%s\"\n", name); + else + { + hdl = LoadLibraryW(wname); + free(wname); + } + return hdl; +} void CloseLib(void *handle) { FreeLibrary((HANDLE)handle); } void *GetSymbol(void *handle, const char *name) @@ -352,19 +379,6 @@ WCHAR *strdupW(const WCHAR *str) return ret; } -static WCHAR *FromUTF8(const char *str) -{ - WCHAR *out = NULL; - int len; - - if((len=MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0)) > 0) - { - out = calloc(sizeof(WCHAR), len); - MultiByteToWideChar(CP_UTF8, 0, str, -1, out, len); - } - return out; -} - FILE *al_fopen(const char *fname, const char *mode) { WCHAR *wname=NULL, *wmode=NULL; -- cgit v1.2.3