Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emojis not visible even in unicode-supported terminal #46

Open
JustinGrote opened this issue Sep 9, 2024 · 7 comments
Open

Emojis not visible even in unicode-supported terminal #46

JustinGrote opened this issue Sep 9, 2024 · 7 comments

Comments

@JustinGrote
Copy link

JustinGrote commented Sep 9, 2024

PWSH 7.4, Windows Terminal, also happens in vscode. PwshSpectreConsole 2.1.1
image

@trackd
Copy link
Collaborator

trackd commented Sep 9, 2024

SpectreConsole checks terminal capabilities on import and sets a profile.

try running this before you import the module.

$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()

i could replicate your issue in my extension terminal, i had forgot to set UTF8 in my vscode profile.

after setting that and restarting the terminal emojis worked.

if it still doesn't work, could you share the output of the below command?

& (gmo PwshSpectreConsole) { Get-SpectreProfile }

@JustinGrote
Copy link
Author

JustinGrote commented Sep 9, 2024

That does fix it! Interesting. Would it be worth autodetecting some terminals we know have unicode support and enable this? E.g. Windows Terminal can be detected with WT_PROFILE_ID env variable

EDIT: Related: PowerShell/PowerShell#7233

@trackd
Copy link
Collaborator

trackd commented Sep 9, 2024

yea showing a warning on import if someone isn't running utf8 would probably save a few people some headache.

I'm not sure changing someones codepage would be nice? there are some edge cases around WSL and similar that dont mix too well with UTF8.

But utf8 should just be the default one by now...

also at the point we could detect it Spectre has already set the profile..

and it does not appear to be entirely straightforward to force it to utf8 after the fact.. but i've only done some brief tests, maybe there is a way to get it to re-run "discovery".

right side has utf8 before import, just to show the profile
image

@JustinGrote
Copy link
Author

Yeah I'd say warning with a ENV variable or global setting to suppress it is probably the way to go.

@ShaunLawrie
Copy link
Owner

ShaunLawrie commented Sep 30, 2024

But utf8 should just be the default one by now...

I've been hoping windows terminal just bites the bullet and sets this. The annoying part is you need to include that snippet as the very first thing in the profile to avoid any other command generating output before setting the encoding settings.

When I've got some time to tinker I think I'll update the module to detect this and maybe offer something like these options on the first run:

  • Please update my profile with utf8 automatically
  • I'll update my profile manually
  • Leave my profile alone, I know I'm going to have a degraded experience

I avoided touching peoples encoding settings originally but it's kind of so odd to have to set up that it might be worth it.

@trackd
Copy link
Collaborator

trackd commented Oct 7, 2024

PS> pwsh -nop -c 'ipmo .\PwshSpectreConsole\PwshSpectreConsole\PwshSpectreConsole.psd1'
WARNING: Your session is currently using encoding 'OEM United States', this disables certain functionality as SpectreConsole requires UTF8 encoding, consider adding
        '$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = [System.Text.UTF8Encoding]::new()' to your $profile
        to suppress this warning set the environment variable '$env:IgnoreSpectreEncoding=$true'
        Note: this needs to be set before importing the module

this covers the basics atleast.

it'll be in once #50 is merged.

ShaunLawrie added a commit that referenced this issue Nov 19, 2024
@ShaunLawrie
Copy link
Owner

It should spit out a pretty obvious warning now in prerelease...

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants