-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.0
-
sparc
-
solaris_2.5.1
Name: akC57697 Date: 09/09/98
The java.io.OutputStreamWriter throws CharConversionException
for malformed surrogate pairs in non-8859_1 encodings. See the
evaluation for bug 4167118.
The example:
--------------------------------8-<---------------------------
import java.io.OutputStreamWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
class Test {
public static void main(String[] argv) {
// Tests the handling of a the high word of a character surrogate pair
char chars[] = {'a','\uD80F','x'};
String encodings[]={
"8859_1","8859_2","8859_3","8859_4","8859_5","8859_6","8859_7","8859_8",
"8859_9","Cp1250","Cp1251","Cp1252","Cp1253","Cp1254","Cp1255","Cp1256",
"Cp1257","Cp1258","Cp437","Cp737","Cp775","Cp850","Cp852","Cp855","Cp857",
"Cp860","Cp861","Cp862","Cp863","Cp864","Cp865","Cp866","Cp869","Cp874",
"MacCentralEurope","MacCroatian","MacCyrillic","MacGreek","MacIceland",
"MacRoman","MacRomania","MacThai","MacTurkish","MacUkraine" };
OutputStreamWriter writer = null;
for (int i=0; i<encodings.length; i++) {
try {
writer = new OutputStreamWriter(
new ByteArrayOutputStream( ),encodings[i]);
} catch( UnsupportedEncodingException e ) {
System.out.println(encodings[i]+" "+e);
}
try {
writer.write( chars ); // write chars
System.out.println(encodings[i]+": No IOException");
}
catch( IOException e ) {
System.out.println(encodings[i]+" "+e);
}
finally {
try{
writer.close();
} catch (Exception ex) {}
}
}
System.exit(0);
}
}
--------------------------------8-<---------------------------
java full version "JDK-1.2fcs-I"
Output:
8859_1: No IOException
8859_2 java.io.CharConversionException: Output buffer too small
8859_3 java.io.CharConversionException: Output buffer too small
...same....
======================================================================
- relates to
-
JDK-4176511 Known Incompatibility: Array type now implements serializable and cloneable
- Closed
-
JDK-4172149 java.io.OutputStreamWriter.write not clear about exceptions for malformed surrog
- Resolved