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 - ###@###.###
======================================================================
- duplicates
-
JDK-4070242 CharToByte conversion fails for the encoding of Big5
-
- Closed
-