fix: use UTF-8 for text file operations

This commit is contained in:
Haoran
2026-08-24 20:28:37 +08:00
parent a32a73f700
commit 199402f9d4
59 changed files with 435 additions and 289 deletions

View File

@@ -78,7 +78,7 @@ def execute_tool(name: str, args: dict) -> str:
if name == "read_file":
try:
return (WORKDIR / args["path"]).read_text()[:50000]
return (WORKDIR / args["path"]).read_text(encoding="utf-8")[:50000]
except Exception as e:
return f"Error: {e}"
@@ -86,7 +86,7 @@ def execute_tool(name: str, args: dict) -> str:
try:
p = WORKDIR / args["path"]
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(args["content"])
p.write_text(args["content"], encoding="utf-8")
return f"Wrote {len(args['content'])} bytes to {args['path']}"
except Exception as e:
return f"Error: {e}"