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

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?


Solution 1:

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:

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:

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:

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")