java.io.OutputStreamWriter: too small buffer

Edouard G. Parmelan Edouard.Parmelan at quadratec.fr
Wed Mar 1 02:57:13 PST 2000


ito at htk.hitachi-cable.co.jp wrote:

> The output buffer of java.io.OutputStreamWriter is too small to
> safely run XT, the XSLT processor.  The following error occurs
> when processing a XML document containing Japanese characters:
> 
> And enlarging the buffer, that is, applying the following
> patch to OutputStreamWriter.java helps solve this problem
> although this is nothing but a workaround.

Could you try the following more general patch ?
-- 
Edouard G. Parmelan
http://egp.free.fr
-------------- next part --------------
Index: libraries/javalib/kaffe/io/CharToByteUTF8.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/kaffe/io/CharToByteUTF8.java,v
retrieving revision 1.1
diff -u -r1.1 CharToByteUTF8.java
--- libraries/javalib/kaffe/io/CharToByteUTF8.java	1999/10/09 20:10:10	1.1
+++ libraries/javalib/kaffe/io/CharToByteUTF8.java	2000/03/01 10:38:42
@@ -21,16 +21,25 @@
 	int i = fpos;
 	int ie = fpos + flen;
 
-	for (; i < ie && o < oe; i++) {
+	for (; i < ie; i++) {
                 char chr = from[i];
                 if (chr >= '\u0001' && chr <= '\u007F') {
+			if (o >= oe) {
+				break;
+			}
 			to[o++] = (byte)chr;
 		}
                 else if (chr <= '\u07FF') {
+			if (o + 1 >= oe) {
+				break;
+			}
                         to[o++] = (byte)(0xC0 | (0x3F & (chr >> 6)));
                         to[o++] = (byte)(0x80 | (0x3F & chr));
                 }
                 else {
+			if (o + 2 >= oe) {
+				break;
+			}
                         to[o++] = (byte)(0xE0 | (0x0F & (chr >> 12)));
                         to[o++] = (byte)(0x80 | (0x3F & (chr >>  6)));
                         to[o++] = (byte)(0x80 | (0x3F & chr));


More information about the kaffe mailing list