fix(build): force MSVC UTF-8 source & execution charset #50

Manually merged
github merged 1 commit from gh-pr/50/head into gh-pr/50/base 2026-11-26 19:11:28 +00:00
Owner

@⁠leonredfish on GitHub · 2026-11-24 01:21 UTC · original
leonredfish:fix/msvc-utf8-charset → main · +8 −0 · 1 files · 1 commits · merged 2026-11-26 07:52 UTC

All sources are UTF-8 without BOM and 15 files under src/ contain non-ASCII bytes. Unless /utf-8 is passed, MSVC decodes them with the host ANSI code page, so on any non-UTF-8 host (936/zh-CN, 1252/en-US, ...) we get:

  • C4819 warnings ("file contains a character that cannot be represented in the current code page"), which break the repo's /W4 0-warning rule. Reproduced on 87cdba6 with MSVC 19.51 / ACP 936: include/openscarlett/gdk/xgameruntime_abi.h(755) src/shims/xgameruntime_shim.cpp(12422)
  • hard errors when such a byte lands inside a string literal, e.g. C2001 "newline in string constant" for a wide literal containing an em dash -- hit locally on src/launcher/launcher_main.cpp:1591 before afcd167 rewrote those literals.

Add /utf-8 (source + execution charset) under if(MSVC) so the build is host-locale independent. No narrow string literal carries non-ASCII text, so the execution-charset half changes no runtime behaviour, and MinGW/clang lanes are untouched.

**@⁠leonredfish** on GitHub · 2026-11-24 01:21 UTC · [original](https://github.com/californiaAlmonds/OpenScarlett/pull/50) `leonredfish:fix/msvc-utf8-charset` → `main` · +8 −0 · 1 files · 1 commits · merged 2026-11-26 07:52 UTC All sources are UTF-8 without BOM and 15 files under src/ contain non-ASCII bytes. Unless /utf-8 is passed, MSVC decodes them with the host ANSI code page, so on any non-UTF-8 host (936/zh-CN, 1252/en-US, ...) we get: * C4819 warnings ("file contains a character that cannot be represented in the current code page"), which break the repo's /W4 0-warning rule. Reproduced on 87cdba6 with MSVC 19.51 / ACP 936: include/openscarlett/gdk/xgameruntime_abi.h(755) src/shims/xgameruntime_shim.cpp(12422) * hard errors when such a byte lands inside a string literal, e.g. C2001 "newline in string constant" for a wide literal containing an em dash -- hit locally on src/launcher/launcher_main.cpp:1591 before afcd167 rewrote those literals. Add /utf-8 (source + execution charset) under if(MSVC) so the build is host-locale independent. No narrow string literal carries non-ASCII text, so the execution-charset half changes no runtime behaviour, and MinGW/clang lanes are untouched.
All sources are UTF-8 without BOM and 15 files under src/ contain non-ASCII
bytes. Unless /utf-8 is passed, MSVC decodes them with the host ANSI code
page, so on any non-UTF-8 host (936/zh-CN, 1252/en-US, ...) we get:

  * C4819 warnings ("file contains a character that cannot be represented in
    the current code page"), which break the repo's /W4 0-warning rule.
    Reproduced on 87cdba6 with MSVC 19.51 / ACP 936:
      include/openscarlett/gdk/xgameruntime_abi.h(755)
      src/shims/xgameruntime_shim.cpp(12422)
  * hard errors when such a byte lands inside a string literal, e.g. C2001
    "newline in string constant" for a wide literal containing an em dash --
    hit locally on src/launcher/launcher_main.cpp:1591 before afcd167
    rewrote those literals.

Add /utf-8 (source + execution charset) under if(MSVC) so the build is
host-locale independent. No narrow string literal carries non-ASCII text, so
the execution-charset half changes no runtime behaviour, and MinGW/clang
lanes are untouched.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:11:26 +00:00
github manually merged commit eb6234d3be into gh-pr/50/base 2026-11-26 19:11:28 +00:00
Author
Owner

@⁠californiaAlmonds on GitHub · 2026-11-26 07:52 UTC · original

Verified cleanly in an isolated worktree on MSVC 19.44 (83/83 core/launcher/test targets built with 0 warnings under /W4 /utf-8, 3/3 CTests passing). Thank you @⁠leonredfish for the clean fix! Merging now.

**@⁠californiaAlmonds** on GitHub · 2026-11-26 07:52 UTC · [original](https://github.com/californiaAlmonds/OpenScarlett/pull/50#issuecomment-7185926992) Verified cleanly in an isolated worktree on MSVC 19.44 (83/83 core/launcher/test targets built with 0 warnings under /W4 /utf-8, 3/3 CTests passing). Thank you @⁠leonredfish for the clean fix! Merging now.
This discussion has been locked. Commenting is limited to contributors.
No description provided.