The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Getting non-ASCII text to display in cmd.exe

    Discussion in 'Windows OS and Software' started by Apollo13, Sep 17, 2008.

  1. Apollo13

    Apollo13 100% 16:10 Screens

    Reputations:
    1,432
    Messages:
    2,578
    Likes Received:
    210
    Trophy Points:
    81
    Apparently this is more difficult than I thought. Whenever I try to print out non-ASCII font from a Java program, or by using the cat command to print it out directly from a file, all I get is gobblydygook. Here's some things I've already tried:

    *Using cmd /u, which supposedly makes it work with Unicode. Yeah, right.
    *Switching to Lucida Console from Raster fonts on cmd.exe, which supposedly enables unicode along with cmd /u. No luck.
    *Enabling Russian as a language version for non-Unicode programs under the Advanced tab of Regional and Language options in the Control Panel. No dice.
    *Windows Power Shell Multilingual Edition. Which doesn't do the trick either.

    So how in the world do I get cmd.exe to actually display unicode (non-ASCII Cyrillic in particular) letters? I didn't expect using non-ASCII characters in command line programs would be so problematic :(.

    System is running Windows XP SP3, although I'd like to know if Vista allows non-ASCII characters as well. English version of Windows.
     
  2. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205
    When I do "cmd /?", the wording in the description of the /U option kind of suggests to me that it's not going to display Unicode on the console.

    So... I'd redirect the output to a file and then view the file in your favorite Unicode-capable text editor/viewer.

    For example:

    java myprog > output.txt
    "C:\Program Files\Internet Explorer\iexplore.exe" output.txt

    You may need to set the character encoding in Internet Explorer (or whatever you use to view the file).
     
  3. Apollo13

    Apollo13 100% 16:10 Screens

    Reputations:
    1,432
    Messages:
    2,578
    Likes Received:
    210
    Trophy Points:
    81
    Well, the whole point of the program I'm making is to be interactive, so redirecting the output doesn't help me. Notepad does work just fine with Unicode, though.

    Any other alternatives for an interactive terminal that has Unicode? I've heard that OSX has it, but that doesn't help a whole lot thanks to Apple's EULA and the fact that it's kinda costly. All I can think of that I'm pretty sure would work is a cmd.exe from a Russian install of Windows.
     
  4. Shyster1

    Shyster1 Notebook Nobel Laureate

    Reputations:
    6,926
    Messages:
    8,178
    Likes Received:
    0
    Trophy Points:
    205
    What about running directly in Powershell instead of cmd?
     
  5. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205
  6. Apollo13

    Apollo13 100% 16:10 Screens

    Reputations:
    1,432
    Messages:
    2,578
    Likes Received:
    210
    Trophy Points:
    81
    Tried it and it didn't work. Guess Powershell isn't quite that powerful.

    Good thought. Tried it out, but alas, no luck. Also tried Cygwin, and no luck there either. I also tried OSX's terminal on a university computer, and it also didn't work. It looks like it's possible, but not necessarily easy to set up, in Linux/Unix, so I'm not going to go to the effort to get it working in Linux/Unix, both because I'm sure it's possible in Windows, and because I don't want the program to only be useful in Linux/Unix - *nix isn't that common these days. So I'm thinking maybe a terminal window isn't the way to go - maybe try Java Swing instead. Thought I could save some time by going with the terminal - guess not. Thanks though.
     
  7. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205
    Yeah the problem isn't cmd.exe. It's the console app that runs the window that those command shells are running in. PowerShell and cygwin (without X11) use the same console window, so that's why it's no different. That's why I suggested Console... I was hoping it might have some char encoding options... but I guess not.

    But since you installed cygwin... did you install any of the X11 stuff? You could open up an xterm (or another graphical terminal like rxvt) and do it I think... but you'll have to set an environment variable. See if you can get X running (try typing "startx" at the cygwin/bash prompt)... then if you get the graphical shell, look at the environment vars ("env" or "setenv") and see if there's any locale stuff that tells it the character set...

    EDIT: Oh yeah this may be easier if it works... puttycyg replaces the command shell window for cygwin: http://robertmarkbramprogrammer.blogspot.com/2008/08/cygwin-and-putty-wonderful-combination.html

    btw you may need to change settings in putty and also locale/charset-related environment vars in the bash environment.

    Unfortunately I don't have any of this stuff installed right at the moment....
     
  8. swarmer

    swarmer beep beep

    Reputations:
    2,071
    Messages:
    5,234
    Likes Received:
    0
    Trophy Points:
    205