From 63ebf5c19fd01dc9b7d59db658f290e0a05d82bc Mon Sep 17 00:00:00 2001 From: hejingwen Date: Fri, 29 Dec 2023 10:06:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8=20.net5=20.net6?= =?UTF-8?q?=20=E7=89=88=E6=9C=AC=E7=9A=84=E4=B8=AD=E6=96=87=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetStudio/LuaDecompile/OutputProcess.cs | 1 + .../handlers/LuaJitDecompileHandler.cs | 1 + .../LuaDecompile/handlers/LuacDecompileHandler.cs | 14 +++++++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/AssetStudio/LuaDecompile/OutputProcess.cs b/AssetStudio/LuaDecompile/OutputProcess.cs index cd965972..e3f14a97 100644 --- a/AssetStudio/LuaDecompile/OutputProcess.cs +++ b/AssetStudio/LuaDecompile/OutputProcess.cs @@ -16,6 +16,7 @@ public OutputProcess() { StartInfo.RedirectStandardOutput = true; StartInfo.RedirectStandardError = true; + OutputDataReceived += OnProcessOutput; ErrorDataReceived += OnProcessError; } diff --git a/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs b/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs index 9b8092e0..4db859ff 100644 --- a/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs +++ b/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs @@ -67,6 +67,7 @@ private OutputProcess BuildProcess(string pythonExePath, string args) decompileProcess.StartInfo.FileName = pythonExePath; decompileProcess.StartInfo.Arguments = args; decompileProcess.StartInfo.UseShellExecute = false; + decompileProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8; return decompileProcess; } } diff --git a/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs b/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs index 5673914c..82da4ca9 100644 --- a/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs +++ b/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs @@ -17,7 +17,7 @@ public class LuacDecompileHandler : ILuaDecompileHandler private const string EXE_DIR = "Dependencies/luadec"; private const string TEMP_FILE = "tempCompiledLua.lua"; - private static readonly string DecompileArg = "-se UTF8 " + TEMP_FILE; + private static readonly string DecompileArg = $"-se UTF8 {TEMP_FILE}"; public byte[] Decompile(LuaByteInfo luaByteInfo) { @@ -36,10 +36,11 @@ public byte[] Decompile(LuaByteInfo luaByteInfo) private byte[] TryDecompile(LuaByteInfo luaByteInfo, string exePath) { - File.WriteAllBytes(TEMP_FILE, luaByteInfo.RawByte); + File.WriteAllBytes(TEMP_FILE, luaByteInfo.RawByte); var decompileProcess = new OutputProcess(); decompileProcess.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, EXE_DIR, exePath); decompileProcess.StartInfo.Arguments = DecompileArg; + decompileProcess.StartInfo.StandardOutputEncoding = Encoding.Default; decompileProcess.StartInfo.UseShellExecute = false; try { @@ -47,9 +48,12 @@ private byte[] TryDecompile(LuaByteInfo luaByteInfo, string exePath) decompileProcess.WaitForExit(); if (decompileProcess.ExitCode == 0) { - // 编译完成结果缓存起来 - var gbkEncode = Encoding.GetEncoding("gbk"); - luaByteInfo.SetDecompiledContent(gbkEncode.GetBytes(decompileProcess.Output)); + // 编译完成结果缓存起来; + luaByteInfo.SetDecompiledContent(Encoding.Default.GetBytes(decompileProcess.Output)); + } + else + { + Console.WriteLine(decompileProcess.Error); } } catch (Exception e) From fa52dd431719324408ab26ae1bef869786ff0fe7 Mon Sep 17 00:00:00 2001 From: hejingwen Date: Fri, 29 Dec 2023 10:34:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=8C=87=E5=AE=9AUTF8=E8=AF=BB=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs b/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs index 82da4ca9..864d9d20 100644 --- a/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs +++ b/AssetStudio/LuaDecompile/handlers/LuacDecompileHandler.cs @@ -40,7 +40,7 @@ private byte[] TryDecompile(LuaByteInfo luaByteInfo, string exePath) var decompileProcess = new OutputProcess(); decompileProcess.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, EXE_DIR, exePath); decompileProcess.StartInfo.Arguments = DecompileArg; - decompileProcess.StartInfo.StandardOutputEncoding = Encoding.Default; + decompileProcess.StartInfo.StandardOutputEncoding = Encoding.UTF8; decompileProcess.StartInfo.UseShellExecute = false; try { @@ -49,7 +49,7 @@ private byte[] TryDecompile(LuaByteInfo luaByteInfo, string exePath) if (decompileProcess.ExitCode == 0) { // 编译完成结果缓存起来; - luaByteInfo.SetDecompiledContent(Encoding.Default.GetBytes(decompileProcess.Output)); + luaByteInfo.SetDecompiledContent(Encoding.UTF8.GetBytes(decompileProcess.Output)); } else { From 76f1da6fb6b7d63703fd25f37ceda77d275f0e84 Mon Sep 17 00:00:00 2001 From: hejingwen Date: Fri, 29 Dec 2023 10:38:28 +0800 Subject: [PATCH 3/3] =?UTF-8?q?UTF8=E4=B8=8D=E7=94=A8=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs b/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs index 4db859ff..9c6ebd57 100644 --- a/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs +++ b/AssetStudio/LuaDecompile/handlers/LuaJitDecompileHandler.cs @@ -41,7 +41,6 @@ private bool TryDecompile(byte[] luaBytes, out byte[] luaCode) if (decompileProcess.ExitCode == 0) { luaCode = Encoding.UTF8.GetBytes(decompileProcess.Output); - luaCode = Encoding.Convert(Encoding.UTF8, Encoding.Default, luaCode); } else {