2
votes

I am writing very simple console application in Java.

The problem is that I need to ouput cyrillic and estonian non-utf8 symbols to console, but in Windows I get bunch of strange symbols and in MacOsX I get only ???? instead of something more readable.

How Can I achieve my aim?

--UPDATE 1--

locale gave me:

LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

Seems I am stuck with that UTF-8 thing %)

Strange idea:

Is there any way to get a console from eclipse and use it outside of eclipse?

1
First thought: use a font that supports those particular unicode valuesmre
Is it possible to set a font for System.out.println()?Jevgeni Smirnov
Windows DOS command prompt is a non-Unicode program: it only supports certain fonts (right-click on top-left icon to access its properties) and it depends on your current language setting. You don't have much choice under Windows other than to modify the current Language for non-Unicode programs to the language you want but this is a global setting which you need to restart technet.microsoft.com/en-us/library/cc721887(WS.10).aspxecle
Do you use precompiled classes on Mac or do you compile from source? If you compile from source, what is the character encoding of the source files? javac will assume it's the system default encoding, utf-8. If it's something different you have to use the -encoding parameter. Otherwise the compiler can't know what characters your source files have.Joni

1 Answers

1
votes

Windows Terminal: The terminal program, cmd.exe, doesn't use the same encoding as the rest of the OS, and from Java you have no way of knowing if you are being run from a terminal or not. You have to set the font used by cmd.exe to Lucida Console and switch the "code page" with chcp before running the program:

OS X Terminal: as far as I know the terminal is configured for UTF-8, so you can just use UTF-8. Use the locale command to check your encoding.