Skip to content

Commit

Permalink
Support UTF-8 file path
Browse files Browse the repository at this point in the history
Add UTF-8 file path support for GLFW window and SDL window.
  • Loading branch information
mao authored and mao committed Nov 23, 2023
1 parent d4d5534 commit 5ba45e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ protected override void RegisterCallbacks()
for (var i = 0; i < count; i++)
{
var p = Marshal.ReadIntPtr(paths, i * IntPtr.Size);
arrayOfPaths[i] = Marshal.PtrToStringAnsi(p);
arrayOfPaths[i] = SilkMarshal.PtrToString((nint) p, NativeStringEncoding.UTF8) ?? "";
}

FileDrop?.Invoke(arrayOfPaths);
Expand Down
4 changes: 3 additions & 1 deletion src/Windowing/Silk.NET.Windowing.Sdl/SdlWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.CompilerServices;
using Silk.NET.Core;
using Silk.NET.Core.Contexts;
using Silk.NET.Core.Native;
using Silk.NET.Maths;
using Silk.NET.SDL;
using Point = System.Drawing.Point;
Expand Down Expand Up @@ -402,7 +403,8 @@ public override void ProcessEvents()
}
case EventType.Dropfile:
{
_droppedFiles.Add(new string((sbyte*) @event.Drop.File));
string path = SilkMarshal.PtrToString((nint) @event.Drop.File, NativeStringEncoding.UTF8) ?? "";
_droppedFiles.Add(path);
break;
}
default:
Expand Down

0 comments on commit 5ba45e1

Please sign in to comment.