From 51494a07d933f78f6b602e816ffd0b5f9d18558c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 27 Mar 2021 10:22:25 -0400 Subject: [PATCH] lua: run unicode-monkeypatch on Windows when loading scripts --- libaegisub/lua/script_reader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libaegisub/lua/script_reader.cpp b/libaegisub/lua/script_reader.cpp index 7730697fa..6beb9813b 100644 --- a/libaegisub/lua/script_reader.cpp +++ b/libaegisub/lua/script_reader.cpp @@ -146,6 +146,14 @@ namespace agi { namespace lua { lua_rawseti(L, -2, 2); lua_pop(L, 2); // loaders, package +#ifdef _WIN32 + // Replace the default lua IO functions with our unicode compatibile ones + luaL_loadstring(L, "require('unicode-monkeypatch')"); + if (lua_pcall(L, 0, 0, 0)) { + return false; // leave error message + } +#endif + luaL_loadstring(L, "return require('moonscript').loadstring"); if (lua_pcall(L, 0, 1, 0)) { return false; // leave error message