United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4153167 separate between ANSI and OEM code pages on Windows
JDK-4153167 : separate between ANSI and OEM code pages on Windows

Details
Type:
Bug
Submit Date:
1998-06-29
Status:
Closed
Updated Date:
2012-06-13
Project Name:
JDK
Resolved Date:
2012-06-13
Component:
core-libs
OS:
solaris_2.5,windows_2003,windows_nt,windows_2008,windows_98,windows_xp,windows_95,windows_7,windows_2000,windows
Sub-Component:
java.nio.charsets
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
orion3windows,arrow,1.1,1.1.4,1.1.7,1.2.1,1.3.0,1.3.1,5.0,6,6u25,7
Fixed Versions:

Related Reports
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

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

Could use GetConsoleCP() to determine OEM code page.
norbert.lindenberg@Eng 1999-04-12
                                     
1999-04-12
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

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

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



Hardware and Software, Engineered to Work Together