Closed tomasz1986 closed 2 years ago
Use --no-color
or set ENABLE_ESCAPE_CODES=0
to disable use of ANSI escape codes if they're not supported by your environment. However, I'd generally like to keep them enabled - e.g. they work just fine under Windows when using Mintty/MSYS2. When I remember correctly, it even worked in some new terminal emulator provided by Microsoft.
I consider it a feature request to disable the use of ANSI escape codes by default in environments which are known to not support it.
Note that syncthingctl
will also unconditionally print output as UTF-8 so you also need to set your consoles' code page to UTF-8 when using cmd.exe
to avoid broken non-ASCII characters.
This happens with the console set to UTF-8 though. I've just found that the solution to get rid of the characters is to run it with the --no-color
flag.
Yes, see my first comment which also mentions an env var. The hint about UTF-8 is just in addition because it might be the next problem you might run into.
Just out of curiosity, are these escape codes only used to colorise the command line output? If yes, then is this the only way to achieve it? I'm asking, because both CMD and PowerShell console themselves are capable of displaying 16 colours, i.e.
and I've seen multiple colours used in other CLI programs, e.g. Git or aria2, so it's not like the command line in Windows itself is limited to two colours only.
If yes, then is this the only way to achieve it?
No, one can use certain WinAPI functions under Windows. However, I'm not going to spend any effort on using them when I can just use a decent terminal. No reason to go the extra mile to cover Microsoft's non-standard ways of doing things.
I can just use a decent terminal.
Yeah, but please keep in mind that there are many situations, where you can't do that (e.g. when using the software on another person's computer for troubleshooting, or in a restricted office environment, or when you use other software that relies on CMD being the default console, etc.). Another problem is that this is broken in PowerShell as well, and there is no alternative to PowerShell as such.
Note that I'd generally accept a (well written) PR to improve this. It is just that I'm not going to spend the effort myself as I don't see the use case myself.
My C-related skills are too minimal to be able to do anything really, so at this point my only request would be limited to at least not display the question marks and such by default there, as they make the output almost unreadable.
To tell the truth, I'm also not really a fan of replacing CMD with 3rd party terminals myself, as in my experience they don't really handle multi-language input well, especially when you need to input Asian scripts (e.g. Chinese characters).
Looks like there's a registry hack to enable ANSI escape codes under Windows 10: https://stackoverflow.com/questions/16755142/how-to-make-win32-console-recognize-ansi-vt100-escape-sequences
And even better, it would be quite easy to enable ANSI escape codes from the application side: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#example-of-select-anniversary-update-features=
So I'll give it a try.
This should be fixed by a90e79b78f69d8f2fdf87683b8c645b7271ce4e3.
Relevant components
syncthingctl
)libsyncthing
)Environment and versions
syncthingtray
,qtutilities
andc++utilities
: syncthingctl v1.1.17Bug description
Result of running
syncthingctl --help
:Steps to reproduce
syncthingctl --help
from the default CMD console in Windows.Expected behavior
The command line output should not contain characters that cannot be printed using the CMD console.
Screenshots
Additional context