Skip to content

read_file does not decode UTF-16 LE files created by Windows PowerShell 5.1 #610

Description

@lAiasu

Using powershell.exe (Windows PowerShell 5.1) as the shell, redirected output is written as UTF-16 LE:

@("alpha", "beta", "gamma") *> $env:TEMP\dc-utf16-test.txt

Reading that file with read_file returns text containing embedded NUL characters.

This causes tool-result persistence to fail with PostgreSQL error 22P05: \u0000 cannot be converted to text.

Reproduction

  1. Set defaultShell to powershell.exe.
  2. Run:
@("alpha", "beta", "gamma") *> $env:TEMP\dc-utf16-test.txt
  1. Call read_file on dc-utf16-test.txt.
  2. The returned text contains NUL characters between letters.

Expected

read_file should detect the UTF-16 BOM and decode the file as UTF-16 LE.

Additional result

The same command does not reproduce with pwsh.exe (PowerShell 7), which writes UTF-8 output by default.

Tested with Desktop Commander 0.2.44 on Windows 11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions