Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On Windows 7, dir or tree can't show unicode characters, even starting cmd with cmd /U

So I would press Window Key + R to run something, and type in cmd /U so that the content might handle Unicode.

And then using dir or tree /F, the content in Unicode won't show as Unicode. (in Window Explorer (file manager), the Unicode will show)

Is there a way to handle it? To get Unicode characters to test your filenames, you can go to

http://news.google.com/news?edchanged=1&ned=tw

and you will be able to get many Unicode characters there (UTF-8)

share|improve this question
    
Have you tried this with Powershell yet? Windows 7 has it installed by default. –  KdgDev Jun 27 '10 at 1:25
    
If I use PowerShell, and do a help ls -full it doesn't have such option as cmd's dir /B –  動靜能量 Jun 27 '10 at 5:03
    
Remember, PowerShell pipes objects between commands - you can get behavior similar to dir /b by executing: dir | % { $_.Name } –  Goyuix Nov 18 '10 at 14:27
    
@Guyuix: Or gci | select -expand Name –  Joey Apr 10 '11 at 8:32

3 Answers 3

Change the font for the console window to a TrueType font, such as Lucida Console or Consolas. With raster fonts you are restricted to the OEm character set.

cmd /u only changes output piped into files, not what you see on screen.

PowerShell by default uses a TrueType font which is why it worked for you.

This has nothing to do with cmd.

share|improve this answer
    
Even if I change to Lucida or Consolas and run cmd /u, I don't get the Unicode characters. –  Snark Apr 10 '11 at 8:07
1  
If you see boxes, then it does indeed work. The console subsystem does not support font switching so it can only use glyphs from the single font you specified. And since neither font has glyphs for Han ideographs you'll see only boxes. However, the text is there; you can copy and paste it, for example. You won't see anything different in PowerShell, though, unless you use the PowerShell ISE (which is not a console application and therefore not subject to the same limitations). –  Joey Apr 10 '11 at 8:31
    
@Joey The problem is entirely a result of using CMD. CMD cannot display Unicode characters. CMD can display DBCS characters, but only that of your system locale. Change your system locale to Shift-JIS, reboot, and you'll be able to show Japanese (Shift-JIS only, not Unicode) characters. The CMD command line processor supports Unicode, thus you can pipe output to files and open them in Notepad, for example, but you can't display Unicode. –  Jeff Dec 2 at 3:09
1  
@Jeff it can't display a lot characters simply because those characters aren't exist in the current font. It can't simply replace the characters by the same in another font like in GUI, as the font policy in cmd is very strict, it only accepts some specific fixed-width font. It isn't because of locale because if I set the codepage to Vietnamese, cmd can still display Russian, Turkish, Japanese... characters without problem, provided that the characters are available in the font. –  Lưu Vĩnh Phúc Dec 2 at 7:51

It's not just a command prompt problem, but a Windows problem in general. The C "wide-character" functions in Windows (namely wprintf) do not support Unicode.

share|improve this answer
    
Proof for your claim? MSDN constantly mentions the wide-char variants for Unicode. –  Joey Apr 10 '11 at 8:34
    
Here's one. –  Mehrdad Apr 10 '11 at 8:37
    
you are aware that that is a bug that was reported on a prerelease version of Visual Studio 2005 and has been long fixed (not to mention that we're at VS 2010 by now ...)? Note also that the Windows API can easily be used and there is no particular reason to use the C standard library in places where no portability problems are likely to be encountered. –  Joey Apr 10 '11 at 20:18
    
@Joey: No, I wasn't aware of that. However, right now I'm using Visual Studio 2008 and calling wprintf(L"私"), and it's definitely not printing anything Unicode. Do you have any example of complex scripts that do get printed with wprintf? (Locale changing shouldn't be needed because the strings are UTF-16.) –  Mehrdad Apr 10 '11 at 20:24
    
The Windows console does support Unicode because it uses Unicode behind the scenes stackoverflow.com/questions/1259084/… stackoverflow.com/questions/2213541/… stackoverflow.com/questions/388490/… In Windows 7 codepage 65001 can't display the characters correctly but you can copy the them to a text editor to see the correct output. In Windows 8 it displays UTF-8 without problem –  Lưu Vĩnh Phúc Jun 10 at 9:56

http://stackoverflow.com/questions/10764920/utf-16-on-cmd-exe

  1. Open/run cmd.exe
  2. Click on the icon at the top-left corner
  3. Select properties
  4. Then Font bar
  5. Select Lucida Console and OK.
  6. Write Chcp 10000 at the prompt
  7. Finally dir /b

Also from http://stackoverflow.com/questions/379240/is-there-a-windows-command-shell-that-will-display-unicode-characters/24135341#24135341

  1. CHCP 65001
  2. DIR > UTF8.TXT
  3. TYPE UTF8.TXT
share|improve this answer
    
10000 is not a Unicode codepage and it can only displays characters in Mac Roman charset –  Lưu Vĩnh Phúc Jun 10 at 9:58
    
how can you display like, Chinese, Japanese characters or emoticons... in that codepage? –  Lưu Vĩnh Phúc Jun 10 at 10:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.