B2CConverter (Apache Tomcat 10.1.57 API Documentation)
Description: declaration: package: org.apache.tomcat.util.buf, class: B2CConverter

# Class B2CConverter

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

public class B2CConverter extends Object
NIO based character decoder.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected static final int`
  `LEFTOVER_SIZE`
  Maximum size for leftover bytes used for incomplete characters during decoding.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `B2CConverter(Charset charset)`
  Constructs a B2CConverter for the given charset, reporting errors on malformed input.
  `B2CConverter(Charset charset, boolean replaceOnError)`
  Deprecated.
  Unused.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `convert(ByteBuffer bc, 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.
  `Charset`
  `getCharset()`
  Returns the charset used by this converter.
  `static Charset`
  `getCharset(String enc)`
  Obtain the Charset for the given encoding
  `void`
  `recycle()`
  Reset the decoder state.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### LEFTOVER_SIZE

    protected static final int LEFTOVER_SIZE
    Maximum size for leftover bytes used for incomplete characters during decoding.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### B2CConverter

    public B2CConverter(Charset charset)
    Constructs a B2CConverter for the given charset, reporting errors on malformed input.
    Parameters:
      `charset` - the charset to use for decoding

  - ### B2CConverter

    @Deprecated public B2CConverter(Charset charset, boolean replaceOnError)
    Deprecated.
    Unused. Will be removed in Tomcat 12 onwards. Use `B2CConverter(Charset)`
    Constructs a B2CConverter for the given charset.
    Parameters:
      `charset` - the charset to use for decoding
      `replaceOnError` - if `true`, replace malformed/unmappable input; otherwise report errors

- ## Method Details

  - ### getCharset

    public static Charset getCharset(String enc) throws 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:
      `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 IOException
    Convert the given bytes to characters.
    Parameters:
      `bc` - byte input
      `cc` - char output
      `endOfInput` - Is this all of the available data
    Throws:
      `IOException` - If the conversion can not be completed

  - ### convert

    public void convert(ByteBuffer bc, CharBuffer cc, ByteChunk.ByteInputChannel ic, boolean endOfInput) throws 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:
      `IOException` - If the conversion can not be completed

  - ### getCharset

    public Charset getCharset()
    Returns the charset used by this converter.
    Returns:
      the charset