You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnicodeEncodeError (charmap codec) on Windows in Unsloth Studio / DiffusionGemma #6489
Bug Report: UnicodeEncodeError (charmap codec) on Windows in Unsloth Studio
Problem Description
When running Unsloth Studio on Windows, if a chat prompt, system prompt, or template contains non-ASCII Unicode characters (such as the right arrow symbol → / \u2192, which is common in many chat templates), the inference process crashes immediately with a Python encoding error:
[engine error: 'charmap' codec can't encode character '\u2192' in position 3140: character maps to <undefined>]
This error is generated by the unsloth_zoo.diffusion_studio.shim server process and returned to the client as an assistant response block.
Root Cause
On Windows, Python's built-in open() function and the subprocess.Popen(..., text=True) interface default to the system's preferred ANSI code page (typically cp1252 or another charmap encoding depending on the system locale), rather than UTF-8.
There are three places in the Unsloth Studio backend where this triggers crashes:
visual_engine.py — File I/O encoding:
In visual_engine.py, the request file used to communicate with the child process (VisualServer) is written using open(self.req, "w") without specifying an encoding.
visual_engine.py — Subprocess Pipe encoding:
The VisualServer subprocess (llama-diffusion-gemma-visual-server) is spawned with text=True but no encoding, causing stdout decoding crashes when the child process outputs Unicode characters.
shim.py — Template loader encoding:
The canvas player HTML template is loaded via open(_PLAYER_TEMPLATE).read() without specifying an encoding.
Proposed Fix / PR
I have submitted a Pull Request fixing these Windows I/O encoding issues in the unsloth-zoo repository here: unslothai/unsloth-zoo#797
Seeing the same type of error with an emoji. also on Windows:
Error generating dataset: 'charmap' codec can't encode character '\U0001f60e' in position 2582: character maps to <undefined>
Fixed! Sorry on the delay. The request file write that raised this was fixed earlier in unslothai/unsloth-zoo#864, and the remaining part (DiffusionGemma replies with umlauts, arrows, emoji or CJK coming back garbled on Windows because the server output was decoded with the Windows code page) is fixed in unslothai/unsloth-zoo#797. It will be in the next release.
To update: Unsloth Desktop will have an update banner. For Studio, use unsloth studio update. For Docker, use docker exec <container> unsloth-studio-update. Reopen if it still happens.
Activity
Use UTF-8 for code/shell execution subprocess I/O
Use UTF-8 for Python code-execution subprocess I/O
Use UTF-8 for Python code-execution subprocess I/O (#6489 class) (#6548)
ekinnee commentedon Jul 26, 2026
Seeing the same type of error with an emoji. also on Windows:
Error generating dataset: 'charmap' codec can't encode character '\U0001f60e' in position 2582: character maps to <undefined>
danielhanchen commentedon Oct 11, 2026
Fixed! Sorry on the delay. The request file write that raised this was fixed earlier in unslothai/unsloth-zoo#864, and the remaining part (DiffusionGemma replies with umlauts, arrows, emoji or CJK coming back garbled on Windows because the server output was decoded with the Windows code page) is fixed in unslothai/unsloth-zoo#797. It will be in the next release.
To update: Unsloth Desktop will have an update banner. For Studio, use
unsloth studio update. For Docker, usedocker exec <container> unsloth-studio-update. Reopen if it still happens.Decode DiffusionGemma visual server output as UTF-8 on Windows (unslo…