Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
On Windows, command hooks receive corrupted UTF-8 for Chinese text in the JSON payload on stdin, even though Cursor’s own Hooks output / UI shows the prompt correctly. This affects beforeSubmitPrompt and likely other hook events that include user text.
The issue appears to be UTF-8 bytes being misinterpreted as GBK (or similar code page) when Cursor writes hook stdin, not a problem in the hook script itself.
Steps to Reproduce
- On Windows, configure a user hook in
~/.cursor/hooks.json:
{
"version": 1,
"hooks": {
"beforeSubmitPrompt": [{ "command": "./hooks/curl-notify.exe" }]
}
}
-
Implement the hook as a small program that:
- Reads all bytes from stdin
- Logs the raw body to stderr (so Cursor Hooks output channel shows it)
- Does not transform encoding
-
Restart Cursor.
-
In Agent chat, submit a prompt containing Chinese, e.g.
中文测试. -
Open Cursor → Hooks output channel and inspect stderr from the hook.
Expected Behavior
The JSON on hook stdin should contain the same UTF-8 text as shown in Cursor, e.g.:
"prompt": "中文测试"
No BOM. Bytes for the prompt should be:
e4 b8 ad e6 96 87 e6 b5 8b e8 af 95
The hook receives valid UTF-8 JSON, but the Chinese content inside is already garbled before the hook process reads it.
Example stderr output:
curl-notify raw: 665 bytes
curl-notify: stripped UTF-8 BOM
curl-notify raw prompt="涓\ue15f枃娴嬭瘯" hex=e6b693ee859fe69e83e5a8b4e5acade798af
Observations:
- UTF-8 BOM (
EF BB BF) is present before{in the stdin payload. promptis mojibake, not the original Chinese.- A Private Use Area character appears in the string (
U+E15F, bytesEE 85 9F), suggesting bytes were lost or mis-decoded during conversion. - This happens with:
bash+curl --data-binary @-- Go binary with direct
io.ReadAll(os.Stdin)(no shell involved)
So the corruption occurs when Cursor passes data to the hook subprocess, not in HTTP forwarding or hook script encoding.
Operating System
Windows 10/11
Version Information
Version: 3.15.6 (user setup)
VS Code Extension API: 1.128.0
Commit: a1f686545fd0ce8917bbd2449f733551a9bce420
Date: 2026-08-06T01:41:03.876Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.291
OS: Windows_NT x64 10.0.26200
Does this stop you from using Cursor
No - Cursor works, but with this issue