Skip to content

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

Closed
flet-dev/serious-python
#234

Description

@KangZhaoKui

Duplicate Check

Describe the bug

After upgrading Flet to version 0.86, running flet build windows -vv fails.

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

Code sample

Code

Use a simple counter.py

import flet as ft

def main(page: ft.Page):
    page.title = "Flet counter example"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    input = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(e):
        input.value = str(int(input.value) - 1)

    def plus_click(e):
        input.value = str(int(input.value) + 1)

    page.add(
        ft.Row(
            alignment=ft.MainAxisAlignment.CENTER,
            controls=[
                ft.IconButton(ft.Icons.REMOVE, on_click=minus_click),
                input,
                ft.IconButton(ft.Icons.ADD, on_click=plus_click),
            ],
        )
    )

ft.run(main)

To reproduce

  1. Upgrade flet to 0.86
  2. Run flet build windows -vv

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11 Chinese Simplified

Flet version

0.86

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

  1. I’m in mainland China, Powershell input: [System.Text.Encoding]::Default.CodePage, output:936, represents GBK;
  2. On Simplified Chinese Windows, default system code page is 936 (GBK). MSVC cannot parse UTF-8 source without BOM under GBK codepage → triggers C4819.
  3. Because /WX is active, this encoding warning is escalated to a fatal build error C2220.

Logs

Logs
[        ]   C:\Program Files\Microsoft Visual
           Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\HostX64\x64\CL.exe /c
           /I"D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral"
           /I"D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\cpp_client_wrapper\incl
           ude" /nologo /W4 /WX /diagnostics:column /O2 /Ob2 /D _WINDLL /D _UNICODE /D UNICODE /D WIN32 /D  
           _WINDOWS /D NDEBUG /D _HAS_EXCEPTIONS=0 /D _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS  
           /D FLUTTER_PLUGIN_IMPL /D UNICODE /D _UNICODE /D "CMAKE_INTDIR=\"Release\"" /D
           url_launcher_windows_plugin_EXPORTS /EHsc /MD /GR /std:c++17
           /Fo"url_launcher_windows_plugin.dir\Release\\"
           /Fd"url_launcher_windows_plugin.dir\Release\vc145.pdb" /external:W4 /TP /wd4100
           /errorReport:queue
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\url_laun
           cher_windows\windows\url_launcher_windows.cpp"
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\url_laun
           cher_windows\windows\messages.g.cpp"
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\url_laun
           cher_windows\windows\system_apis.cpp"
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\url_laun
           cher_windows\windows\url_launcher_plugin.cpp"
[16:41:36] [  +60 ms]   url_launcher_windows.cpp
[16:41:37] [+1778 ms]   messages.g.cpp
[16:41:39] [+1292 ms]   system_apis.cpp
           [ +540 ms]   url_launcher_plugin.cpp
[16:41:41] [+1771 ms]   正在生成代码...
[16:41:42] [+1442 ms] Link:
           [        ]   C:\Program Files\Microsoft Visual
           Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\HostX64\x64\link.exe
           /OUT:"D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\url_launcher_windows
           \Release\url_launcher_windows_plugin.dll" /INCREMENTAL:NO /NOLOGO
           ..\..\flutter\Release\flutter_wrapper_plugin.lib shlwapi.lib
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\flutter_windows.dll.lib" 
           kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib       
           comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
           /manifest:embed
           /PDB:"D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/url_launcher_windows
           /Release/url_launcher_windows_plugin.pdb" /SUBSYSTEM:CONSOLE /TLBID:1
           /IMPLIB:"D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/url_launcher_wind
           ows/Release/url_launcher_windows_plugin.lib" /MACHINE:X64  /machine:x64 /DLL
           url_launcher_windows_plugin.dir\Release\url_launcher_windows.obj
           [        ]   url_launcher_windows_plugin.dir\Release\messages.g.obj
           [        ]   url_launcher_windows_plugin.dir\Release\system_apis.obj
           [        ]   url_launcher_windows_plugin.dir\Release\url_launcher_plugin.obj
           [  +79 ms]     正在创建库
           D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/url_launcher_windows/Relea
           se/url_launcher_windows_plugin.lib 和对象
           D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/url_launcher_windows/Relea
           se/url_launcher_windows_plugin.exp
