JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix: 日志中文乱码 issue 139
Haowei_Ducf865c177ba0
diff --git a/jiuwenclaw/agentserver/tools/command_tools.py b/jiuwenclaw/agentserver/tools/command_tools.pyindex dd71755009..49f38c98e8 100644--- a/jiuwenclaw/agentserver/tools/command_tools.py+++ b/jiuwenclaw/agentserver/tools/command_tools.py@@ -6,6 +6,7 @@ from __future__ import annotationsimport asyncioimport json+import localeimport osimport reimport shutil@@ -164,12 +165,15 @@ def _run_command_sync(shell_type: str,) -> tuple[subprocess.CompletedProcess[str], str]:plan, use_shell, resolved_shell = _resolve_execution_plan(command, shell_type)+ # Windows 下 cmd 的输出通常是系统代码页(常见 CP936/GBK),+ # 这里不要强行按 UTF-8 解码,否则会出现中文乱码(如 .lnk 名称)。+ encoding = locale.getpreferredencoding(False) or "utf-8"result = subprocess.run(plan,shell=use_shell,cwd=str(workdir),text=True,- encoding='utf-8',+ encoding=encoding,errors='replace',capture_output=True,timeout=timeout_seconds,