spectre.console icon indicating copy to clipboard operation
spectre.console copied to clipboard

Unable to redirect output to file

Open 84961 opened this issue 1 year ago • 2 comments

Information

  • OS: [eg Windows/Linux/MacOS]
  • Version: [e.g. 0.33.0]
  • Terminal: [e.g Windows Terminal]

Describe the bug Trying to run the console app and redirect the output to file consoleapp.exe > dump.ansi

To Reproduce Steps to reproduce the behavior.

Expected behavior should be able to view the file in powershell using type dump.ansi -Encoding oem

Screenshots The file is showing as image

Additional context Add any other context about the problem here.


Please upvote :+1: this issue if you are interested in it.

84961 avatar May 08 '24 12:05 84961

Looks like your terminal doesn't support ansi escape codes or the encoding you've selected messes something up. I'm afraid this is outside the scope of the project.

patriksvensson avatar May 08 '24 13:05 patriksvensson

I think I have run into the same issue.

I can reproduce encoding errors on Windows in both the old terminal (ConHost) and Windows Terminal when the shell is Windows Powershell (powershell.exe), on newer versions of Powershell (pwsh.exe) everything seems to be working fine.

I think this is related to the encoding used by Powershell.

A workaround is, setting the console encoding before running the tool that uses Spectre.Console:

[Console]::InputEncoding = [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding

ap0llo avatar May 05 '25 13:05 ap0llo