kaffe.io.ByteToCharIconv makes wrong results
Ito Kazumitsu
kaffe@rufus.w3.org
Mon, 3 Sep 2001 15:24:50 +0900
kaffe.io.ByteToCharIconv seems to make wrong results.
I use kaffe-snap-20010819. In my environment, libiconv was not
automatically taken into kaffe, so I did the following:
Afer ./configure, I edited config/config.h to add "#define HAVE_ICONV 1"
and edited libraries/clib/native/Makefile to add "-liconv" to LIBS.
Here is a simple program for testing.
import java.io.*;
public class TestIconv {
public static void main(String[] args) {
try {
String from = args[0];
InputStreamReader reader = new InputStreamReader(System.in, from);
char[] cbuf = new char[1024];
int l;
while ((l = reader.read(cbuf,0,cbuf.length)) >= 0) {
for(int i = 0; i < l; i++) {
System.out.print(cbuf[i]);
}
}
System.out.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
}
And here are the results of this program.
$ echo "aaaa" | kaffe TestIconv US-ASCII |od -xc
0000000 6161 0000 0000
a a \0 \0 \0 \0
0000005
$ echo "aaaa" | kaffe TestIconv EUC-JP |od -xc
0000000 6161 0000 0000
a a \0 \0 \0 \0
0000005
$ echo "aaaa" | kaffe TestIconv ASCII |od -xc
0000000 6161 6161 000a
a a a a \n \0
0000005
$ echo "aaaa" | kaffe TestIconv EUC_JP |od -xc
0000000 6161 6161 000a
a a a a \n \0
0000005
$
In the former two cases, kaffe.io.ByteToCharIconv must have been
used to handle such encodings as "US-ASCII" and "EUC-JP". And
the results are wrong.
In the latter two cases, kaffe.io.ByteToCharASCII and
kaffe.io.ByteToCharEUC_JP must have been used. And the results
are satisfactory.
This comparison makes me think there is some problem around
kaffe.io.ByteToCharIconv.