Skip to content

Commit 1e2e463

Browse files
committed
Encode strings as UTF8 when sending them to Lua, to match the string decoding.
1 parent 3c7356a commit 1e2e463

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Yafc.Parser/LuaContext.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ private enum Type {
5151
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
5252
private static partial void lua_close(IntPtr state);
5353

54-
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller))]
54+
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Utf8)]
5555
[UnmanagedCallConv(CallConvs = new System.Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
5656
private static partial Result luaL_loadbufferx(IntPtr state, in byte buf, IntPtr sz, string name, string? mode);
5757
[LibraryImport(LUA)]
5858
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
5959
private static partial Result lua_pcallk(IntPtr state, int nargs, int nresults, int msgh, IntPtr ctx, IntPtr k);
60-
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller))]
60+
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Utf8)]
6161
[UnmanagedCallConv(CallConvs = new System.Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
6262
private static partial void luaL_traceback(IntPtr state, IntPtr state2, string? msg, int level);
6363

@@ -74,10 +74,10 @@ private enum Type {
7474
[UnmanagedCallConv(CallConvs = new System.Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
7575
private static partial double lua_tonumberx(IntPtr state, int idx, [MarshalAs(UnmanagedType.Bool)] out bool isnum);
7676

77-
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller))]
77+
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Utf8)]
7878
[UnmanagedCallConv(CallConvs = new System.Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
7979
private static partial int lua_getglobal(IntPtr state, string var);
80-
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller))]
80+
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Utf8)]
8181
[UnmanagedCallConv(CallConvs = new System.Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
8282
private static partial void lua_setglobal(IntPtr state, string name);
8383
[LibraryImport(LUA)]
@@ -90,7 +90,7 @@ private enum Type {
9090
[LibraryImport(LUA)]
9191
[UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
9292
private static partial void lua_pushnil(IntPtr state);
93-
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Custom, StringMarshallingCustomType = typeof(System.Runtime.InteropServices.Marshalling.AnsiStringMarshaller))]
93+
[LibraryImport(LUA, StringMarshalling = StringMarshalling.Utf8)]
9494
[UnmanagedCallConv(CallConvs = new System.Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
9595
private static partial IntPtr lua_pushstring(IntPtr state, string s);
9696
[LibraryImport(LUA)]

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Date:
1717
- Add the ability to switch through project pages with control-tab and control-shift-tab
1818
Bugfixes:
1919
- Fix a possible threading race while destroying textures, which could cause an illegal access crash.
20+
- Fix a loading error when mods use non-ASCII characters in their settings.
2021
----------------------------------------------------------------------------------------------------------------------
2122
Version 0.7.3
2223
Date: July 21st 2024

0 commit comments

Comments
 (0)