Page 1 of 1
ANSI color codes
Posted: Wed Feb 13, 2008 6:15 pm
by Chris Corbyn
Does anyone know if the windows cmd.exe can display ANSI color escape sequences using the same code as under UNIX-like systems?
Could someone with a windows machine give this a little test for me?
Run on command line:
Code: Select all
<?php
echo "First : \033[31m Fail \033[0m" . PHP_EOL;
echo "Second : \033[32m OK \033[0m" . PHP_EOL;
echo "Third : \033[31m\033[1m Exception \033[0m" . PHP_EOL;
echo "Fourth : \033[34m\033[1m Skip \033[0m" . PHP_EOL;
Re: ANSI color codes
Posted: Wed Feb 13, 2008 6:45 pm
by Christopher
Windows wrote:First : ←[31m Fail ←[0m
Second : ←[32m OK ←[0m
Third : ←[31m←[1m Exception ←[0m
Fourth : ←[34m←[1m Skip ←[0m
Re: ANSI color codes
Posted: Wed Feb 13, 2008 7:04 pm
by Chris Corbyn
*sigh*
Thanks man

Re: ANSI color codes
Posted: Fri Feb 15, 2008 3:01 pm
by xpt
Chris Corbyn wrote:Does anyone know if the windows cmd.exe can display ANSI color escape sequences using the same code as under UNIX-like systems?
Back to the old DOS days, one can display ANSI color escape sequences, and cursor reallocation too, provided that the
is included in the config.sys
Haven't been playing with DOS/Windows for nearly 10 years, and I don't know what's the status now...
Re: ANSI color codes
Posted: Mon Feb 18, 2008 6:21 pm
by Chris Corbyn
Ah, I was just coming back here to ask about ansi.sys. Thanks for the reply

It seems that windows does require this device driver to be loaded before it will display ansi color (wtf???). My windows knowledge is completely zilch when it comes to this type of thing, but does anyone know some kind of COM check I can run to determine if I can display ansi colors? I can get by with just displaying plain black/white if it's not loaded, but since it displays those silly backspace chars without it I'll need to do a check.
If push comes to shove I'll just check if PHP_OS looks like windows and disable color if so.
It's not for anything important... just the CLI interface to a test runner:
Re: ANSI color codes
Posted: Wed Feb 20, 2008 8:15 pm
by Ambush Commander
In theory, it should be possible to use COM to get the effect we want. Researching right now...
Re: ANSI color codes
Posted: Wed Feb 20, 2008 9:31 pm
by Ambush Commander
Gave up, but here's what I found:
1. COM is one possibility, but I couldn't figure out how to directly interface with the COM to manipulate the Console
2. Next, I turned to scripting with COM, but Console didn't seem to be defined in Jscript
3. Finally, I tried instantiating the System.Console dot-net class, but PHP fatally errored on me.
Whee...
Re: ANSI color codes
Posted: Thu Feb 21, 2008 5:39 am
by Chris Corbyn
Hey thanks for trying man! I guess windows users will just have to live with black and white.