JDK-4153531 : java.lang.PropertiesgetProperty does not recognize unicode key in Properties
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.1.6
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 1998-06-30
  • Updated: 1999-02-11
  • Resolved: 1999-02-11
Related Reports
Relates :  
Description
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)
======================================================================

Comments
EVALUATION Properties files enforce use of 8859_1 encoding so that they are transportable between systems. In 1.2 Unicode values can be used in Properties keys and values using the \uxxxx encoding. The Properties API has many flaws and it may be superceded in a future release.
11-06-2004

WORK AROUND -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= String str=properties.get("1"); String koreanString=new String(str.getBytes("8859_1"), "KSC5601"); -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
11-06-2004