|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
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
|