Code example for Charset

Methods: name

0
 
  protected Charset charset = Charset.forName("UTF-8");
   
  /** @deprecated This field is no longer used. Use {@link #charset} instead. */ 
  @Deprecated 
  protected String charsetName = charset.name();
 
  public IdentityEncoder() { 
  } 
 
  public IdentityEncoder(Charset charset) {
    this.charset = charset;
    // @deprecated, remove this in 4.0: 
    charsetName = charset.name();
  } 
 
 
  public Payload encode(char[] buffer, int offset, int length) {
    final ByteBuffer bb = charset.encode(CharBuffer.wrap(buffer, offset, length));
    if (bb.hasArray()) {
      return new Payload(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining());