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

[Fmt-Nu] French thousands separator is non-breaking space

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • P4
    • tbd
    • 1.3.0, 5.0u4, 6u10
    • core-libs
    • generic, x86
    • generic, windows_xp

    Description



      Name: yyT116575 Date: 10/03/2001


      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      This is an attempt to reopen bug 4350931.
      That bug complained that the French thousands separator
      (when formatting numbers) does not print. The bug was
      closed; it was claimed that the thousands separator is a space.

      It is true that the separator is a space, but it is a special non-breaking
      space -- the character 0xA0. This means that if the user in a UI types
      a number with (normal) spaces, the Java formatting code will reject it
      with an error.

      It's not even clear that this special space character will be displayed
      as such in a HTML client. Certainly it will not occur to a user who
      sees an existing value that he needs to type a funny space character.

      The following source code shown the spaces will cause the number
      be rejected.

      import java.text.*;
      import java.util.Locale;

      public class French {
        public static void main(String args []) {
          NumberFormat form = NumberFormat.getInstance(Locale.FRENCH);
          form.setGroupingUsed(true);
          String fmt = form.format(123456.789);

          System.out.println("Here is the formatted value:");
          for (int i = 0; i < fmt.length(); i++) {
            System.out.print((int) (fmt.charAt(i)));
            System.out.println(" " + fmt.charAt(i));
          }

          String fmtAsSpace = "123 456,789";
          System.out.println("About to parse " + fmtAsSpace);

          try {
            System.out.println(form.format(fmtAsSpace));
          } catch (Exception e) {
            System.out.println(e.getMessage());
          }
        }
      }

      Here is the output:

      Here is the formatted value:
      49 1
      50 2
      51 3
      160 ?
      52 4
      53 5
      54 6
      44 ,
      55 7
      56 8
      57 9
      About to parse 123 456,789
      Cannot format given Object as a Number
      (Review ID: 132812)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              nishjain Nishit Jain
              yyoungsunw Yung-ching Young (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: