0

I cannot find solution and explanation of this problem. I have this simple program for NodeJS:

var colored = ' \u001b[1;41mFAILED\u001b[0m';
console.log(colored);

And on Win8 it prints colored output into the CMD. But... If I write very similar program in PHP:

$color = "[1;41mFAILED\x1b[0m";
print chr(27) . $color;

It doesn't work. The output is ←[1;41mFAILED←[0m. But why? Why it works only with NodeJS? Where is the difference? And how can I print colored output in PHP? It's obvious that it's possible if NodeJS can do this without additional programs needed. Thanks...

mrtnzlml
  • 109
  • 1
  • 8
  • Do you really think, that there is explanation of my NodeJS question or solution of this problem **without** any additional program? – mrtnzlml Jun 13 '14 at 08:55
  • nodejs make terminal support ansi. php not do it. cmd.exe not support ansi. – askovpen Jun 13 '14 at 09:00
  • Ok, but I am using the same CMD for running NodeJS and PHP. So back to the question. How does it do NodeJS internally? I want to do the same in PHP if possible (without DLLs as suggested before). The goal is to make this possible for every user without additional installation of something... – mrtnzlml Jun 13 '14 at 09:07
  • nodejs support native windows cmd colors and translate ansi to it. php don't support it. – askovpen Jun 13 '14 at 09:13
  • http://stackoverflow.com/a/16799175/1347147 – askovpen Jun 13 '14 at 09:15
  • Are you kidding me? How this can be duplicate question? Hope the last edit clarify what's the main question... – mrtnzlml Jun 13 '14 at 12:01
  • For NodeJS you can check this: http://stackoverflow.com/a/25107254/1710825 – user1710825 Aug 04 '14 at 00:32

0 Answers0