Printing Unicode characters to the PowerShell prompt - unicode

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?

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.

Prints semi-fine here. Consolas doesn't have a glyph for that character, so all I see in the console window is a replacement glyph. But PowerShell accepts and prints it just fine, as you can see when copy-pasting it.
Now, if you have set your console window to raster fonts, then the story is a little different, but PowerShell luckily has sane defaults.

You can't using the default PowerShell (i.e. windows) console. However, if you use the PowerShell ISE (which provides its own console), it will work. I am not sure if this will meet your needs though.

Deja Vu Sans Mono works in cmd and has that character, and so it works in PowerShell too.
BTW, I suggest also installing Droid Sans Mono, and Courier New, to the command prompt. They'll then be available in PowerShell too. There aren't many mono spaced fonts that cmd supports. But those are three, Deja Sans Mono, Droid Sans Mono, and Courier New.

You need to
install a monospace font in your system, that contains your glyph (possibly use Character Map to find a suitable one, etc)
and then
set it as a console font, as described here: http://www.watchingthenet.com/how-to-add-and-change-fonts-in-windows-command-prompt.html

Related

Chinese characters in emacs --no-window-system on windows

I recently started using emacs on Android in Termux. My projects feature some chinese characters, which are displayed there just fine.
When later opening the same file in Emacs on Windows, I was disappointed to see them displayed as \xxxx
I am not sure how to search for a solution, because I do not what the problem is.
The only thing I found related to my problem is this:
Unicode characters in emacs term-mode
but it did no help me solve the issue.
You can tell what's going on by looking at the first few characters in the mode line. In Termux, it says UUU, but in Windows it says DDU. These three characters stand for:
the coding system for keyboard input
the coding system for terminal output
the coding system of the file in the buffer
U stands for UTF-8, while D stands for various DOS code pages. (You can find this using M-x list-coding-systems. This is all described in the Mode Line section of the Emacs manual.)
So this means that Emacs is reading the file correctly, but it thinks that the terminal is unable to display the Chinese characters, so it uses the \uxxxx notation as a fallback. I'm not sure how to get this to work properly in a Windows terminal, but try M-x set-terminal-coding-system with utf-8 - it might just work.
As an aside, if you run Emacs as a "normal" Windows application instead of in a terminal, the characters should display correctly automatically, so if there is a particular problem preventing you from doing so, it might be worth trying to fix that instead.

Displaying UTF-8 Characters in Powershell Console [duplicate]

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?
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.
Prints semi-fine here. Consolas doesn't have a glyph for that character, so all I see in the console window is a replacement glyph. But PowerShell accepts and prints it just fine, as you can see when copy-pasting it.
Now, if you have set your console window to raster fonts, then the story is a little different, but PowerShell luckily has sane defaults.
You can't using the default PowerShell (i.e. windows) console. However, if you use the PowerShell ISE (which provides its own console), it will work. I am not sure if this will meet your needs though.
Deja Vu Sans Mono works in cmd and has that character, and so it works in PowerShell too.
BTW, I suggest also installing Droid Sans Mono, and Courier New, to the command prompt. They'll then be available in PowerShell too. There aren't many mono spaced fonts that cmd supports. But those are three, Deja Sans Mono, Droid Sans Mono, and Courier New.
You need to
install a monospace font in your system, that contains your glyph (possibly use Character Map to find a suitable one, etc)
and then
set it as a console font, as described here: http://www.watchingthenet.com/how-to-add-and-change-fonts-in-windows-command-prompt.html

PowerShell: svn st and German umlauts [duplicate]

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?
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.
Prints semi-fine here. Consolas doesn't have a glyph for that character, so all I see in the console window is a replacement glyph. But PowerShell accepts and prints it just fine, as you can see when copy-pasting it.
Now, if you have set your console window to raster fonts, then the story is a little different, but PowerShell luckily has sane defaults.
You can't using the default PowerShell (i.e. windows) console. However, if you use the PowerShell ISE (which provides its own console), it will work. I am not sure if this will meet your needs though.
Deja Vu Sans Mono works in cmd and has that character, and so it works in PowerShell too.
BTW, I suggest also installing Droid Sans Mono, and Courier New, to the command prompt. They'll then be available in PowerShell too. There aren't many mono spaced fonts that cmd supports. But those are three, Deja Sans Mono, Droid Sans Mono, and Courier New.
You need to
install a monospace font in your system, that contains your glyph (possibly use Character Map to find a suitable one, etc)
and then
set it as a console font, as described here: http://www.watchingthenet.com/how-to-add-and-change-fonts-in-windows-command-prompt.html

Issue with coding Windows-1250 in Perl

I have a text file encoded in Windows-1250. I'm using Windows 7 EN.
I would like to iterate through this file line by line in Perl code with
print. In console I cannot see the diacritic signs.
Could you give me any solution?
It depends on what you are going to do with the text, but for many cases
it's possible to code independently on encoding. Anyway, if you redirect
output to a file and the result is OK (read: can be displayed opened by
text editor in Windows 1250 mode using proper font), your code is not the
problem.
The other thing is that you want to see CE characters in your console.
For that to work you need to do:
set your console window to use font capable of displaying them (you
may need to install such font, I don't remember The Right Way in Win 7)
set your console to Windows-1250 mode using command chcp 1250
Note that this is basically the same you would need to do with your viewer
or editor to see the characters. Except that while many editors are able
to detect encoding themselves (sometimes even correctly) and pick the right
font, consoles typically need help from you.
Your problem might be similar to what has been solved here. I also
recommend reading the other post I'm referencing there.

How to Make Emacs Display Chinese Characters

I often use simple Chinese phrases like "你好" to test that my code can handle non-ascii characters. Whenever I enter Chinese characters directly into Emacs, they just come out as question marks.
Emacs can sometimes display characters properly if I open a premade text file but not always. For example, if I create a simple text file in Notepad with "你好" in it, the 好 displays fine but 你 just shows a box. Can Emacs handle Chinese characters? If so, how do I set it up?
I'm running Emacs 22.3.1 on Windows with the Courier New font, but I'm also curious about having this work on Linux. I have all the needed Eastern Language packages installed. I can edit in Chinese in Notepad with no problem.
The Emacs 23 release solves the problem I was having on Windows. Chinese characters work properly with no fussing or hacking. I can write Chinese directly in a buffer or open a file with no issues. Emacs's unicode support wasn't fully implemented until version 23.
Emacs 23 Release Notes
Have you tried this (leim)?
http://www.khngai.com/emacs/chinese.php
Liberation Mono font, which I use under Emacs, can display these characters.