Strange behaviour of java.nio.charset.StandardCharsets.UTF8.newDecoder()

Martin Buchholz martinrb at google.com
Fri Mar 18 18:44:04 UTC 2016


Coders could have an internal buffer to store incomplete sequences,
but the design is that they don't.
https://docs.oracle.com/javase/8/docs/api/java/nio/charset/CoderResult.html
https://docs.oracle.com/javase/8/docs/api/java/nio/charset/CoderResult.html#UNDERFLOW
It's more efficient to not have (yet another) intermediate buffer.

On Fri, Mar 18, 2016 at 11:38 AM, Pavel Rappo <pavel.rappo at oracle.com> wrote:
> Why is that? I don't think I have to supply only "correct" chunks. After all,
> decoders are free to maintain an internal state needed for this.
>
>> On 18 Mar 2016, at 18:31, Martin Buchholz <martinrb at google.com> wrote:
>>
>> trying to decode one byte at a time, which cannot
>> work?  The minimum unit to decode that will work is 4 bytes
>


More information about the nio-dev mailing list