解决读取iphone名称中文乱码问题
#region 解决中文乱码 Ethan 2016-01-06 [DllImport("iTunesMobileDevice.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "AMDeviceCopyValue")] public unsafe static extern __CFString* AMDeviceCopyValue_1(void* device, uint unknown, void* cfstring); [DllImport("CoreFoundation.dll", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern int CFStringGetLength(__CFString* thisString); // Token: 0x060000A3 RID: 163 [DllImport("CoreFoundation.dll", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern byte CFStringGetCString(__CFString* thisString, void* value, int length, uint format); // Token: 0x060000D5 RID: 213 //for 32位 [DllImport("msvcr71.dll", CallingConvention = CallingConvention.Cdecl)] public unsafe static extern void* malloc(uint size); // Token: 0x060000D7 RID: 215 //for 64位 [DllImport("msvcr100.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "malloc")] public unsafe static extern void* malloc_64(ulong size); // Token: 0x02000012 RID: 18 public struct __CFString { } public unsafe static string AMDeviceCopyValue_fix(void* device, string name) { string result = ""; try { __CFString* ptr = AMDeviceCopyValue_1(device, 0u, __CFStringMakeConstantString(StringToCString(name))); if (ptr != null) { uint num = (uint)CFStringGetLength(ptr); uint num2 = 4u * num + 2u; sbyte* value; try { value = (sbyte*)malloc(num2); } catch (Exception) { value = (sbyte*)malloc_64(num2); } CFStringGetCString(ptr, (void*)value, (int)num2, 134217984u); EX.UTF8Marshaler uTF8Marshaler = new EX.UTF8Marshaler(); result = (string)uTF8Marshaler.MarshalNativeToManaged(new IntPtr((void*)value)); } } catch (Exception ex) { } return result; } #endregion
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架