[kaffe] Encoder/Decoder problems

Ito Kazumitsu kaz at maczuka.gcd.org
Tue Oct 5 15:11:51 PDT 2004


>>>>> "I" == Ito Kazumitsu <kaz at maczuka.gcd.org> writes:

I> I have found that this is caused
I> by "java.io.UnsupportedEncodingException: ISO-8859-1"

The following program shows that there is something wrong around ISO-8859-1.

bash-2.05b$ cat TestKaffeEncoding.java 
import java.io.*;

public class TestKaffeEncoding {
    public static void main(String[] args) throws Exception {
        String ienc = args[0];
        String oenc = args[1];

        BufferedReader rdr = new BufferedReader(
            new java.io.InputStreamReader(System.in, ienc));
        PrintWriter wtr = new PrintWriter(
            new java.io.OutputStreamWriter(System.out, oenc));
        while (true) {
            String line = rdr.readLine();
            if (line == null) break;
            wtr.println(line);
        }
    }
}
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding Default Default
abcd
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding US-ASCII US-ASCII
abcd
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding EUC-JP EUC-JP
abcd
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding ISO-8859-1 ISO-8859-1
java.io.UnsupportedEncodingException: ISO-8859-1: ISO-8859-1
   at gnu.java.io.EncodingManager.getDecoder (EncodingManager.java:287)
   at gnu.java.io.EncodingManager.getDecoder (EncodingManager.java:261)
   at java.io.InputStreamReader.<init> (InputStreamReader.java:129)
   at TestKaffeEncoding.main (TestKaffeEncoding.java:9)
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding EUC-JP Default       
abcd
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding EUC-JP US-ASCII
abcd
bash-2.05b$ echo "abcd"| kaffe TestKaffeEncoding EUC-JP ISO-8859-1
java.lang.NullPointerException
   at gnu.java.io.encode.KaffeEncoder.convertToBytes (KaffeEncoder.java:101)
   at gnu.java.io.encode.Encoder.convertToBytes (Encoder.java:192)
   at gnu.java.io.encode.Encoder.setBadCharValue (Encoder.java:316)
   at java.io.OutputStreamWriter.<init> (OutputStreamWriter.java:106)
   at TestKaffeEncoding.main (TestKaffeEncoding.java:11)




More information about the kaffe mailing list