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

java.lang.PropertiesgetProperty does not recognize unicode key in Properties

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1.6
    • core-libs
    • generic
    • generic

      Name: tb29552 Date: 06/30/98

      There is a bug in java.lang.Properties with Korean string.
      load() method is not handle korean string.

      The test code is below.

      import java.io.*;
      import java.util.*;

      public class PropertiesTest
      {
       public static void main(String[] args) throws Exception
       {
        Properties p=new Properties();
        p.load(new FileInputStream("test.properties"));

        System.out.println(p.getProperty("a"));
        System.out.println(p.getProperty("b"));
        System.out.println(p.getProperty("ÇÑ"));
       }
      }


      test.properties contains :

       a=java
       b=ÇѱÛ
       ÇÑ=ÀÚ¹Ù



      Expected result is

      java
      ÇѱÛ
      ÀÚ¹Ù



      But, the output is

      java
      ??¡¾?
      null



      Java is the language based on Unicode.
      but, this result is not apply this policy.
      The troublesome solution is using additional code.

      String koreanString=new String(p.getProperties("b").getBytes("8859_1"), "KSC5601");

      But, this solution can't correct the problem that not recognize
      unicode key in Properties.

      I want to use Korean string in Properties directly.

      If JavaSoft overload load() method like follow, may correct this problem.

      public void load(InputStream);
      public void load(Reader);

      Thanks for reading.



      This works fine when reading english or number...
      but, not convert input characters to korean string correctly.



      Is it design mistake in Java I18N?
      Why can't i manipulate Korean string with Properties class directly?

      (Review ID: 33206)
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: