You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Rafal Krzewski <Ra...@e-point.pl> on 2000/09/10 23:56:27 UTC
WebMacro Fastwriter
This should actualy go to WebMacro list, but sice I'm not
subscribed there, and I knonw that Justin and other WM
developers read this list, so I posted it here. Sorry...
I have a problem with FastWriter. I'm trying to capture
the output of template rendering into a String.
// template & wc are set up earlier
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
FastWriter fw = new FastWriter(bytes, "UTF-8");
template.write(fw, wc);
fw.flush();
String results = bytes.toString("UTF-8");
And the above code works fine... AFAIK Java uses two byte
UTF-16BE format internally. Therefore, for minimal
performance loss, I should use this encoding for the byte
stream. Unfortunately, when changing the encoding to
UTF-16BE I get lots of ? characters instead of most of
the text, and when using UTF-16 encoding I get no output
at all (bytes.size() tells that there are bytes in the
buffer though, but somehow they don't translate into
Unicode characters).
Is this a bug? Or am I doing something wrong? Maybe there
is another way of (fast) capturing WM output into a String?
Rafal