[16:41:43] [  +99 ms]   url_launcher_windows_plugin.vcxproj ->
           D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\url_launcher_windows\Relea
           se\url_launcher_windows_plugin.dll
           [   +9 ms] FinalizeBuildStatus:
           [        ]
           正在删除文件“url_launcher_windows_plugin.dir\Release\url_laun.B79FF416.tlog\unsuccessfulbuild”。 
           [        ]
           正在对“url_launcher_windows_plugin.dir\Release\url_laun.B79FF416.tlog\url_launcher_windows_plugin
           .lastbuildstate”执行 Touch 任务。
           [        ]
           已完成生成项目“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\url_launche
           r_windows\url_launcher_windows_plugin.vcxproj”(默认目标)的操作。
           [  +33 ms]
           项目“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\runner\flet_counter.vcxproj”(
           9)正在节点 1
           上生成“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\window_manager\wind
           ow_manager_plugin.vcxproj”(17) (默认目标)。
           [        ] PrepareForBuild:
           [        ]   已启用结构化输出。编译器诊断的格式设置将反映错误层次结构。有关详细信息,请参阅      
           https://aka.ms/cpp/structured-output。
           [        ]
           正在创建目录“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\window_manage
           r\Release\”。
           [        ]   正在创建目录“window_manager_plugin.dir\Release\window_m.4493C673.tlog\”。
           [   +2 ms] InitializeBuildStatus:
           [        ]
           正在创建“window_manager_plugin.dir\Release\window_m.4493C673.tlog\unsuccessfulbuild”,因为已指定“
           AlwaysCreate”。
           [        ]
           正在对“window_manager_plugin.dir\Release\window_m.4493C673.tlog\unsuccessfulbuild”执行 Touch     
           任务。
           [  +65 ms] CustomBuild:
           [        ]   Building Custom Rule
           D:/PythonProjects/flet-counter/build/flutter/windows/flutter/ephemeral/.plugin_symlinks/window_ma
           nager/windows/CMakeLists.txt
           [  +65 ms] ClCompile:
           [        ]   C:\Program Files\Microsoft Visual
           Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\HostX64\x64\CL.exe /c
           /I"D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral"
           /I"D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\cpp_client_wrapper\incl
           ude" /nologo /W4 /WX /diagnostics:column /O2 /Ob2 /D _WINDLL /D _UNICODE /D UNICODE /D WIN32 /D  
           _WINDOWS /D NDEBUG /D _HAS_EXCEPTIONS=0 /D _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS  
           /D FLUTTER_PLUGIN_IMPL /D _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING /D UNICODE /D        
           _UNICODE /D "CMAKE_INTDIR=\"Release\"" /D window_manager_plugin_EXPORTS /EHsc /MD /GR /std:c++17 
           /Fo"window_manager_plugin.dir\Release\\" /Fd"window_manager_plugin.dir\Release\vc145.pdb"        
           /external:W4 /TP /wd4100 /errorReport:queue
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\window_m
           anager\windows\window_manager.cpp"
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\window_m
           anager\windows\window_manager_plugin.cpp"
           [  +61 ms]   window_manager.cpp
