Skip to content

Fix: UTF-8 console output on Windows (affects --table box-drawing) #201

Description

@vmvarela

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

  • On Windows, --table box-drawing characters render correctly in default cmd.exe
  • On Windows Terminal / modern conhost, no visible change (already works)
  • No change in behavior on macOS/Linux
  • No additional dependencies — uses zig std or kernel32 externs only

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highMust be in the next sprintsize:sSmall — 1 to 4 hoursstatus:readyRefined and ready for sprint selectiontype:bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions