On Chinese and other CJK Windows (code page 936/932/949), the Agent’s PowerShell tool still decodes command output as UTF-8 while the console runs in the system ANSI/OEM code page. So any CJK text in command output, paths, or file contents comes back garbled. This was acknowledged as a known bug in Garbled characters appear in the return values of the command-line tool, but the only workaround is a rule telling the model to run chcp 65001 and set the encodings itself. That’s unreliable and wastes tokens on every command.
This happens even on PowerShell 7: its cmdlets default to UTF-8, but [Console]::OutputEncoding still follows the OEM code page (936), so output from native executables like git, uv, node and python is decoded wrong before it reaches the agent.
Codex already solves this on its side. Its PowerShell wrapper prepends this line to every shell call:
The try/catch keeps it from erroring in ConstrainedLanguage mode (openai/codex#24949).
Could Cursor do the same in its agent shell wrapper? Ideally it would go a bit further:
Set [Console]::InputEncoding, [Console]::OutputEncoding and $OutputEncoding to UTF-8.
On Windows PowerShell 5.1, default Get-Content, Set-Content and Out-File to UTF-8 via $PSDefaultParameterValues, since 5.1 reads BOM-less UTF-8 files as ANSI.
Prefer pwsh (PowerShell 7) over powershell.exe when it’s installed.
Cursor already does this on Windows: before each agent command, its PowerShell wrapper sets [Console]::OutputEncoding, [Console]::InputEncoding and $OutputEncoding to UTF-8, and it prefers pwsh over powershell.exe when both are installed. On 3.27.14 that setup can sometimes be skipped for a whole chat session, which would match what you’re seeing. The team is aware, and newer 3.27 updates will include more encoding fixes for shell output, so updating when one reaches you is worth doing.
In the meantime, a more reliable workaround than a rule: agent commands load your PowerShell profile, so you can set this once there.
In PowerShell 7, run New-Item -ItemType Directory -Force (Split-Path $PROFILE.CurrentUserAllHosts), then notepad $PROFILE.CurrentUserAllHosts.
Thanks Colin, this is really helpful, and good to know the wrapper already sets UTF-8 and it’s just being skipped on 3.27.14.
I honestly didn’t expect agent commands to load the PowerShell profile. I’d assumed Cursor ran them with no profile the way Codex and OpenCode do, so it never occurred to me to fix this there. I added those lines to $PROFILE.CurrentUserAllHosts, restarted Cursor, and the mojibake is gone. Much cleaner than a rule.
Marking this as the solution. Looking forward to the encoding fixes in the next 3.27 updates!