Context
sql-pipe builds for Windows (x86_64-windows-gnu, aarch64-windows-gnu, x86-windows-gnu) but does not configure the console for UTF-8 output. The default legacy Windows console (conhost, cmd.exe) uses a non-UTF-8 codepage (e.g., CP437 or CP1252). This means the --table output mode with box-drawing Unicode characters (─│┌┐└┘├┤┬┴┼) is garbled on default Windows setups.
Sparkline (future feature) and any Unicode output would share the same problem.
Windows Terminal and recent Windows 10/11 builds with UTF-8 codepage enabled handle this fine, but a fresh install of Windows does not.
Proposed fix
Call SetConsoleOutputCP(65001) (CP_UTF8) and SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING on startup when running on Windows. This is a no-op on non-Windows platforms.
Zig provides std.os.windows.SetConsoleOutputCP and std.os.windows.SetConsoleMode via the windows standard library module. Alternatively, use kernel32 externals.
Scope
src/main.zig — call setupConsoleOutput() on startup, conditional on Windows target using @import("builtin").os.tag
- New function
setupConsoleOutput(): SetConsoleOutputCP(65001), SetConsoleMode with VIRTUAL_TERMINAL_PROCESSING
- No-op on macOS/Linux (compile-time conditional)
Excluded (YAGNI)
- Input codepage handling (stdin encoding is separate)
- CMD script startup wrapper (should be in the binary)
- Registering global codepage changes (just set for this process)
Acceptance criteria
Context
sql-pipe builds for Windows (
x86_64-windows-gnu,aarch64-windows-gnu,x86-windows-gnu) but does not configure the console for UTF-8 output. The default legacy Windows console (conhost, cmd.exe) uses a non-UTF-8 codepage (e.g., CP437 or CP1252). This means the--tableoutput mode with box-drawing Unicode characters (─│┌┐└┘├┤┬┴┼) is garbled on default Windows setups.Sparkline (future feature) and any Unicode output would share the same problem.
Windows Terminal and recent Windows 10/11 builds with UTF-8 codepage enabled handle this fine, but a fresh install of Windows does not.
Proposed fix
Call
SetConsoleOutputCP(65001)(CP_UTF8) andSetConsoleModewithENABLE_VIRTUAL_TERMINAL_PROCESSINGon startup when running on Windows. This is a no-op on non-Windows platforms.Zig provides
std.os.windows.SetConsoleOutputCPandstd.os.windows.SetConsoleModevia thewindowsstandard library module. Alternatively, usekernel32externals.Scope
src/main.zig— callsetupConsoleOutput()on startup, conditional on Windows target using@import("builtin").os.tagsetupConsoleOutput(): SetConsoleOutputCP(65001), SetConsoleMode with VIRTUAL_TERMINAL_PROCESSINGExcluded (YAGNI)
Acceptance criteria
--tablebox-drawing characters render correctly in default cmd.exe