aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-04-17 21:17:48 -0700
committerChris Robinson <[email protected]>2014-04-17 21:17:48 -0700
commit20e5ec18e1e28b83ecaa588b87973be2cf295e74 (patch)
tree1867f41bf552d716b425b296b2d34fbfa55695d5
parent5abefaed0a21b1c97decdf6a40d582a0ac41a3ed (diff)
Handle the lib name as UTF-8
-rw-r--r--Alc/helpers.c42
1 files 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;