code: public static Charset forName(String charsetName) { // NOPMD
      if (charsetName == null) {
        throw new IllegalArgumentException("Null charset name");
      }
  
      charsetName = charsetName.toUpperCase();
      if (EmulatedCharset.ISO_8859_1.name().equals(charsetName)) {
        return EmulatedCharset.ISO_8859_1;
      } else if (EmulatedCharset.ISO_LATIN_1.name().equals(charsetName)) {
        return EmulatedCharset.ISO_LATIN_1;
      } else if (EmulatedCharset.UTF_8.name().equals(charsetName)) {
        return EmulatedCharset.UTF_8;
      }
  
      if (!charsetName.matches("^[A-Za-z0-9][\\w-:\\.\\+]*$")) { // NOPMD
        throw new IllegalCharsetNameException(charsetName);
      } else {
        throw new UnsupportedCharsetException(charsetName);
      }
    }
docs: get charset for name.
  
  @param charsetName name of the charset
  @return coresponding charset