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

Hebrew string get reversed when using '\r' in string

XMLWordPrintable

      Hebrew string get reversed when using '\r' in string while running in jdk 1.4
      or above along with the BDO character \u202D. Whenever we try to set the
      text of JTextField or JTextArea with the string containing '\r' character
      along with Right to Left override character \u202D, the string gets displayed
      in the reverse manner. This is not happening when the string is not preceded
      by the RLO character. We are trying to insert the text with the characters
      "\n\r" ( carriage return) so that the text following them will be shown in a
      new line. But the string gets displayed in a reversed manner.
      .
      Suppose the String1 contains \u202Dh1h2h3 as the hebrew contents and string3
      contains h4h5h6 and string2 contains \r\n. The expected behavior is
      .
      h3h2h1
      h6h5h1
      .
      but the actual behaviour is
      .
      h1h2h3
      h6h5h1
      This system is SRS Net Connect enabled: No
      I will be sending an Explorer file: No
      List steps to reproduce the problem(if applicable): STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Run the given testcase with jdk 1.4 or above and observe string get
      reversed.
      2) Remove the \u202d character from string1 and again run the test case, the
      string will not get reversed
      3)It will be working fine when running in jdk 1.3. Compare both the results
       
      TestCase:
       
      import java.awt.ComponentOrientation;
      import javax.swing.JFrame;
      import javax.swing.JTextArea;
       
       
      public class JTextAreaDemo extends JFrame
      {
        JTextArea textArea = new JTextArea("Swing TextArea");
        
        public void init()
        {
          add(textArea);
          
          String string1 = "\u202D\u05d0\u05dc\u05e8";
          String string2 = "\r\n";
          String string3 = "\u05d9\u05e9\u05e8";
       
          textArea.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
          textArea.setText(string1+string2+string3);
          
          this.setVisible(true);
        }
        
        public static void main(String args[])
        {
          new JTextAreaDemo().init();
        }
      }

            peterz Peter Zhelezniakov
            rabarker Rich Barker (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: