Skip to content

Use explicit encodings in the build scripts instead of locale-dependent defaults. - #2011

Merged
dsnopek merged 1 commit into
godotengine:masterfrom
shiena:fix/msvc-capture-log-encoding
Jul 24, 2026
Merged

dsnopek merged 1 commit into
godotengine:masterfrom
shiena:fix/msvc-capture-log-encoding

Conversation

@shiena

@shiena shiena commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

fixed #2010

Note on Windows: open() without an explicit encoding uses the ANSI code page (e.g. cp932 on Japanese Windows) rather than UTF-8, and sys.stdout.encoding follows the console code page, so text written and read with different defaults gets mixed encodings and can raise UnicodeEncodeError/UnicodeDecodeError. In text mode Python also translates \n to \r\n on write, which would change the contents of the generated raw string literals — hence newline="\n".

@shiena
shiena requested a review from a team as a code owner July 2, 2026 15:32
…nt defaults.

Note on Windows: `open()` without an explicit `encoding` uses the ANSI code
page (e.g. cp932 on Japanese Windows) rather than UTF-8, and `sys.stdout.encoding`
follows the console code page, so text written and read with different defaults
gets mixed encodings and can raise `UnicodeEncodeError`/`UnicodeDecodeError`.
In text mode Python also translates `\n` to `\r\n` on write, which would change
the contents of the generated raw string literals — hence `newline="\n"`.
@shiena
shiena force-pushed the fix/msvc-capture-log-encoding branch from 1da8d35 to 863fffd Compare July 2, 2026 16:38
@shiena shiena changed the title SCons: Write msvc_capture.log as UTF-8 to match its creation encoding Use explicit encodings in the build scripts instead of locale-dependent defaults. Jul 2, 2026
@dsnopek dsnopek added the bug This has been identified as a bug label Jul 4, 2026
@dsnopek dsnopek added this to the 10.x milestone Jul 4, 2026

@dsnopek dsnopek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I haven't tested these changes, but they look OK to me, so I'll give it a tentative approval. Let's see what CI says

@dsnopek
dsnopek merged commit 572ff3c into godotengine:master Jul 24, 2026
20 checks passed
@shiena
shiena deleted the fix/msvc-capture-log-encoding branch July 24, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

silence_msvc: UnicodeEncodeError when writing msvc_capture.log on non-UTF-8 consoles (e.g. cp932)

2 participants