-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: auR10023 Date: 05/25/2001
OutputStreamWriter.write(char[]) incorrectly writes valid chars in 8859_1
encoding.
Here is the test demonstrating the bug:
import java.io.*;
-----------CharacterEncodingTest01.java----------
public class CharacterEncodingTest01 {
public static void main(String[] args) {
String encoding = args[0];
try {
char chars[] = {
'A', 'B',
'\uFFF0',
'a', 'b'
};
ByteArrayOutputStream baos = new ByteArrayOutputStream( );
OutputStreamWriter writer = new OutputStreamWriter( baos, encoding );
writer.write( chars );
writer.flush();
byte[] bytes = baos.toByteArray();
System.out.println("TO STRING: " + baos.toString());
if( bytes.length < chars.length ) {
System.out.println( "Incorrect number of bytes written: " +
bytes.length );
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
#> java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
#> java -cp . CharacterEncodingTest01 8859_1
TO STRING: AB?b
Incorrect number of bytes written: 4
#> java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
#> java -cp . CharacterEncodingTest01 8859_1
TO STRING: AB?ab
======================================================================
- duplicates
-
JDK-4457851 (cs) JCK13a api/java_io/CharacterEncoding/primarySBCS.html#ISO_8859_1 Solaris sp
- Closed