I created a small Eclipse application that simply prints the string äÄß via System.out. When I run this application from within Eclipse the string is correctly printed out in the Eclipse console view. However if I build a product containing this application and start it on windows with eclipsec.exe, I see a─▀ printed to the console.
The product definition is:
<configIni use="default">
</configIni>
<launcherArgs>
<programArgs>-consoleLog</programArgs>
<vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
</launcherArgs>
<windowImages/>
<launcher>
<solaris/>
<win useIco="false">
<bmp/>
</win>
</launcher>
<vm>
</vm>
<plugins>
<plugin id="console-encoding"/>
<plugin id="javax.transaction" fragment="true"/>
<plugin id="org.eclipse.core.contenttype"/>
<plugin id="org.eclipse.core.jobs"/>
<plugin id="org.eclipse.core.runtime"/>
<plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
<plugin id="org.eclipse.equinox.app"/>
<plugin id="org.eclipse.equinox.common"/>
<plugin id="org.eclipse.equinox.preferences"/>
<plugin id="org.eclipse.equinox.registry"/>
<plugin id="org.eclipse.osgi"/>
</plugins>
<configurations>
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
</configurations>
I tried to set the value of osgi.console.encoding to Cp1252 and console.encoding also to Cp1252. I also tried changing the codepage of the command prompt where I start the eclipse application, but that didn’t help either. When I’m typing German umlauts on the console they are displayed correctly.
What do I have to do to display the German umlauts on the console correctly?
EDIT:
I have modified the application to also read a line from new BufferedReader(new InputStreamReader(System.in)) and print that out too. When the codepage of the console is set to Cp850 I can input äÄß and this is printed out. If I attach a debugger, I see that the input in eclipse looks like „Žá.
I also tried to explicitly specify the encoding via new PrintStream(System.out, true, "Cp1252"), but that didn’t change anything.
I’m using Windows 7, just in case it matters.
The easiest way of printing German umlauts to the console correctly is to use
System.console()and the methods it provides.Another way is to configure the encoding to be used externally, via a system property for example. Then the application has to use that encoding to create the necessary Writer, Readers and Streams. For Windows systems this encoding has to be
IBM850.The problem is that in Windows the default encoding
Cp1252is used also forSystem.outandSystem.in. But the windows console usescodepage 850(a legacy from DOS times), which correspondents to the encodingIBM850in Java. SinceCp1252andIBM850are not compatible the characters get messed up.