Return a copy of this message protocol with the charset set to the given charset.

@param charset The charset to set.
@return A copy of this message protocol.
178743
public MessageProtocol withCharset(String charset) {
        return new MessageProtocol(contentType, Optional.ofNullable(charset), version);
    }
423491
@Nonnull
  @ReturnsMutableCopy
  public byte [] toByteArray (@Nonnull final Charset aCharset)
  {
    return StringHelper.encodeCharToBytes (m_aBuf, 0, m_nCount, aCharset);
  }
1075149
public static String readToString(InputStream inputStream, Charset charset) throws IOException {
        return new String(FileCopyUtils.copyToByteArray(inputStream), charset);
    }
620485
public void setEncoding(String charset) {
    Validator.validate(!Validator.isBlank(charset), "encoding cannot be blank");
    this.encoding = charset.trim();
  }
1158489
public Response andCharset(String charset) {
        Objects.requireNonNull(charset, Required.CHARSET.toString());
        this.charset = charset;

        return this;
    }
738723
public InterfaceConfigBuilder setMethodsCharset(Charset charset) {
        for (MethodConfigBuilder b : methodBuilders.values()) {
            b.setCharset(charset);
        }
        return this;
    }
1282900
public static String asString(byte[] bytes, Charset charset)
    {
        if (bytes == null)
        {
            return null;
        }

        if (charset == null)
        {
            throw new IllegalArgumentException("Cannot get bytes without a Charset");
        }

        try
        {
            return new String(bytes, charset.name());
        }
        catch (UnsupportedEncodingException e)
        {
            throw new IllegalStateException(charset.name() + " must be present", e);
        }
    }
1263324
public static Charset getCharset(MediaType m) {
        String name = (m == null) ? null : m.getParameters().get(MediaType.CHARSET_PARAMETER);
        try {
            return (name == null) ? Charsets.UTF_8 : Charset.forName(name);
        } catch (Exception e) {
            return Charsets.UTF_8;
        }
    }
172655
public Part<T> charset(Charset charset) {
        requireNonNull(charset);
        return new Part<>(name, fileName, body, contentType, charset, partWriter);
    }
1020696
public static String encode(String source, String charset) {
		return encode(StrUtil.bytes(source, charset), charset);
	}
559835
public function setCharset($charset)
    {
        $prev = $this->charset;

        $charset = strtoupper($charset);
        $charset = null === $charset || 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset;

        $this->charset = $charset;

        return $prev;
    }
1058578
public Charset charset(Charset defaultValue) {
        return charset != null ? Charset.forName(charset) : defaultValue;
    }
1354729
public String readStringNullEnd(final Charset charset) {
    int initialPosition = position;
    int cnt = 0;
    while (remaining() > 0 && (buf[position++] != 0)) {
      cnt++;
    }
    return new String(buf, initialPosition, cnt, charset);
  }
1254423
public RawResponse charset(Charset charset) {
        return new RawResponse(method, url, statusCode, statusLine, cookies, headers, body, charset, decompress);
    }
259797
public String getString(String charset) {
    try {
      return new String(getBytes(), charset);
    }
    catch (UnsupportedEncodingException e) {
      throw new IllegalStateException(e.getMessage());
    }
  }
637718
public Charset getCharset() {
		Charset charset = null;
		final String charsetName = getCharsetName();
		if (StrUtil.isNotBlank(charsetName)) {
			try {
				charset = Charset.forName(charsetName);
			} catch (UnsupportedCharsetException e) {
				// ignore
			}
		}
		return charset;
	}
1057695
private static CharsetDecoder getDecoder(Charset charset)
    {
        if (charset == null) {
            throw new NullPointerException("charset");
        }

        Map<Charset, CharsetDecoder> map = decoders.get();
        CharsetDecoder d = map.get(charset);
        if (d != null) {
            d.reset();
            d.onMalformedInput(CodingErrorAction.REPLACE);
            d.onUnmappableCharacter(CodingErrorAction.REPLACE);
            return d;
        }

        d = charset.newDecoder();
        d.onMalformedInput(CodingErrorAction.REPLACE);
        d.onUnmappableCharacter(CodingErrorAction.REPLACE);
        map.put(charset, d);
        return d;
    }