From b42b997f00b3b305e42cd1ceaae4f006a64b5fbc Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 8 Jun 2022 18:04:43 -0700 Subject: [PATCH] Scripting: Why does this function take PCWSTR?? --- src/script/engines/lua.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/script/engines/lua.c b/src/script/engines/lua.c index 24e54c88e..096532b8d 100644 --- a/src/script/engines/lua.c +++ b/src/script/engines/lua.c @@ -486,7 +486,7 @@ bool _luaLoad(struct mScriptEngineContext* ctx, const char* filename, struct VFi snprintf(name, sizeof(name), "=%s", filename + 1); } else { #ifdef _WIN32 - char dirname[PATH_MAX] = {0}; + wchar_t dirname[PATH_MAX] = {0}; const char* lastSlash = strrchr(filename, '/'); const char* lastBackslash = strrchr(filename, '\\'); if (lastSlash && lastBackslash) { @@ -497,7 +497,7 @@ bool _luaLoad(struct mScriptEngineContext* ctx, const char* filename, struct VFi lastSlash = lastBackslash; } if (lastSlash) { - strncpy(dirname, filename, lastSlash - filename); + MultiByteToWideChar(CP_UTF8, 0, filename, lastSlash - filename, dirname, PATH_MAX); AddDllDirectory(dirname); } #endif