From 4f8ff79a771705d0e6cc0c602344900f4ddd83ba Mon Sep 17 00:00:00 2001 From: hanzhao Date: Mon, 18 May 2026 10:35:09 +0800 Subject: [PATCH] Fix Windows clipboard paste mojibake for CJK search text - Use UTF-16 with BOM for clip.exe stdin instead of raw utf-16le - Prevents localized Windows from treating paste bytes as ANSI - Fixes garbled input when typing app names in taskbar search Co-Authored-By: Claude Opus 4.6 (1M context) Co-authored-by: Cursor --- visual/computer/computer_action_executor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/visual/computer/computer_action_executor.py b/visual/computer/computer_action_executor.py index a2e616b..f6295b5 100644 --- a/visual/computer/computer_action_executor.py +++ b/visual/computer/computer_action_executor.py @@ -172,7 +172,9 @@ def _type_text(self, text: str): env["LC_ALL"] = "en_US.UTF-8" subprocess.run(["pbcopy"], input=text.encode("utf-8"), env=env, check=True) elif system == "Windows": - subprocess.run(["clip"], input=text.encode("utf-16le"), check=True) + # clip.exe expects UTF-16 with BOM; utf-16le alone is misread as ANSI on + # localized Windows and pastes mojibake into Search / text fields. + subprocess.run(["clip"], input=text.encode("utf-16"), check=True) else: subprocess.run(["xclip", "-selection", "clipboard"], input=text.encode("utf-8"), check=True)