Skip to content

fix: reconfigure stdio to UTF-8 on Windows - #1259

Closed
oussamalembarki wants to merge 2 commits into
MemPalace:developfrom
oussamalembarki:fix/mcp-windows-unicode-encoding
Closed

fix: reconfigure stdio to UTF-8 on Windows#1259
oussamalembarki wants to merge 2 commits into
MemPalace:developfrom
oussamalembarki:fix/mcp-windows-unicode-encoding

Conversation

@oussamalembarki

Copy link
Copy Markdown
Contributor

Fixes #1242.

This PR adds a platform check to reconfigure sys.stdin and sys.stdout to use UTF-8 encoding when running on Windows. This prevents UnicodeDecodeError when the MCP server receives non-ASCII characters (emojis, CJK, etc.) from clients.

@igorls igorls added this to the v3.3.5 milestone May 1, 2026
@igorls igorls added area/i18n Multilingual, Unicode, non-English embeddings area/windows Windows-specific bugs and compatibility bug Something isn't working labels May 2, 2026
@igorls

igorls commented May 2, 2026

Copy link
Copy Markdown
Member

Thanks @oussamalembarki! Closing as duplicate — #1280 is a strict superset of this fix and is the canonical PR for the Windows UTF-8 stdio cluster. It covers everything here (mcp_server stdin/stdout reconfigure) plus:

  • stderr coverage and errors="replace" so the JSON-RPC loop never crashes on undecodable bytes
  • import-time _force_utf8_stdio() call that fixes a stdout-redirect race
  • hooks_cli.run_hook reconfigure (this PR doesn't touch hooks)
  • ensure_ascii=False in JSON-RPC responses so CJK round-trips without \uXXXX escapes
  • a real cp936 subprocess regression test

Please follow #1280 (and #1282 for the CLI / fact-checker side, which neither this PR nor #1280 covers). Really appreciate the diagnosis — confirming the fix on multiple forks gives us high confidence it works.

@igorls igorls closed this May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/i18n Multilingual, Unicode, non-English embeddings area/windows Windows-specific bugs and compatibility bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diary_write fails with Unicode characters on Windows (cp950 stdin encoding)

3 participants