Skip to content

[Bug]: Windows PowerShell terminal mangles non-ASCII / UTF-8 stdout due to missing Console::OutputEncoding initialization #37369

Closed

Description

@HITECHDEM

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On Windows, in any thread with PowerShell terminal execution, run a command that outputs non-ASCII or UTF-8 characters (e.g. git log with non-ASCII commit messages, file contents containing Cyrillic, Umlauts, accents, or python -c "print('Привет мир')").
  2. Inspect the tool output returned to the agent and rendered in the T3 Code UI.

Expected behavior

Standard UTF-8 text is preserved and rendered accurately (e.g. Привет мир).

Actual behavior

Non-ASCII characters are mangled into replacement characters `` or legacy OEM/ANSI codepage mojibake (e.g. ???).
This occurs because when Node.js spawns `powershell.exe` on Windows with redirected stdout pipes, PowerShell defaults `$OutputEncoding` to ASCII/OEM (e.g. CP437, CP866, or Windows-1252), corrupting all multibyte UTF-8 characters before they reach the server buffer.

Impact

Major degradation or frequent failure

Version or commit

T3 Code 0.1.9 / core 0.169.0

Environment

Windows 11 x64, Desktop app, PowerShell 5.1 / PowerShell 7

Workaround & Suggested Fix

Whenever T3 Code spawns a PowerShell process or initializes an interactive terminal on Windows, configure UTF-8 output encoding by prepending:

$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8;
[Console]::InputEncoding = [System.Text.Encoding]::UTF8;
chcp 65001 > $null;

And ensure Node.js child_process spawn options specify { encoding: 'utf8', env: { ...process.env, PYTHONIOENCODING: 'utf-8', LC_ALL: 'en_US.UTF-8' } }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions