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

sun.io.CharToByteKSC5601 cause incorret charset conversion.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.3
    • core-libs
    • None
    • sparc
    • solaris_2.5.1



      Name: el35337 Date: 07/23/97


      /*
      C:>java BugChecker5
      java.vendor: Sun Microsystems Inc.
      java.version: 1.1.3
      os.name: Solaris
      os.arch: sparc

      CharToByteKSC5601 bug: number of KSC5601 bytes written should be 20000, not be 19996
      CharToByteKSC5601 bug: number of KSC5601 bytes written should be 19999, not be 19995

      <<< Solution >>>
      The statement
      `charOff++;'
      should be placed at the last statement of the while loop in
      `convertHangul' method for restartibility in case of exception occurrences.
      */

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

      class BugChecker5
      {
          public static void main(String[] args)
              throws IOException
          {
              System.out.println( "java.vendor: " + System.getProperty("java.vendor") );
              System.out.println( "java.version: " + System.getProperty("java.version") );
              System.out.println( "os.name: " + System.getProperty("os.name") );
              System.out.println( "os.arch: " + System.getProperty("os.arch") );
              System.out.println();

              ByteArrayOutputStream bos;
              OutputStreamWriter osw;
              byte[] array;
              char[] carray = new char[10000];

              bos = new ByteArrayOutputStream();
              osw = new OutputStreamWriter(bos, "KSC5601");
              for (int i = 0; i < 10000; ++i)
                  carray[i] = '\uac00';
              osw.write( new String(carray) );
              osw.close();
              array = bos.toByteArray();
              if ( array.length != 20000 )
                  System.out.println( "CharToByteKSC5601 bug: number of KSC5601 bytes written should be 20000, "
                             + "not be " + array.length );
              
              bos = new ByteArrayOutputStream();
              osw = new OutputStreamWriter(bos, "KSC5601");
              carray[0] = 'a';
              for (int i = 1; i < 10000; ++i)
                  carray[i] = '\uac00';
              osw.write( new String(carray) );
              osw.close();
              array = bos.toByteArray();
              if ( array.length != 19999 )
                  System.out.println( "CharToByteKSC5601 bug: number of KSC5601 bytes written should be 19999, "
                             + "not be " + array.length );
          }
      }

      company - KAIST , email - ###@###.###
      ======================================================================

            ssenthilsunw Shanmugam Senthil (Inactive)
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: