java.io.OutputStreamWriter: too small buffer
Edouard G. Parmelan
kaffe@rufus.w3.org
Wed, 1 Mar 2000 11:57:13 +0100
--TB36FDmn/VVEgNH/
Content-Type: text/plain; charset=us-ascii
ito@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
--TB36FDmn/VVEgNH/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kaffe-utf.diff"
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));
--TB36FDmn/VVEgNH/--