From 89782798fc200bc9f32a033026d78ddce57668d2 Mon Sep 17 00:00:00 2001 From: Varun Nuthalapati Date: Sun, 31 May 2026 20:14:06 -0700 Subject: [PATCH] fix(windows): force UTF-8 console codepage to prevent non-ASCII mojibake --- .changeset/fix-windows-utf8-console.md | 5 +++++ crates/google-workspace-cli/src/main.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .changeset/fix-windows-utf8-console.md diff --git a/.changeset/fix-windows-utf8-console.md b/.changeset/fix-windows-utf8-console.md new file mode 100644 index 00000000..6017281c --- /dev/null +++ b/.changeset/fix-windows-utf8-console.md @@ -0,0 +1,5 @@ +--- +"@googleworkspace/cli": patch +--- + +Force UTF-8 console output on Windows to prevent CP-1252 mojibake of non-ASCII characters diff --git a/crates/google-workspace-cli/src/main.rs b/crates/google-workspace-cli/src/main.rs index 41dcc1e1..d381e206 100644 --- a/crates/google-workspace-cli/src/main.rs +++ b/crates/google-workspace-cli/src/main.rs @@ -50,6 +50,17 @@ async fn main() { // Load .env file if present (silently ignored if missing) let _ = dotenvy::dotenv(); + // Windows: force UTF-8 console output to prevent CP-1252 mojibake of non-ASCII characters + #[cfg(target_os = "windows")] + { + extern "system" { + fn SetConsoleOutputCP(wCodePageID: u32) -> i32; + } + unsafe { + SetConsoleOutputCP(65001); + } + } + // Initialize structured logging (no-op if env vars are unset) logging::init_logging();