[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/26220] New: InputStreamReader(, CharSet) creates broken
From: |
andy dot seaborne at hp dot com |
Subject: |
[Bug classpath/26220] New: InputStreamReader(, CharSet) creates broken reader |
Date: |
11 Feb 2006 10:35:33 -0000 |
Setup: ikvm 0.24.0.1 (as JVM), Java 1.4.2_10
Of the three constructors for InputStreamReader that allow the app to set
the Charset, the one where the Charset is passed directly does not give a
Reader that can read the data.
Charset cs = Charset.forName("utf-8");
new InputStreamReader(ins, cs.newDecoder()); // Works
new InputStreamReader(ins, "utf-8"); // Works
new InputStreamReader(ins, cs); // Does not work
The test program should print 104 each time but does not do so in the third
case. Workaround: use the constructor with cs.newDecoder().
Couldn't find a bug like this in bugzilla - apologies if it is a duplicate.
Andy
Test program:
public static void main(String[] argv)
{
System.out.println("<<<<<<<<<<<<<<<");
try {
Charset cs = Charset.forName("utf-8");
{
ByteArrayInputStream ins = new ByteArrayInputStream("hello
world".getBytes()) ;
Reader r = new InputStreamReader(ins, cs.newDecoder());
System.out.println("With decoder: .read() =>
"+r.read()) ;
}
System.out.println("---------------");
// ----
{
ByteArrayInputStream ins = new ByteArrayInputStream("hello
world".getBytes()) ;
Reader r = new InputStreamReader(ins, "utf-8");
System.out.println("With charset name: .read() =>
"+r.read()) ;
}
System.out.println("---------------");
// ----
{
ByteArrayInputStream ins = new ByteArrayInputStream("hello
world".getBytes()) ;
Reader r = new InputStreamReader(ins, cs);
System.out.println("With charset object: .read() =>
"+r.read()) ;
}
} catch (Exception ex)
{
System.err.println("IO exception: "+ex.getMessage()) ;
}
System.out.println(">>>>>>>>>>>>>>>");
}
--
Summary: InputStreamReader(,CharSet) creates broken reader
Product: classpath
Version: 0.20
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: classpath
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andy dot seaborne at hp dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26220
- [Bug classpath/26220] New: InputStreamReader(, CharSet) creates broken reader,
andy dot seaborne at hp dot com <=
- [Bug classpath/26220] InputStreamReader(, CharSet) creates broken reader, andy dot seaborne at hp dot com, 2006/02/11
- [Bug classpath/26220] InputStreamReader(, CharSet) creates broken reader, jeroen at frijters dot net, 2006/02/12
- [Bug classpath/26220] InputStreamReader(, CharSet) creates broken reader, jeroen at frijters dot net, 2006/02/12
- [Bug classpath/26220] InputStreamReader(, CharSet) creates broken reader, cvs-commit at developer dot classpath dot org, 2006/02/12