cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Santiago Gala <>
Subject Re: 3/1/2001 FOP0.17 Change for OutputStream vs. Writer Fudged Unicode
Date Mon, 26 Mar 2001 08:10:23 GMT
Jay Freeman (saurik) wrote:

> Not only that, but the FO2PDFFormatter change breaks the CVS compile... this
> simple requirement should really be dealt with before checking anything in.
> Time for a good 'ol   cvs update -dP -D 3/24/2001   :).
>     [javac] Compiling 1 source file to
> /www/bin/cvs/xml/xml-cocoon/build/classes
>     [javac]
> /www/bin/cvs/xml/xml-cocoon/build/src/org/apache/cocoon/formatter/FO2PDFForm
> Undefined variable or class name: outputStream
>     [javac]                 stream.write (new String
> (outputStream.toByteArray (), encoding).getBytes ());
>     [javac]                                           ^
>     [javac] 1 error
> Sincerely,
> Jay Freeman (saurik)

A question about this code: What is it trying to do?

outputStream.toByteArray() --> takes out bytes from a stream

new String(outputStream.toByteArray(), encoding) --> decodes these bytes 
using the named encoding (to a String)

new String(outputStream.toByteArray(), encoding).getBytes() --> encodes 
the String back to bytes, using the default (platform dependent !! ) 

stream.write (new String(outputStream.toByteArray(), encoding).getBytes()); --> writes

bytes to another stream
It looks like dangerous code. If the platform encoding is identical to 
the encoding var, it is a (costly) noop. On the other side, this code 
could deliver different results depending wether it is run in a Chinese, 
Russian, Arabic or Western machine, which does not look good.

Looping stream.write( looks better behaviour, but 
maybe I'm wrong. This would leave encoding issues for the final stream.

To unsubscribe, e-mail:
For additional commands, email:

View raw message