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..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 { @@ -67,6 +66,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..864d9d20 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.UTF8; 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.UTF8.GetBytes(decompileProcess.Output)); + } + else + { + Console.WriteLine(decompileProcess.Error); } } catch (Exception e)