I'm trying to set up Mercurial to print out the status of the repository I'm currently in with PowerShell. So far, I have everything working, but I would like to be able to print '☿' to the prompt when I am in a repository. Unfortunately, it seems that PowerShell has some problems with printing Unicode characters.
In the accepted answer for Is there a Windows command shell that will display Unicode characters? it is suggested that PowerShell v2, which shipped with Windows 7 (which I am using) would be able to print Unicode characters, but I can't seem to get it to work. Likewise, the next answer of using chcp 65001
does not work either.
Is this still a deficiency in PowerShell, or am I missing something obvious?
The PowerShell system supports Unicode exclusively for character and string manipulation. Windows itself supports both Unicode and traditional character sets such as Windows code pages.
This is not a PowerShell deficiency. It is a deficiency with the Windows console subsystem which PowerShell.exe uses. The console subsystem does not support Unicode but code pages instead which dates back to the DOS days. The PowerShell V2 fix is provided via the PowerShell Integrated Scripting Environment or PowerShell_ISE.exe. This is a graphical app based on WPF which can handle Unicode characters easily.
In theory you could change the code page using chcp or
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding(850)
to display different characters but I haven't had much luck with this. You'd also need to find a code page that contains the character you want to display.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With