JDK-4153167 : separate between ANSI and OEM code pages on Windows
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version:
    orion3windows,arrow,1.1,1.1.4,1.1.7,1.2.1,1.3.0,1.3.1,5.0,6,6u25,7 orion3windows,arrow,1.1,1.1.4,1.1.7,1.2.1,1.3.0,1.3.1,5.0,6,6u25,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS:
    solaris_2.5,windows,windows_95,windows_98,windows_nt,windows_2000,windows_2003,windows_xp,windows_2008,windows_7 solaris_2.5,windows,windows_95,windows_98,windows_nt,windows_2000,windows_2003,windows_xp,windows_2008,windows_7
  • CPU: generic,x86
  • Submitted: 1998-06-29
  • Updated: 2012-06-13
  • Resolved: 2012-06-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 8
8 b28Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
Windows has _two_ code pages that are used in any non Asian locale.  There is the "ANSI" codepage used by any GUI code and there is the "OEM" codepage used by DOS based things such as the DOS shell.

The VM picks the ANSI codepage for the default on startup.  This means that  System.out.println() uses the wrong codepage when it is attached to a DOS console window.

The following will demonstrate: 

// Run this on a US version of Windows

import java.awt.*;
import com.sun.java.swing.*;
import java.io.*;

public class HelloWorldFrame extends JFrame
{
  JButton jButton1 = new JButton();

  public HelloWorldFrame()
  {
    this.getContentPane().add(jButton1, BorderLayout.CENTER);
  }

  public static void main(String[] args) throws Exception
  {
    HelloWorldFrame helloWorldFrame1 = new HelloWorldFrame();

    //String umlaut = "���������������";  
    String umlaut = "\u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00df";  

    helloWorldFrame1.jButton1.setText(umlaut);
    System.out.println (umlaut);

    PrintWriter out = new PrintWriter( new OutputStreamWriter(System.out,
                                                              "Cp437"),
                                       true );
    // Does the right thing
    out.println(umlaut);

    // Does the wrong thing
    System.out.println(umlaut);

    helloWorldFrame1.pack();
    helloWorldFrame1.show();
  }

}


brian.beck@Eng 1998-06-29

Comments
EVALUATION re-open the RFE. Will investiage the possibility of use cmd/console encoding (OEM by default on Windows) for System.out/err when the System.out/err is attached to a real "terminal" when jvm is started, in jdk8 timeframe.
2011-06-13

EVALUATION As suggested above, the new JDK6 java.io.Console class uses OEM codepage on Windows platform when dealing with the DOS prompt/command line on windows. It's definitely too late to change System.in/out/err to use OEM codepage though. So I closed this one as "will not fix"
2006-11-06

EVALUATION In 6.0 we added a Console class which pick the code page used by the underlying console/dos prompt
2006-02-01

EVALUATION Could use GetConsoleCP() to determine OEM code page. norbert.lindenberg@Eng 1999-04-12
1999-04-12