spectre.console
spectre.console copied to clipboard
Spinners not showing
Information
- OS: Windows
- Version: 10
- Terminal: Windows CMD, Powershell
Describe the bug When using the spinner sample on the cmd or powershell I only get a bar displayed instead the dots.
To Reproduce Run the Spinner sample on windows
Expected behavior The dot spinner animation
Additional context I switched Spinner.Known.Default to Spinner.Known.Dot to make sure that it is really used.
You will only get the dot spinner if the terminal is capable of showing Unicode characters and the output encoding is set to something like UTF-8.
Thank you for the fast reply. Do you know if the Console supports unicode on windows?
I added this to set the Encoding to UTF-8: System.Console.OutputEncoding = Encoding.UTF8;
Edit: Seems like the font is the problem
Yes it does. Try setting the encoding to UTF-8 and you should be able to see Unicode spinners.
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
I set both: System.Console.OutputEncoding = Encoding.UTF8; System.Console.InputEncoding = Encoding.UTF8;
But only get a question mark on the windows console. Probably because of the default font.
Edit: With the Windows Terminal it works as expected
Also having this issue.
In Windows Terminal only the line spinner will show, unless I force UTF8 inside the project with System.Console.OutputEncoding = Encoding.UTF8;
after forcing, dots spinner shows fine.
In regular Command Prompt, forcing adds an invalid character, like UTF8 isn't supported.
Perhaps there's an issue with UTF8 encoding detection? or maybe this is windows terminal adding UTF8 ontop of the command prompt itself.
The stdout encoding needs to be set to UTF-8 or UTF-16 to display UTF-8 characters.
Try running dotnet example info
and see what encoding is being used.
Using Windows Terminal with a Command Prompt instance
In command prompt itself
@Twinki14 I can't reproduce the strange output in your second image. What do your console settings look like?
I can reproduce the line break issue on my machine with main
. I think I've chased it down and we'll get that fixed real soon.
But regarding the spinner - that seems like the default and desired behavior. For example, if you are overriding the encoding and getting a question mark when displaying, that to me indicates that the defaults capability detection did its job and we fell back to the safe renderer. From a library perspective, forcing the issue ourselves isn't going to be a great idea for exactly this reason. I.e. we need to make safe defaults so that y'all as developers don't get issues asking why your spinner has question marks from users not using Windows Terminal.
I can reproduce the line break issue on my machine with
main
. I think I've chased it down and we'll get that fixed real soon.But regarding the spinner - that seems like the default and desired behavior. For example, if you are overriding the encoding and getting a question mark when displaying, that to me indicates that the defaults capability detection did its job and we fell back to the safe renderer. From a library perspective, forcing the issue ourselves isn't going to be a great idea for exactly this reason. I.e. we need to make safe defaults so that y'all as developers don't get issues asking why your spinner has question marks from users not using Windows Terminal.
Regarding the spinner, after running the info example it appears to be acting just as intended. I think the confusion here is that for running a command prompt instance, inside of/with Windows Terminal, there's support for utf8 that doesn't appear to be detected by spectre.console, but i'm also not sure if there's a way you could detect that.
I'm guessing Windows Terminal has it's own utf8 support, but only "on-top" / the way it wraps of the underlying command prompt instance.
This work for me:
- Open cmd -> Properties -> font -> font-style = Cascadia Mono
- Add this code:
System.Console.OutputEncoding = Encoding.UTF8;
System.Console.InputEncoding = Encoding.UTF8;
This work for me:
1. Open cmd -> Properties -> font -> font-style = Cascadia Mono 2. Add this code:
System.Console.OutputEncoding = Encoding.UTF8; System.Console.InputEncoding = Encoding.UTF8;
I can confirm this approach works here too
I'm going ahead and close this issue. The main problem has been resolved (as described in https://github.com/spectreconsole/spectre.console/issues/391#issuecomment-1271332735) by
- ensuring Encoding has been set to
UTF-8
- using a font that can show the spinners.
If someone feels this does not resolve the initial issue, do not hesitate to open a new issue.
Hey,
i have the same issue, but with .net 8.0, which nativly support UTF-8. Setting is the same like in issue https://github.com/spectreconsole/spectre.console/issues/113 Same code worked with previous dotnet versions just perfect.
@lengschder97 This has nothing to do with .NET, but the output encoding of the terminal you're using.