Instructions to get emojis to work (on Windows)
See original GitHub issueI am using Emojis for a project and everything worked perfectly fine on my machine. After distributing the self executable to the customer he reported me that the emojis didn’t get printed out and instead two question marks (??) are displayed. This was quite surprising because in the documentation there exists no section of when emojis get printed and when not.
So this is an effort of collecting solutions on how to get emojis to work on Windows.
-
Set the OutputEncoding manually: This is an easy fix to do, just add
System.Console.OutputEncoding = System.Text.Encoding.UTF8
as the first line of the main function. Altough this is a quick fix I don’t think it is the best solution because basically you override the Encoding settings of the parent console. -
Set the Encoding of the PowerShell (Core) console on a per session basis: You can set the input and output encoding of the console by executing the following line
[console]::InputEncoding = [console]::OutputEncoding = [System.Text.Encoding]::UTF8
This commaand can be put in the profile file so the command gets executed automatically. There exists also an issue to set UTF-8 as the default encoding on PowerShell Core: https://github.com/PowerShell/PowerShell/issues/7233 -
Set the UTF-8 worldwide language support:
- Execute
intl.cpl
- Go to [Administrative], then [Change system locale…]
- Set the checkbox
- Execute
In fact this was the setting I had set on my development machine which caused to render the emojis correctly.
I hope this helps troubleshooting the issues I had with the output encoding (and emojis) and maybe some explanation could be added to the documentation.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:8 (3 by maintainers)
Top GitHub Comments
Documentation added in #744
I found that this affected the display of the line graphics as well, and not just the emojis. For example, having looked at the Progress sample, I tried implementing my own, but I was confused when the line styles and spinners did not match up with the ones in the animations. Setting the output encoding to utf-8 and running in Windows Terminal improved things.