Search code examples
javanio

What Charset does ByteBuffer.asCharBuffer() use?


What Charset does ByteBuffer.asCharBuffer() use? It seems to convert 3 bytes to one character on my system.

On a related note, how does CharsetDecoder relate to ByteBuffer.asCharBuffer()?

UPDATE: With respect to what implementation of ByteBuffer I am using, I am invoking ByteBuffer.allocate(1024).asCharBuffer(). I can't comment on what implementation gets used under the hood.


Solution

  • For the first question - I believe it uses native character encoding of Java (UTF-16).