Is there a Windows command shell that will display Unicode characters?

UnicodePowershell

Unicode Problem Overview


Assuming I have fonts installed which have the appropriate glyphs in them, is there a command shell for Windows XP that will display Unicode characters? At a minimum, two things that should display Unicode correctly:

  • Directory listings. I don't care what I have to type (dir, ls, get-childitem, etc.), so long as files with Unicode characters in their names appear with the right glyphs, not the unprintable character box.
  • Text file content listings. Again, doesn't matter to me if it's 'less', 'more', 'cat', 'dog', etc., so long as the characters are printed. I recognize that this is more complicated because of character encoding of the file, so if I have to specify that on the command line that's fine with me.

Here's what I've tried so far:

  • cmd.exe
  • Windows PowerShell; including the multilingual version.
  • Cygwin bash

No luck. I even tried installing custom fonts for cmd/PowerShell. PowerShell and cmd.exe seem to be Unicode-aware in the sense that I can copy/paste the non-printable box out of there and it will paste into other apps with the correct characters. Cygwin (?) seems to convert to the ? character and that comes through in the copy/paste.

Any ideas?

Unicode Solutions


Solution 1 - Unicode

To do this with cmd.exe, you'll need to use the console properties dialog to switch to a Unicode TrueType font.

Then use these commands:

 CHCP 65001
 DIR > UTF8.TXT
 TYPE UTF8.TXT

Commands:

  • Switch console to UTF-8 (65001)
  • Redirect output of DIR to UTF8.TXT
  • Dump UTF-8 to console

The characters will still need to be supported by the font to display properly on the console.

I18N: Unicode at the Windows command prompt (C++; .Net; Java)

Solution 2 - Unicode

This was a major issue in PowerShell v1. Version 2 is shipping with a "graphical shell" that corrects the problem, which is ultimately not with PowerShell, but with the Windows console host (which Cmd.exe also uses). You can get the current CTP for PowerShell v2, if you want.

Actually, PowerShell v2.0 was finalized and shipped with the release of Windows 7 and Windows Server 2008 R2 in early August. In addition, the backported versions (Windows Vista/2008) reached their Release Candidate milestone just the other day; Windows XP/Windows Server 2003 should follow very shortly. Linky linky.

Solution 3 - Unicode

Setting the codepage to UTF-8 with the command "chcp 65001" should help you print file contents correctly to the shell (using cmd.exe). This won't work for directory listings though (UTF-16 encoding in NTFS file names).

Solution 4 - Unicode

Try this:

powershell.exe -NoExit /c "chcp.com 65001"

Who uses msysgit:

powershell.exe -NoExit /c "chcp.com 65001; sh --login -i"

Do not forget to change font of window to TrueType font with UTF-8 support ("Lucida Console")

Solution 5 - Unicode

This is how I can got Chinese output in cmd.exe running on Windows 7 Pro English Version. I also tried file names with Japanese, Russian, and Polish and they all seem to display correctly. Input also seems to work, at least when I tried to do a dir xxx* containing non-ascii characters.

  1. Install console2, which is a front-end to cmd.exe (and other shells)

  2. After installation, follow these instructions

    Delete the key HKEY_CURRENT_USER\Console\Console2 command window in the registry.

    Import the following data into windows registry:

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Console\Console2 command window] 
    "CodePage"=dword:000003a8 
    "FontSize"=dword:000a0000 
    "FontFamily"=dword:00000036 
    "FontWeight"=dword:00000190 
    "FaceName"="細明體" 
    "HistoryNoDup"=dword:00000000
    
  3. You may or may not have to change the font. Initially I had the font set to @NimSum, and the Chinese characters came out rotated 90 degrees. Then I switched to NimSum (without the @) and it came out correctly. Then just out of curiosity I switched to Consola and yet I can still see the Chinese characters. So I'm not sure if you actually have to set the font or not.

Solution 6 - Unicode

For a true shell, try PowerShell Plus. You can select Unicode fonts and work with other languages, not only in the editor, but in the true console.

Solution 7 - Unicode

Try Console 2. Be careful with the colors/palette configurations though. Those are a bit buggy. I have confirmed them to not work; they behave like cmd.exe.

Solution 8 - Unicode

Open an elevated command prompt (run cmd as administrator). Query your registry for available TrueType fonts to the console by:

REG query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont"

You'll see an output like:

0    REG_SZ    Lucida Console
00    REG_SZ    Consolas
936    REG_SZ    *新宋体
932    REG_SZ    *MS ゴシック

Now we need to add a TrueType font that supports the characters you need like Courier New, we do this by adding zeros to the string name, so in this case the next one would be "000" :

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v 000 /t REG_SZ /d "Courier New"

Now we implement UTF-8 support:

REG ADD HKCU\Console /v CodePage /t REG_DWORD /d 65001 /f

Set default font to "Courier New":

REG ADD HKCU\Console /v FaceName /t REG_SZ /d "Courier New" /f

Set font size to 20 :

REG ADD HKCU\Console /v FontSize /t REG_DWORD /d 20 /f

Enable quick edit if you like :

REG ADD HKCU\Console /v QuickEdit /t REG_DWORD /d 1 /f

Solution 9 - Unicode

As of November 2011, MinTTY is now Cygwin's default terminal emulator (installed by setup.exe). MinTTY is a fork of PuTTY's terminal emulator, and as such sports proper Unicode support and much-improved compatibility with other terminal emulators.

Solution 10 - Unicode

http://www.microsoft.com/downloads/details.aspx?FamilyID=c913aeab-d7b4-4bb1-a958-ee6d7fe307bc&displaylang=en">PowerShell V2 CTP3 inside http://sourceforge.net/projects/console/">Console2</a> seems to do that. The only downside is that the default console encoding is UCS-2 LE instead of UTF-8.

Solution 11 - Unicode

Also from https://stackoverflow.com/questions/10764920/utf-16-on-cmd-exe

	Open/run cmd.exe
	Click on the icon at the top-left corner
	Select properties
	Then "Font" bar
	Select "Lucida Console" and OK.
	Write Chcp 10000 at the prompt
	Finally dir /b

Solution 12 - Unicode

A fast and convenient way to do it is on the Explorer.

1. Open the Explorer window.
2. Traverse to the top level of directory where you want to find.
3. On the upper right corner, there is a find field.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrandon DuRetteView Question on Stackoverflow
Solution 1 - UnicodeMcDowellView Answer on Stackoverflow
Solution 2 - UnicodeDon JonesView Answer on Stackoverflow
Solution 3 - UnicodeKimView Answer on Stackoverflow
Solution 4 - UnicodeiegikView Answer on Stackoverflow
Solution 5 - UnicodecrusherjoeView Answer on Stackoverflow
Solution 6 - Unicodekarl prosserView Answer on Stackoverflow
Solution 7 - UnicodeKimView Answer on Stackoverflow
Solution 8 - UnicodeAlon OrView Answer on Stackoverflow
Solution 9 - UnicodenneonneoView Answer on Stackoverflow
Solution 10 - UnicodeRobin SmidsrødView Answer on Stackoverflow
Solution 11 - Unicodeuser2718593View Answer on Stackoverflow
Solution 12 - Unicodedavid m leeView Answer on Stackoverflow