[16:41:45] [+2124 ms]   window_manager_plugin.cpp
[16:41:47] [+2393 ms]   正在生成代码...
[16:41:49] [+1418 ms] Link:
           [        ]   C:\Program Files\Microsoft Visual
           Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\HostX64\x64\link.exe
           /OUT:"D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\window_manager\Relea
           se\window_manager_plugin.dll" /INCREMENTAL:NO /NOLOGO
           ..\..\flutter\Release\flutter_wrapper_plugin.lib
           "D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\flutter_windows.dll.lib" 
           kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib       
           comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
           /manifest:embed
           /PDB:"D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/window_manager/Relea
           se/window_manager_plugin.pdb" /SUBSYSTEM:CONSOLE /TLBID:1
           /IMPLIB:"D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/window_manager/Re
           lease/window_manager_plugin.lib" /MACHINE:X64  /machine:x64 /DLL
           window_manager_plugin.dir\Release\window_manager.obj
           [        ]   window_manager_plugin.dir\Release\window_manager_plugin.obj
           [  +84 ms]     正在创建库
           D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/window_manager/Release/win
           dow_manager_plugin.lib 和对象
           D:/PythonProjects/flet-counter/build/flutter/build/windows/x64/plugins/window_manager/Release/win
           dow_manager_plugin.exp
           [  +99 ms]   window_manager_plugin.vcxproj ->
           D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\window_manager\Release\win
           dow_manager_plugin.dll
           [   +8 ms] FinalizeBuildStatus:
           [        ]
           正在删除文件“window_manager_plugin.dir\Release\window_m.4493C673.tlog\unsuccessfulbuild”。       
           [        ]
           正在对“window_manager_plugin.dir\Release\window_m.4493C673.tlog\window_manager_plugin.lastbuildst
           ate”执行 Touch 任务。
           [        ]
           已完成生成项目“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\window_mana
           ger\window_manager_plugin.vcxproj”(默认目标)的操作。
           [   +1 ms]
           已完成生成项目“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\runner\flet_counter
           .vcxproj”(默认目标)的操作 - 失败。
           [   +1 ms]
           已完成生成项目“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\ALL_BUILD.vcxproj”(
           默认目标)的操作 - 失败。
           [        ]
           已完成生成项目“D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\INSTALL.vcxproj”(默
           认目标)的操作 - 失败。
           [  +12 ms] 生成失败。
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\INSTALL.vcxproj”(默认目标) (1) ->
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\ALL_BUILD.vcxproj”(默认目标) (3) 
           ->
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\runner\flet_counter.vcxproj”(默认
           目标) (9) ->
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\serious_python_windows\se
           rious_python_windows_plugin.vcxproj”(默认目标) (14) ->
           [        ] (ClCompile 目标) ->
           [        ]
           D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\serious_p
           ython_windows\windows\serious_python_windows_plugin.cpp(1,1): warning C4819:
           该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
           [D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\serious_python_windows\se
           rious_python_windows_plugin.vcxproj]
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\INSTALL.vcxproj”(默认目标) (1) ->
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\ALL_BUILD.vcxproj”(默认目标) (3) 
           ->
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\runner\flet_counter.vcxproj”(默认
           目标) (9) ->
           [        ]
           “D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\serious_python_windows\se
           rious_python_windows_plugin.vcxproj”(默认目标) (14) ->
           [        ] (ClCompile 目标) ->
           [        ]
           D:\PythonProjects\flet-counter\build\flutter\windows\flutter\ephemeral\.plugin_symlinks\serious_p
           ython_windows\windows\serious_python_windows_plugin.cpp(1,1): error C2220: 以下警告被视为错误    
           [D:\PythonProjects\flet-counter\build\flutter\build\windows\x64\plugins\serious_python_windows\se
           rious_python_windows_plugin.vcxproj]
           [        ]     1 个警告
           [        ]     1 个错误
           [        ] 已用时间 00:02:18.57
           [  +29 ms] Building Windows application... (completed in 144.2s)
           [        ] "flutter windows" took 148,533ms.
           [  +67 ms] Build process failed.
           [        ]
                      #0      throwToolExit (package:flutter_tools/src/base/common.dart:34:3)
                      #1      _runBuild (package:flutter_tools/src/windows/build_windows.dart:262:5)        
                      <asynchronous suspension>
                      #2      buildWindows (package:flutter_tools/src/windows/build_windows.dart:118:5)     
                      <asynchronous suspension>
                      #3      BuildWindowsCommand.runCommand
           (package:flutter_tools/src/commands/build_windows.dart:72:5)
                      <asynchronous suspension>
                      #4      FlutterCommand.run.<anonymous closure>
           (package:flutter_tools/src/runner/flutter_command.dart:1630:27)
                      <asynchronous suspension>
                      #5      AppContext.run.<anonymous closure>
           (package:flutter_tools/src/base/context.dart:154:19)
                      <asynchronous suspension>
                      #6      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
                      <asynchronous suspension>
                      #7      FlutterCommandRunner.runCommand.<anonymous closure>
           (package:flutter_tools/src/runner/flutter_command_runner.dart:496:9)
                      <asynchronous suspension>
                      #8      AppContext.run.<anonymous closure>
           (package:flutter_tools/src/base/context.dart:154:19)
                      <asynchronous suspension>
                      #9      FlutterCommandRunner.runCommand
           (package:flutter_tools/src/runner/flutter_command_runner.dart:431:5)
                      <asynchronous suspension>
                      #10     FlutterCommandRunner.run.<anonymous closure>
           (package:flutter_tools/src/runner/flutter_command_runner.dart:307:33)
                      <asynchronous suspension>
                      #11     run.<anonymous closure>.<anonymous closure>
           (package:flutter_tools/runner.dart:104:11)
                      <asynchronous suspension>
                      #12     AppContext.run.<anonymous closure>
           (package:flutter_tools/src/base/context.dart:154:19)
                      <asynchronous suspension>
                      #13     main (package:flutter_tools/executable.dart:103:3)
                      <asynchronous suspension>


           [        ] Running 1 shutdown hook
           [  +11 ms] Shutdown hooks complete
           [  +23 ms] exiting with code 1

Additional details

No response

Activity

  1. FeodorFitsner commented on Jul 15, 2026

    @FeodorFitsner
    Contributor

    Working on a fix.

  2. moved this from 🆕 New to 👀 In review in Flet Developmenton Jul 15, 2026
  3. Muddassir-Farooq-official commented on Jul 15, 2026

    @Muddassir-Farooq-official

    Working on a fix.

    There is also an issue with --port and -d and -r arguments when run with flet run main.py --web

  4. added a commit that references this issue on Jul 16, 2026
    55e0ca6
  5. KangZhaoKui commented on Jul 16, 2026

    @KangZhaoKui
    Author

    Thank you @FeodorFitsner ! I've tested it, and serious_python_windows_plugin.cpp is fixed, but I found another file with the same issue:

    Image Image

    connectivity_plus_plugin.cpp,After making these changes, it won't fail again! Thank you again for your efforts.

  6. MRDXHMAGIC commented on Jul 16, 2026

    @MRDXHMAGIC

    Open "Beta 版:使用 Unicode UTF-8 提供全球语言支持" can fix MSVC C4819 error.

    屏幕截图 2026-07-17 024213.png

  7. added a commit that references this issue on Jul 16, 2026
    7619abc
  8. FeodorFitsner commented on Jul 16, 2026

    @FeodorFitsner
    Contributor

    The fix is coming guys: #6687

  9. added a commit that references this issue on Jul 16, 2026
    e1eb3fd
  10. FeodorFitsner commented on Jul 17, 2026

    @FeodorFitsner
    Contributor

    It's been fixed in 0.86.1.

  11. moved this from 👀 In review to ✅ Done in Flet Developmenton Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions