Garbled characters in the Windows command line?

Do you use OpenDS, Glassfish, Directory Server Enterprise Edition or other Java applications on german, french or spanish Microsoft Windows and see the accentuated characters like ùûüÿàâäçéèêëïîñóôöœßÙÛÜŸÄÀÂÇÉÈÊËÏÎŒÑÖÓÔ garbled in the command line interface? Here's why and how to fix it:

Unlike UNIX and UNIX-like systems, Microsoft Windows lacks the benefits of utf-8 encoding. Instead a mess of ANSI and OEM "codepages" is used. A bug in the JDK 5 System.out/.in/.err classes causes the wrong codepage to be selected when the application  is attached to a DOS console window. The bug was found too late, so it became a feature.

The java.io.Console class in JDK 6 detects the codepages correctly and should be therefore preferred. However we still support JDK 5, so the old classes are used and you still meet broken french/german/spanish/... CLI.

cmd.exe with cp850

Fortunately there's an easy workaround:

Right-click on the title bar of the cmd.exe window and choose 'Properties'. In the 'Font' tab switch the font to Lucida Console and click OK. Then in the cmd.exe window issue the below command:

chcp 1252

cmd.exe with cp1252


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Members of the EMEA Globalization Center are blogging about the products that comprise the Java Enterprise System stack.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today