JDK-4195985 : new String( bvar , "ISO2022CN_GB"); returns exception
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1998-12-09
  • Updated: 1998-12-10
  • Resolved: 1998-12-10
Related Reports
Duplicate :  
Description

Name: nl37777			Date: 12/08/98


JDK Version:
java version "1.2"
Classic VM (build JDK-1.2-U, green threads, sunwjit)

String var1 = new String( bvar, "ISO2022CN_GB") causes exception.

Program that reproduces problem:

import java.util.*;
 
public class test2 {
 
    public static void main(String[] args)
    {
    try {
        String var0 = new String("any string");
        byte[] bvar = var0.getBytes("ISO2022CN_GB"); //works
        //byte[] bvar = var0.getBytes("ISO2022KR"); //works
 
        String uniString = new String(bvar, "ISO2022CN_GB"); //does not work
        //String uniString = new String(bvar, "ISO2022KR"); //works
        System.out.println("Unicode String= " + uniString);
        }
        catch (Exception e)
            {
            System.out.println("ERROR: " + e.getMessage());
            }
    }
}


Error returned is:
$java test2
ERROR: ISO2022CN_GB
(Review ID: 47367)
======================================================================

Comments
EVALUATION There are two separate converters for the direction char -> byte for ISO2022CN_CNS and ISO2022CN_GB, but only one for the direction byte -> char which handles both sub-encodings. This converter is simply called ISO2022CN. Our alias mechanism isn't set up to handle this kind of asymmetry, so we may have to create two separate subclasses of ByteToCharISO2022CN just to get the names right. norbert.lindenberg@Eng 1998-12-08
08-12-1998

WORK AROUND Use ISO2022CN. norbert.lindenberg@Eng 1998-12-08
08-12-1998