JDK-6679005 : HORIZONTAL BAR (U+2015) conversion on ISO-2022-JP is wrong.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 6
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2008-03-24
  • Updated: 2011-02-16
  • Resolved: 2008-07-01
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
$ java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)

and

$ java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_13-b05, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
$ uname -a
Linux Rychely 2.6.18-5-amd64 #1 SMP Tue Oct 2 20:37:02 UTC 2007 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
On JDK 6 UPDATE 3 and JDK 5 UPDATE 13 (linux amd64),
When I convert HORIZONTAL BAR (U+2015 like '-') to ISO-2022-JP charset,
it become 0x2129 (like '?').
In ISO-2022-JP, HORIZONTAL BAR is 0x213d.

e.g.
public class Foo
{
    public static void main(String[] args)
    {
        try{
            String s = "\u2015";
            System.out.println(s);

            byte[] iso2022jp = s.getBytes("iso-2022-jp");
            for(int i = 0; i < iso2022jp.length; i++){
                System.out.printf("%02x ", iso2022jp[i]);
            }
            System.out.println("");
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
    }
}

$ java Foo
��
1b 24 42 21 29 1b 28 42

"1b 24 42" and "1b 28 42" is escape sequence on ISO-2022-JP.
Charactor data is only "21 29".

REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION See 6173388 for details. The fix has been backport into 5u7 already. Use -Dsun.nio.cs.map=x-windows-iso2022jp/ISO-2022-JP to get MS variants.
01-07-2008