Skip to content

fix: specify UTF-8 encoding when reading .csproj file on Windows#397

Merged
nikitalita merged 1 commit into
GDRETools:masterfrom
YuroGod:fix/encoding-gbk-csproj-reading
Apr 16, 2026
Merged

fix: specify UTF-8 encoding when reading .csproj file on Windows#397
nikitalita merged 1 commit into
GDRETools:masterfrom
YuroGod:fix/encoding-gbk-csproj-reading

Conversation

@YuroGod
Copy link
Copy Markdown
Contributor

@YuroGod YuroGod commented Apr 16, 2026

Problem

On Windows systems with non-UTF-8 locale (e.g. Simplified Chinese using GBK),
building with scons platform=windows fails with:

UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence:
  File "modules/gdsdecomp/build/mono_decomp.py", line 53:
    for line in csproj_file:

This happens because open() without an explicit encoding falls back to the
system default (GBK on Chinese Windows), but the .csproj file is UTF-8 encoded.

Fix

Explicitly set encoding="utf-8" in the open() call for .csproj files.

On Windows systems with non-UTF-8 locale (e.g. Chinese GBK),
Python's open() defaults to the system encoding, causing
UnicodeDecodeError when reading UTF-8 encoded .csproj files.

Fixes UnicodeDecodeError: 'gbk' codec can't decode byte...
@nikitalita nikitalita merged commit 9d33c44 into GDRETools:master Apr 16, 2026
18 checks passed
@nikitalita
Copy link
Copy Markdown
Collaborator

Thank you!

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.

2 participants