JDK-4991519 : Encoding Unicode to JIS0208 Throw exception
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.4.2_04
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 2004-02-09
  • Updated: 2004-04-23
  • Resolved: 2004-04-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2_04 04Fixed
Related Reports
Duplicate :  
Description
Since J2SDK 1.4.2_04, an exception is threw when run the following testcase

java.lang.IllegalArgumentException: Illegal replacement
        at java.nio.charset.CharsetEncoder.replaceWith(CharsetEncoder.java:262)
        at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:180)
        at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:203)
        at sun.nio.cs.ext.DoubleByteEncoder.<init>(DoubleByteEncoder.java:31)
        at sun.nio.cs.ext.JIS_X_0208$Encoder.<init>(JIS_X_0208.java:74)
        at sun.nio.cs.ext.JIS_X_0208.newEncoder(JIS_X_0208.java:35)
        at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:317)
        at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:308)
        at java.lang.StringCoding.encode(StringCoding.java:365)
        at java.lang.String.getBytes(String.java:573)
        at CIITest.<init>(CIITest.java:41)
        at CIITest.main(CIITest.java:48)

public class CIITest {

  public CIITest() {

      byte[] tfdElement = null;

      String temp = null;

      byte [] ciiarray;

      ciiarray = new byte[16];
      ciiarray[0] = 0x46;
      ciiarray[1] = 0x7c;
      ciiarray[2] = 0x4b;
      ciiarray[3] = 0x5c;
      ciiarray[4] = 0x45;
      ciiarray[5] = 0x45;
      ciiarray[6] = 0x35;
      ciiarray[7] = 0x24;
      ciiarray[8] = 0x33;
      ciiarray[9] = 0x74;
      ciiarray[10] = 0x3c;
      ciiarray[11] = 0x30;
      ciiarray[12] = 0x32;
      ciiarray[13] = 0x71;
      ciiarray[14] = 0x3c;
      ciiarray[15] = 0x52;

      try {
		  System.out.println("Test JIS0208--->Unicode");
          temp = new String(ciiarray, "JIS0208");

          for (int i=0; i<temp.length(); i++) {
             System.out.println("Pos " + i + ": " + (int)temp.charAt(i));
          }
      }
      catch (Exception e) {e.printStackTrace();}

      try {
		  System.out.println("Test Unicode--->JIS0208");
		  tfdElement = temp.getBytes("JIS0208");
		  System.out.println("No exception occurred");
      }
      catch (Exception e) {e.printStackTrace();}

  }
  public static void main(String[] args) {
    CIITest CIITest1 = new CIITest();
  }
}

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.2_04 FIXED IN: 1.4.2_04 INTEGRATED IN: 1.4.2_04
14-06-2004

SUGGESTED FIX *** /tmp/sccs.c8aiNs Tue Feb 10 16:51:51 2004 --- JIS_X_0208.java Tue Feb 10 15:54:17 2004 *************** *** 73,79 **** public Encoder(Charset cs) { super(cs, c2b.getIndex1(), ! c2b.getIndex2() ); } --- 73,80 ---- public Encoder(Charset cs) { super(cs, c2b.getIndex1(), ! c2b.getIndex2(), ! repl ); } *************** *** 81,86 **** --- 82,88 ---- super(cs, c2b.getIndex1(), c2b.getIndex2(), + repl, avg, max); }
11-06-2004

EVALUATION Will fix in JIS_X_0208 encoder ###@###.### 2004-02-09
09-02-2004