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

[Win32] incorrect character conversion

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2 P2
    • None
    • 1.2.0
    • core-libs

      On Win32 platform (tested NT4.0 ja), following SJIS code is converted to different unicode than MicroSoft mapping. These are identail character, but has two different character code.

              These 5 character is recognized incorrectly yet.

                                              MS- JAVA
              Name SJIS UNICODE UNICODE
              ------------------------------------------------
              palarell sign 0x8161 0x2225 0x2016
              fullwidth minus 0x817c 0xff0d 0x2212
              cent sign 0x8191 0xffe0 0x00a2
              pound sign 0x8192 0xffe1 0x00a3
              mathematical not sign 0x81ca 0xffe2 0x00ac

      palarell sign and fullwidth minus are different character conversion
      between MS-Windows and Java.
      Other 3 characters are mapped to Latin-1 category by Java, but
      mapped to FullWidth Form category by MS-Windows.

      Sample Program as follows. Upper testfield is awt.TextField,
      Lower is awt.swing.JTextField. When pushed enter key in each textfield,
      the text it has is displayed into TextArea, Label and System.out.

      ------

      import java.awt.*;
      import java.awt.event.*;
      import java.awt.swing.JTextField;

      class GetSetString extends Frame implements ActionListener {
        JTextField jtf;
        TextField tf;
        TextArea ta;
        Label l;
        Button b;
        Panel p;

        public void setup() {
          // initialize components
          String initData = "\u00a2\u00a3\u00ac\u2016\u2212\uff06\uff3c";
          tf = new TextField(initData, 20);
          jtf = new JTextField(initData, 20);
          ta = new TextArea(2,20);
          l = new Label("text");
          p = new Panel();
       
          // layout setting
          p.setLayout(new BorderLayout());
          p.add(tf, "North");
          p.add(ta, "Center");
          p.add(l, "South");
          setLayout(new BorderLayout());
          add(p, "North");
          add(jtf, "South");

          // set components' attribute
          tf.addActionListener(this);
          jtf.addActionListener(this);
          ta.setEditable(false);
        }

        public void actionPerformed(ActionEvent e) {
          String dataText;
          if (e.getSource() == jtf)
            dataText = jtf.getText();
          else
            dataText = tf.getText();
          ta.setText( dataText );
          l.setText( dataText );
          System.out.println( "data: "+dataText );
        }

        public static void main( String[] args ) {
          GetSetString obj = new GetSetString();
          obj.setup();
          obj.addWindowListener( new WindowAdapter(){
            public void windowClosing( WindowEvent e ){ System.exit(0);}
          });
          obj.pack();
          obj.show();

        }
      }

      koushi.takahashi@japan 1998-03-18

            bcbeck Brian Beck (Inactive)
            ktakahassunw Koushi Takahashi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: