From 056ae914cefa41fce232a28be3e5c58c211197cb Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Fri, 5 Jun 2026 08:32:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(client):=20Windows=20main.cpp=20=E7=94=A8?= =?UTF-8?q?=20ASCII=20=E5=8D=81=E5=85=AD=E8=BF=9B=E5=88=B6=E8=BD=AC?= =?UTF-8?q?=E4=B9=89=E5=86=99=E6=A0=87=E9=A2=98=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20C4819?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v1.0.14 Windows 构建失败:main.cpp 含中文(u8 标题+中文注释),MSVC 在 GBK(936) 代码页报 C4819「字符无法表示」,而 runner 开了 /WX 警告即错误。 改为标题用 UTF-8 字节的 \x 十六进制转义、注释改英文,源码纯 ASCII, 运行时 MultiByteToWideChar(CP_UTF8) 解码,窗口标题仍是岩美酒库。 Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 2 +- client/windows/runner/main.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7585e4c..3f64252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.0.14] - 2026-06-05 +## [1.0.15] - 2026-06-05 ### 修复 - 修复 Windows 桌面端打印卡死:打印字体由 OpenType/CFF 改为 TrueType(glyf),dart_pdf 渲染中文不再抛错(此前点「打印」后卡死) diff --git a/client/windows/runner/main.cpp b/client/windows/runner/main.cpp index 6a9f59b..78ecdfe 100644 --- a/client/windows/runner/main.cpp +++ b/client/windows/runner/main.cpp @@ -29,8 +29,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - // 窗口标题:用 u8 字面量 + UTF-8→UTF-16 转换,避免源码编码导致中文乱码。 - const std::string title_utf8 = u8"岩美酒库"; + // Window title as UTF-8 bytes (hex-escaped to keep this source pure ASCII and + // avoid MSVC C4819 under GBK code page 936). Decoded to UTF-16 for Win32. + // Bytes below are the UTF-8 encoding of the Chinese app title. + const std::string title_utf8 = + "\xE5\xB2\xA9\xE7\xBE\x8E\xE9\x85\x92\xE5\xBA\x93"; int title_len = ::MultiByteToWideChar(CP_UTF8, 0, title_utf8.c_str(), -1, nullptr, 0); std::wstring window_title(title_len > 0 ? title_len - 1 : 0, L'\0');