TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.2k stars 385 forks source link

Accented characters in Bizhawk path can prevent some LUA scripts from loading #3970

Open jaku opened 4 months ago

jaku commented 4 months ago

Summary

If Bizhawk is running from a folder with a accented character like é, and LUA scripts loaded that are looking for socket.core functionality are used, it will throw an error about being unable to find DLLs that would otherwise load just fine.

Repro

  1. Create a folder like "Bizhawk Tést"
  2. Put bizhawk files in that folder
  3. Run a game and load a lua script like the connector.lua script from the crowdcontrol-lua.zip attached
  4. Get output errors!

Note: The lua files can be inside the accented folder or not. But if just the lua files are in the accented folder and bizhawk is not, things work fine.

Output

NLua.Exceptions.LuaScriptException: [string "main"]:57: module 'socket.core' not found:
    no field package.preload['socket.core']
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\lua\socket\core.lua'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\lua\socket\core\init.lua'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\socket\core.lua'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\socket\core\init.lua'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\..\share\lua\5.4\socket\core.lua'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\..\share\lua\5.4\socket\core\init.lua'
    no file '.\socket\core.lua'
    no file '.\socket\core\init.lua'
    no file 'H:\CC\Bizhawk Tést\Bizhawk-2.9.1\Lua\socket\core.dll'
    no file 'H:\CC\Bizhawk Tést\Bizhawk-2.9.1\Lua\loadall.dll'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\socket\core.dll'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\..\lib\lua\5.4\socket\core.dll'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\loadall.dll'
    no file 'H:\CC\Bizhawk Tést\Bizhawk-2.9.1\Lua\socket.dll'
    no file 'H:\CC\Bizhawk Tést\Bizhawk-2.9.1\Lua\loadall.dll'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\socket.dll'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\..\lib\lua\5.4\socket.dll'
    no file 'H:\CC\Bizhawk T st\Bizhawk-2.9.1\loadall.dll'

Host env.

CasualPokePlayer commented 4 months ago

This could be considered a "bug" in Lua itself. https://github.com/lua/lua/blob/c1dc08e8e8e22af9902a6341b4a9a9a7811954cc/loadlib.c#L428 fopen is used check if the file exist. This is bad on Windows as if non-ASCII UTF-8 is passed here, it usually doesn't work, as Windows has it use the local codepage rather than UTF-8 by default. A UTF-8 string here has to be converted into UTF-16 then the w* APIs must be used.

Presumingly this bug would not occur on Linux with a similar directory structure (since that actually uses UTF-8 typically).

Morilli commented 4 months ago

So the solution is to set the UTF-8 codepage globally in windows