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

Arabic locales do not have \u0660 as zero digit base

XMLWordPrintable

      Name: rlT66838 Date: 05/09/2000


      java version "1.3beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
      Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

      When formatting numbers for the Arabic locales, the European digits are used
      instead of the Arabic digits. While some Arabic locales might use European
      digits as a default this is not the case everyone. The following code uses
      NumberFormat to format a number using the default locale.

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import java.text.*;
      import java.util.*;
      import java.lang.*;

      public class ArabicTest extends JPanel {
          static JFrame frame;

          public ArabicTest() {
      NumberFormat nf = NumberFormat.getInstance();

      JLabel label = new JLabel(nf.format(1234567.89));
      label.setFont(new Font("Lucida Sans", Font.PLAIN, 22));
      add(label);
          }

          public static void main(String s[]) {
      ArabicTest panel = new ArabicTest();

      frame = new JFrame("ArabicTest");
      frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
      });
      frame.getContentPane().add("Center", panel);
      frame.pack();
      frame.setVisible(true);
          }
      }


      If we ran this as follows:

      java -Duser.language=ar -Duser.region=EG ArabicTest

      we should get the number formatted using the Arabic digits. I have tried this
      with every Arabic locale and it doesn't work.
      (Review ID: 103178)
      ======================================================================

      Same issue reported by a CAP member:

       
      There is an bug for numbers with the arabic locale. The Arab is using
      arabic-indic digits. All arabic locales is using the default (english)
      number format because there in no entry "NumberElements" in the
      LocaleElements_ar.class. You can verify it with:
       
           java.util.Locale locale = new java.util.Locale("ar");
           //java.util.Locale locale = new java.util.Locale("th", "TH", "TH");
           //java.util.Locale locale = new java.util.Locale("hi", "IN");
           java.text.DecimalFormat df = (java.text.DecimalFormat)java.text.DecimalFormat.getNumberInstance(locale);
           System.out.println(df.format(12345));
       
      We have find only 2 Locales with other digits "th_TH_TH" and "hi_IN".
       

      ###@###.### 2005-04-14 14:50:34 GMT

            jtusla Jiri Tusla (Inactive)
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: