/**
   * Write a portion of an array of characters.
   *
   * @param cbuf Array of characters
   * @param off Offset from which to start writing characters
   * @param len Number of characters to write
   * @throws java.io.IOException If an I/O error occurs
   */
  public void write(final char[] cbuf, final int off, final int len) throws IOException {
    text = Utf16LE.getInstance().decode(cbuf, off, len, text);
    if (buffer != null) {
      buffer.setCursor(0);
    }

    if (errorType == null) {
      buffer = encoding.encode(text, buffer);
    } else {
      buffer = encoding.encode(text, buffer, errorType);
    }

    outputStream.write(buffer.getData(), buffer.getOffset(), buffer.getLength());
  }