locked
win10 console ANSI Escape Code support RRS feed

  • Question

  • Before win10 anniversary update, i have tested some code, and the console show colored text.

    After anniversary update, exec same script, it show only white text

    Sample Code:

    function ansi_test($esc, $text)
    {
        WScript.Echo($esc+'[31m'+$text);
    }
    
    ansi_test(String.fromCharCode(27), 'String.fromCharCode(27)');
    ansi_test('\x1B', '\\x1B');
    ansi_test('\u001B', '\\u001B');

    it only show white text

    D:\>c:\Windows\SysWOW64\cscript.exe test.js

    Microsoft (R) Windows Script Host Version 5.812
    Copyright (C) Microsoft Corporation. All rights reserved.

    String.fromCharCode(27)
    \x1B
    \u001B

    redirect output to file, use command : type <file> , it show colored text

    D:\>c:\Windows\SysWOW64\cscript.exe test.js > test.txt

    D:\>type test.txt

    Microsoft (R) Windows Script Host Version 5.812
    Copyright (C) Microsoft Corporation. All rights reserved.

    String.fromCharCode(27)
    \x1B
    \u001B

    what had happened after anniversary update?




    Saturday, September 24, 2016 6:59 AM