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

java.util.Properties.save and store doesn't save unicode chars correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.3.0
    • 1.2.0
    • core-libs
    • None
    • kestrel
    • generic
    • generic

      The spec says that store should output the unicode chars less than /u0020 as the unicode values. This doesn't happen in 1.2. It happens it 1.1.


      Here is a test

      put /net/castor.east/jtg/testbase/src/modena_jlib2_2/classes in your classpath

      /*
       * JLIB++ : The Modena JLIB++ Suite, Version 2.2, June 1998
       * Copyright (c) 1995-1998 Modena Software (I) Pvt. Ltd., All Rights Reserved
       */

      /*
       * Section : 21.6.8
       * Filename : c2106088
       * Purpose : Positive test for section 21.6.8
       *
       * public void save(OutputStream out, String header)
       * Each character of the associated element string is examined to see
       * whether it should be renedered as an escape sequence.
       * Characters less than \u0020 and characters greater than \u007E are
       * written as \\uxxxx for the appropriate hexadecimal value xxxx.
       */
       
       import cpack.*;
       import java.io.*;
       import java.util.Properties;
       import java.util.Date;
       
       
       class X extends Properties{
       
        X(){ }

        X(Properties props)
        {
          super(props);
        }
           
       static int i;
       static String file_Name = "test.txt";
       InputStream in1;
       InputStream in2;
       DataInput din;
       OutputStream out;

       public void check_Save()
       {
         String element = null;
         String str = "NAME1=MOD\u0019ENA1";
         X x_Props = new X();
         
         try
         {
           out = new FileOutputStream(file_Name);
           in1 = new StringBufferInputStream(str);
           in2 = new FileInputStream(file_Name);
           din = new DataInputStream(in2);
           
           x_Props.load(in1);
           x_Props.store(out,null);
           din.readLine();
           element = din.readLine();
           Chk.chkIntVal("err_1","length",element.length(),19); //length of the
                                                                 //string written
         }
         catch (IOException io1)
         {
           Chk1.fileError("c2106088");
         }
       }
       
       
       public static void main(String argv[])
       {
         X ox = new X();
         ox.check_Save();
       
         Chk.endTest("c2106088");
       }
      }

      In 1.1 the output files looks like

      #Mon Feb 22 11:09:53 EST 1999
      NAME1=MOD\u0019ENA1

      and in 1.2 it looks like

      #Mon Feb 22 11:01:45 EST 1999
      NAME1=MODENA1

            mmcclosksunw Michael Mccloskey (Inactive)
            chrowe Chrys Rowe (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: