What to do about write(CharBuffer)?
Martin Buchholz
martinrb at google.com
Sun Jun 28 20:33:24 PDT 2009
In the general case, an encoder needs to know whether there is
more input, not just for error detection, but also for
producing the correct output.
If some encoder produced different output for
x
and
x + UMLAUT
then if the last char is 'x' we need some more input
or we need to know that there will be no more.
Again in the general case the encoder will need to
maintain state between encodes of CharBuffers, and the behavior
may be different on the final one.
Martin
On Sun, Jun 28, 2009 at 15:13, Gili <cowwoc at bbs.darktech.org> wrote:
>
> Hi,
>
> As discussed before, I've got a class that reads/writes CharBuffers on top
> of an existing AsynchronousByteChannel. I'd like your opinion on the
> following problem.
>
> When a user writes out a CharBuffer, I use CharsetEncoder.encode() to
> convert it to bytes. The value of CharsetEncoder.encode()'s "endOfInput"
> argument is used to trigger malformed-character errors. It's not clear how
> I'm supposed to know whether I've reach the end of input...
>
> So, does that imply I should change the method signature from
> write(CharBuffer) to write(CharBuffer, endOfInput)?
>
> Thanks,
> Gili
> --
> View this message in context:
> http://n2.nabble.com/What-to-do-about-write%28CharBuffer%29--tp3171370p3171370.html
> Sent from the nio-discuss mailing list archive at Nabble.com.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20090628/ad5beca1/attachment.html
More information about the nio-discuss
mailing list