Req #72768 [Com]: Add ENABLE_VIRTUAL_TERMINAL_PROCESSING flag for php.exe

From: Date: Wed, 10 Aug 2016 14:06:53 +0000
Subject: Req #72768 [Com]: Add ENABLE_VIRTUAL_TERMINAL_PROCESSING flag for php.exe
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203165@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72768&edit=1 ID: 72768 Comment by: mlocati at gmail dot com Reported by: mlocati at gmail dot com Summary: Add ENABLE_VIRTUAL_TERMINAL_PROCESSING flag for php.exe Status: Assigned Type: Feature/Change Request Package: Output Control Operating System: Windows 10 PHP Version: Irrelevant Assigned To: ab Block user comment: N Private report: N New Comment: In the Windows console it's represented by a left arrow as represented here: http://imgur.com/a/heYHm (at least with my codepage) By the way, pasting that string in the browser caused that char to be suppressed, that's why I wrote "?" Previous Comments: ------------------------------------------------------------------------ [2016-08-10 13:50:08] cmb@php.net > (where ? is \033) The ESC character is likely being suppressed by Windows. ------------------------------------------------------------------------ [2016-08-10 13:38:50] mlocati at gmail dot com Whoops, the link I mentioned is where I added my test code, the instructions I followed to compile php.exe are at https://wiki.php.net/internals/windows/stepbystepbuild ------------------------------------------------------------------------ [2016-08-10 13:35:58] mlocati at gmail dot com I just recompiled php.exe using the instructions described at http://git.php.net/?p=php-src.git;a=blob;f=sapi/cli/php_cli.c;h=dc92045ae7402ad16566a9024453820a26c69da8;hb=HEAD#l1174 (using the version tagged php-7.0.9) With the current code, the output of Release_TS\php.exe -r "echo ""\033[101;93m TEST \033[0m\n"";" is ?[101;93m TEST ?[0m (where ? is \033) Adding the SetConsoleMode-related stuff described in this #72768, I get TEST (with red background and yellow foreground) So, I can confirm that the approach described here is valid. Just one note: I called SetConsoleMode only for STD_OUTPUT_HANDLE, but STDERR seems to follow STDOUT: Release_TS\php.exe -r "fwrite(STDERR, ""\033[101;93m TEST \033[0m\n"");" gives the same colorized output as writing to STDOUT. ------------------------------------------------------------------------ [2016-08-10 11:34:55] jhdxr@php.net It's a good news that Windows finally supports this feature. If we add this flag to cli, I think we'd better add a constant indicating if this feature is enabled or not so userland can have their own choice. ------------------------------------------------------------------------ [2016-08-08 06:29:28] mlocati at gmail dot com Please note that the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag does not affect the output of php.exe, but just the way the console interprets it. For instance, if we assume that the sample c program mentioned in this #72768 is compiled as "test.exe", the contents of the file "test.txt" created with "test.exe >test.txt 2>&1" is <ESC>[101;93m Yellow text on red background <ESC>[0m <ESC>[101;93m Yellow text on red background <ESC>[0m (where <ESC> is the character with ascii code \033 (octal)) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=72768 -- Edit this bug report at https://bugs.php.net/bug.php?id=72768&edit=1

« previous php.bugs (#203165) next »