Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4153167

separate between ANSI and OEM code pages on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 8
    • orion3windows, arrow, 1.1, 1.1.4, 1.1.7, 1.2.1, 1.3.0, 1.3.1, 5.0, 6, 6u25, 7
    • core-libs
    • b28
    • generic, x86
    • solaris_2.5, windows, windows_95, windows_98, windows_nt, windows_2000, windows_2003, windows_xp, windows_2008, windows_7
    • Not verified

      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

            sherman Xueming Shen
            bcbeck Brian Beck (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: