Package org.apache.tomcat.util.buf

## Class B2CConverter

- java.lang.Object
- - org.apache.tomcat.util.buf.B2CConverter

    public class B2CConverter
    extends java.lang.Object

NIO based character decoder.

### Field Summary

Fields
`protected static int` `LEFTOVER_SIZE`

### Constructor Summary

Constructors
`B2CConverter​(java.nio.charset.Charset charset)`
`B2CConverter​(java.nio.charset.Charset charset, boolean replaceOnError)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`void` `convert​(java.nio.ByteBuffer bc, java.nio.CharBuffer cc, ByteChunk.ByteInputChannel ic, boolean endOfInput)` Convert the given bytes to characters.
`void` `convert​(ByteChunk bc, CharChunk cc, boolean endOfInput)` Convert the given bytes to characters.
`java.nio.charset.Charset` `getCharset()`
`static java.nio.charset.Charset` `getCharset​(java.lang.String enc)` Obtain the Charset for the given encoding
`static java.nio.charset.Charset` `getCharsetLower​(java.lang.String lowerCaseEnc)` Deprecated. Will be removed in Tomcat 9.0.x
`void` `recycle()` Reset the decoder state.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### LEFTOVER_SIZE

    protected static final int LEFTOVER_SIZE

See Also:
  Constant Field Values

### Constructor Detail

#### B2CConverter

    public B2CConverter​(java.nio.charset.Charset charset)

#### B2CConverter

    public B2CConverter​(java.nio.charset.Charset charset,
                        boolean replaceOnError)

### Method Detail

#### getCharset

    public static java.nio.charset.Charset getCharset​(java.lang.String enc)
                                               throws java.io.UnsupportedEncodingException

Obtain the Charset for the given encoding

Parameters:
  `enc` - The name of the encoding for the required charset
Returns:
  The Charset corresponding to the requested encoding
Throws:
  `java.io.UnsupportedEncodingException` - If the requested Charset is not available

#### getCharsetLower

    @Deprecated
    public static java.nio.charset.Charset getCharsetLower​(java.lang.String lowerCaseEnc)
                                                    throws java.io.UnsupportedEncodingException

Deprecated.
Will be removed in Tomcat 9.0.x
Only to be used when it is known that the encoding name is in lower case.

Parameters:
  `lowerCaseEnc` - The name of the encoding for the required charset in lower case
Returns:
  The Charset corresponding to the requested encoding
Throws:
  `java.io.UnsupportedEncodingException` - If the requested Charset is not available

#### recycle

    public void recycle()

Reset the decoder state.

#### convert

    public void convert​(ByteChunk bc,
                        CharChunk cc,
                        boolean endOfInput)
                 throws java.io.IOException

Convert the given bytes to characters.

Parameters:
  `bc` - byte input
  `cc` - char output
  `endOfInput` - Is this all of the available data
Throws:
  `java.io.IOException` - If the conversion can not be completed

#### convert

    public void convert​(java.nio.ByteBuffer bc,
                        java.nio.CharBuffer cc,
                        ByteChunk.ByteInputChannel ic,
                        boolean endOfInput)
                 throws java.io.IOException

Convert the given bytes to characters.

Parameters:
  `bc` - byte input
  `cc` - char output
  `ic` - byte input channel
  `endOfInput` - Is this all of the available data
Throws:
  `java.io.IOException` - If the conversion can not be completed

#### getCharset

    public java.nio.charset.Charset getCharset()