From 20691a70b00a65ab94f8eb659bee97b7b0b7d90a Mon Sep 17 00:00:00 2001 From: Matthew Breedlove Date: Sat, 21 Feb 2026 14:20:55 -0500 Subject: [PATCH] Set Windows UTF-8 code page for piped statusline (closes #186) --- src/ccstatusline.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ccstatusline.ts b/src/ccstatusline.ts index 0bc999d..6998ca3 100644 --- a/src/ccstatusline.ts +++ b/src/ccstatusline.ts @@ -54,6 +54,19 @@ async function readStdin(): Promise { } } +async function ensureWindowsUtf8CodePage() { + if (process.platform !== 'win32') { + return; + } + + try { + const { execFileSync } = await import('child_process'); + execFileSync('chcp.com', ['65001'], { stdio: 'ignore' }); + } catch { + // Ignore failures to preserve statusline output even in restricted shells. + } +} + async function renderMultipleLines(data: StatusJSON) { const settings = await loadSettings(); @@ -164,6 +177,8 @@ async function renderMultipleLines(data: StatusJSON) { async function main() { // Check if we're in a piped/non-TTY environment first if (!process.stdin.isTTY) { + await ensureWindowsUtf8CodePage(); + // We're receiving piped input const input = await readStdin(); if (input && input.trim() !== '') {