From 8a13d0fe07319e6349aad89deb65b93f7bbd1394 Mon Sep 17 00:00:00 2001 From: TaurusXin Date: Sat, 6 Apr 2024 12:10:56 +0800 Subject: [PATCH] update: parse UTF-8 to lib in C# --- example/csharp/NeteaseCrypt.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/example/csharp/NeteaseCrypt.cs b/example/csharp/NeteaseCrypt.cs index f3cc68e..f78439c 100644 --- a/example/csharp/NeteaseCrypt.cs +++ b/example/csharp/NeteaseCrypt.cs @@ -30,7 +30,13 @@ namespace libncmdump_demo_cli /// 网易云音乐 ncm 加密文件路径 public NeteaseCrypt(string FileName) { - NeteaseCryptClass = CreateNeteaseCrypt(Marshal.StringToHGlobalAnsi(FileName)); + byte[] bytes = Encoding.UTF8.GetBytes(FileName); + + IntPtr inputPtr = Marshal.AllocHGlobal(bytes.Length + 1); + Marshal.Copy(bytes, 0, inputPtr, bytes.Length); + Marshal.WriteByte(inputPtr, bytes.Length, 0); + + NeteaseCryptClass = CreateNeteaseCrypt(inputPtr); } ///