From 03e8c4c0c136659eb74577ee8efd269b16e16664 Mon Sep 17 00:00:00 2001 From: bobo liu Date: Wed, 9 Sep 2026 22:03:52 +0800 Subject: [PATCH] fix(launch): match IsGBKEncoding behavior with Framework --- PCL.Core/Utils/OS/KernelInterop.cs | 3 +++ PCL.Core/Utils/OS/SystemInfo.cs | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/PCL.Core/Utils/OS/KernelInterop.cs b/PCL.Core/Utils/OS/KernelInterop.cs index 72e6cd2f69..5068a8d699 100644 --- a/PCL.Core/Utils/OS/KernelInterop.cs +++ b/PCL.Core/Utils/OS/KernelInterop.cs @@ -71,6 +71,9 @@ private struct MEMORYSTATUSEX [LibraryImport("kernel32.dll", EntryPoint = "GetConsoleWindow")] private static partial nint _GetConsoleWindow(); + + [LibraryImport("kernel32.dll")] + internal static partial uint GetACP(); // ReSharper restore InconsistentNaming, UnusedMember.Local diff --git a/PCL.Core/Utils/OS/SystemInfo.cs b/PCL.Core/Utils/OS/SystemInfo.cs index 94f7b3706a..6b5756772b 100644 --- a/PCL.Core/Utils/OS/SystemInfo.cs +++ b/PCL.Core/Utils/OS/SystemInfo.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; -using System.Text; namespace PCL.Core.Utils.OS; @@ -19,7 +18,7 @@ public static class SystemInfo /// /// 是否使用 GBK 编码。 /// - public static readonly bool IsGBKEncoding = Encoding.Default.CodePage == 936; + public static readonly bool IsGBKEncoding = KernelInterop.GetACP() == 936; /// /// 系统信息描述,例如 Microsoft Windows 11 专业工作站版 10.0.22635.0