Piping ANSI control sequences through 'type'

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
May 5, 2017

I have a cross-platform console application which emits ANSI control sequences to stdout. This works great in Linux with its native support for ANSI. However, I am trying to find a suitable workaround for Windows/TCC21 that will allow me to redirect its output through the X3.64 interpreter. TYPE seems to be my best option per the following text from the help:

TCC interprets only its own output, not the output of external commands. In some cases you can redirect the output of an application program to a temporary file, then send it through TCC ANSI X3.64 interpreter, e.g., by using the TYPE command. This will display ANSI X3.64 correctly, but will not work with an interactive application.

Indeed, myapp.exe | type "kind of" works. However, the application's output is seemingly not piped through type until after myapp.exe exits (almost like an in-process pipe). I have also tried myapp.exe | for %x in (@CON:) echo %x which behaves similarly (no output until the application exits). I've also tried piping the output through TAIL to no avail.

Is there any way to redirect the output of my application through TCC's ANSI X3.64 interpreter and observe the output as it is generated by the app? I've seen references in this forum to people injecting TCC's ANSI32.dll into processes but this seems both brutish and unsavory.


May 30, 2008
I use the "Y" command, without specifying a file name. This allows me to get ANSI output from external programs.

(You do get an extra line at the end)

Not sure if it has the TYPE and FOR issues you mentioned though, those did not work at all for me, i.e. failed to produce any output.
May 5, 2017
Fantastic! This worked swimmingly. I did not know you could use 'Y' without a filename (I had looked at it along with TEE but passed over it because of the file requirement).

Thanks, Niklas!

Edit: I did have to use setvbuf to force stdout/stderror to unbuffered I/O to make this work (for anyone who may follow this thread in the future).
Last edited: