Get charset name. If name is null then default charset name provided.

@param charsetName name of charset, can be null
@return charset name, must not be null
@throws IllegalArgumentException if charset name can't be recognized
546646
@Nonnull
  public static String ensureEncodingName(@Nullable final String charsetName) {
    final Charset defaultCharset = Charset.defaultCharset();
    try {
      return (charsetName == null) ? defaultCharset.name() : Charset.forName(charsetName.trim()).name();
    } catch (IllegalCharsetNameException ex) {
      throw new IllegalArgumentException("Can't recognize charset for name '" + charsetName + '\'');
    }
  }
69109
public static String extractCHARSET(String charset){
	    final String arg = charset.replace("@charset","").replace(";","").trim();
	    if (arg.length() > 2)
	        return extractSTRING(arg);
	    else
	        return "";
	}
1250656
def get_charset(self, default: str) -> str:
        """"""
        ctype = self.headers.get(CONTENT_TYPE, '')
        mimetype = parse_mimetype(ctype)
        return mimetype.parameters.get('charset', default)
615347
public void setCharset(String charset) {
	if (StringUtil.isEmpty(charset)) return;
	this.charset = CharsetUtil.toCharSet(charset.trim());
    }
816183
@Nullable
  public static String getCharsetNameFromMimeType (@Nullable final IMimeType aMimeType)
  {
    return aMimeType == null ? null : aMimeType.getParameterValueWithName (CMimeType.PARAMETER_NAME_CHARSET);
  }
669424
protected Charset getCharSet() {
		String contentType = urlConnection.getContentType();
		Charset charset = Charset.forName("iso-8859-1"); // default charset
		if (contentType != null) {
			// find out about the charset from the URLConnection
			Matcher m = charsetPattern.matcher(contentType);
			if (m.find()) {
				String charsetString = m.group(1);
				try {
					charset = Charset.forName(charsetString);
				} catch (IllegalCharsetNameException e) {
					e.printStackTrace();
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				}
			}
		}
		return charset;
	}
488677
@SuppressWarnings("unchecked")
    public String getCharSet() {
        ParameterParser parser = new ParameterParser();
        parser.setLowerCaseNames(true);
        // Parameter parser can handle null input
        Map<String, String> params = parser.parse(getContentType(), ';');
        return params.get("charset");
    }
623282
public static byte[] asBytes(String string, Charset charset)
    {
        if (string == null)
        {
            return null;
        }

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

        try
        {
            return string.getBytes(charset.name());
        }
        catch (UnsupportedEncodingException e)
        {
            //since we are using *actual* charsets, not string lookups, this
            //should *never* happen. But it is better to throw it up than swallow it.
            throw new IllegalStateException("Charset present", e);
        }
    }
485829
public Character getChar(String name) {
        Object o = get(name);
        if (o instanceof Character) {
            return (Character)o;
        }

        if (o != null) {
            String string = o.toString();
            if (string != null && string.length() == 1) {
                return string.charAt(0);
            }
        }
        return null;
    }
705482
public final String getString(String charsetName) {
        if (position >= origin + limit) throw new IllegalArgumentException("limit excceed: " + position);

        byte[] buf = buffer;
        final int len = (0xff & buf[position]);
        if (position + len + 1 > origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                                    + (position + len + 1 - origin));

        try {
            String string = new String(buf, position + 1, len, charsetName);
            position += len + 1;
            return string;
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException("Unsupported encoding: " + charsetName, e);
        }
    }
1320794
public static String getResponseAsString(String uri, String charsetName) {
        return request(new HttpGet(uri), charsetName);
    }
1000986
public static Charset forNameUEE(String charsetName) throws UnsupportedEncodingException {
        try {
            return Charset.forName(charsetName);
        } catch (Exception cause) {
            UnsupportedEncodingException ex = new UnsupportedEncodingException(charsetName);
            ex.initCause(cause);
            throw ex;
        }
    }
617119
public Charset getCharsetProperty(final String name, final Charset defaultValue) {
        final String prop = getStringProperty(name);
        try {
            return prop == null ? defaultValue : Charset.forName(prop);
        } catch (UnsupportedCharsetException e) {
            LowLevelLogUtil.logException("Unable to get Charset '" + name + "', using default " + defaultValue, e);
            return defaultValue;
        }
    }
1105387
public String name() {
    return Charset.isSupported(encoding) ? Charset.forName(encoding).name() : encoding;
  }
307117
public static String request(HttpUriRequest httpUriRequest,
            String charSetName) {
        return request(httpUriRequest, Charset.forName(charSetName));
    }
908799
public Charset readCharset() {
        BasicProperties basicProperties = message.getBasicProperties();
        if (basicProperties == null) {
            return Message.DEFAULT_MESSAGE_CHARSET;
        }
        String contentCharset = basicProperties.getContentEncoding();
        if (contentCharset == null) {
            return Message.DEFAULT_MESSAGE_CHARSET;
        }
        return Charset.forName(contentCharset);
    }
535870
public function charset($charset = null)
    {
        if (!func_num_args()) {
            return $this->_charset;
        }
        $this->_charset = $charset ? strtoupper($charset) : null;
        return $this;
    }