Skip to content

Fix Windows build failure on non-UTF-8 locales (C4819/C2220)#234

Open
FeodorFitsner wants to merge 1 commit into
mainfrom
fix/windows-c4819-utf8-source
Open

Fix Windows build failure on non-UTF-8 locales (C4819/C2220)#234
FeodorFitsner wants to merge 1 commit into
mainfrom
fix/windows-c4819-utf8-source

Conversation

@FeodorFitsner

Copy link
Copy Markdown
Contributor

Problem

flet build windows fails on Simplified-Chinese Windows (and any non-UTF-8 system locale) while compiling the serious_python Windows plugin:

serious_python_windows_plugin.cpp(1,1): warning C4819: The file contains a character
  that cannot be represented in the current code page (936). Save the file in Unicode
  format to prevent data loss
serious_python_windows_plugin.cpp(1,1): error C2220: the following warning is treated as an error

Reported in flet-dev/flet#6686.

Root cause

serious_python_windows_plugin.cpp line 39 contained a non-ASCII character — an em dash (, U+2014) — in a comment, and the file has no BOM. On a system whose active code page isn't UTF-8 (Simplified-Chinese Windows defaults to 936/GBK), MSVC decodes the UTF-8 source bytes as GBK, can't represent the sequence, and emits C4819. The Flutter plugin template compiles with /WX (warnings-as-errors), which escalates it to a fatal C2220 — so the whole build fails.

This is a regression in Flet 0.86: the comment was introduced with serious_python 3.0.0 (commit eb2ee4b), the version bundled with 0.86.

Fix

  • Remove the em dash from the comment in serious_python_windows_plugin.cpp (the direct cause).
  • Belt-and-suspenders: compile the Windows plugin with /utf-8 so MSVC always reads sources as UTF-8 regardless of the build machine's code page — any future non-ASCII source byte is handled correctly.
  • Remove the same stray character from serious_python_linux_plugin.cc for consistency (GCC reads UTF-8 by default, so there was no build impact on Linux).

Release

Bumps all packages 4.3.2 → 4.3.3 (lockstep) with CHANGELOG entries. No runtime changes — bundled Python (3.12.13 / 3.13.14 / 3.14.6) and dart_bridge (1.5.0) are unchanged from 4.3.2.

Fixes flet-dev/flet#6686

serious_python_windows_plugin.cpp contained a non-ASCII character (an em
dash) in a comment. On a system whose code page isn't UTF-8 (e.g. 936/GBK
on Simplified-Chinese Windows) MSVC decodes the UTF-8 source as GBK, can't
represent the bytes and emits warning C4819, which the Flutter template's
/WX escalates to a fatal C2220 -> `flet build windows` fails.

Remove the character and compile the Windows plugin with /utf-8 so any
future non-ASCII source byte is read correctly regardless of the build
machine's code page. Also drop the same stray character from the Linux
plugin source (GCC tolerated it, no build impact).

Bump all packages 4.3.2 -> 4.3.3 with changelog entries.

Fixes flet-dev/flet#6686
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.

bug: Windows build fails with C4819+C2220 error when using serious_python after upgrading Flet to 0.86

1 participant