CharToByteUTF8.java loses some characters

ito at htk.hitachi-cable.co.jp ito at htk.hitachi-cable.co.jp
Fri Mar 3 03:03:21 PST 2000


In message "Re: java.io.OutputStreamWriter: too small buffer"
    on 00/03/02, ito at htk.hitachi-cable.co.jp <ito at htk.hitachi-cable.co.jp> writes:

> In message "Re: java.io.OutputStreamWriter: too small buffer"
>     on 00/03/01, "Edouard G. Parmelan" <Edouard.Parmelan at quadratec.fr> writes:
> 
> > Could you try the following more general patch ?
> 
> This patch worked fine. Tank you.

I am afraid that patch is not enough to make CharToByteUTF8.java
work fine.

Please see the attached files.

When I run 

   $ java Test test05in test05out

I expect that 512 characters should be written to test05out.
But test05out has only 341 Japanese characters (1023 bytes). 

   $ ls -al test05in test05out
   -rw-rw-r--   1 ito      ito            13 Mar  3 19:13 test05in
   -rw-rw-r--   1 ito      ito          1023 Mar  3 19:44 test05out

Attached files are here.

$ cat Test.java
import java.io.*;
public class Test {
    public static void main(String[] args) {
        try {
            char[] cbuf = new char[512];
            InputStreamReader in
                = new InputStreamReader(new FileInputStream(args[0]),"UTF8");
            OutputStreamWriter out
                = new OutputStreamWriter(new FileOutputStream(args[1]), "UTF8");
            int l = in.read(cbuf,0,cbuf.length);
            if (l > 0) {
               l--;  // chop off the line feed
               System.err.println(l + " characters");
               int i = 0;
               int j = l;
               while(j < cbuf.length) {
                  cbuf[j++] = cbuf[i++];
               }
            }
            out.write(cbuf,0,cbuf.length);
            in.close();
            out.close();
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }
}
$ mmencode -b < test05in
5LyK6Jek5LiA5YWJCg==
$ mmencode -b < test05out
5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6Jek
5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ
5LyK6Jek5LiA5YWJ5LyK6Jek5LiA5YWJ5LyK6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