Skip to content

Fix UnicodeDecodeError when serving UI on Windows#7

Open
PhunkyBob wants to merge 1 commit intoPromtEngineer:mainfrom
PhunkyBob:fix/windows_charmap
Open

Fix UnicodeDecodeError when serving UI on Windows#7
PhunkyBob wants to merge 1 commit intoPromtEngineer:mainfrom
PhunkyBob:fix/windows_charmap

Conversation

@PhunkyBob
Copy link

@PhunkyBob PhunkyBob commented Feb 18, 2026

Problem

On Windows, Path.read_text() defaults to the system encoding (cp1252). The ui.html file contains characters outside the cp1252 range, causing a UnicodeDecodeError at startup when the UI route was first hit.

UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 16403: character maps to <undefined>

Solution

Explicitly pass encoding="utf-8" to read_text() in the get_ui endpoint so the file is always decoded correctly regardless of the host system's default encoding.

Changed file

src/fs_explorer/server.pyget_ui function, line 90.

How to test

Run uv run uvicorn fs_explorer.server:app --host 127.0.0.1 --port 8000 on a Windows machine and navigate to the UI — no more UnicodeDecodeError.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant