code: public static CharSequence getCharsetAsSequence(CharSequence contentTypeValue) {
          if (contentTypeValue == null) {
              throw new NullPointerException("contentTypeValue");
          }
  
          int indexOfCharset = AsciiString.indexOfIgnoreCaseAscii(contentTypeValue, CHARSET_EQUALS, 0);
          if (indexOfCharset == AsciiString.INDEX_NOT_FOUND) {
              return null;
          }
  
          int indexOfEncoding = indexOfCharset + CHARSET_EQUALS.length();
          if (indexOfEncoding < contentTypeValue.length()) {
              CharSequence charsetCandidate = contentTypeValue.subSequence(indexOfEncoding, contentTypeValue.length());
              int indexOfSemicolon = AsciiString.indexOfIgnoreCaseAscii(charsetCandidate, SEMICOLON, 0);
              if (indexOfSemicolon == AsciiString.INDEX_NOT_FOUND) {
                  return charsetCandidate;
              }
  
              return charsetCandidate.subSequence(0, indexOfSemicolon);
          }
  
          return null;
      }
docs: Fetch charset from Content-Type header value as a char sequence.
  
  A lot of sites/possibly clients have charset="CHARSET", for example charset="utf-8". Or "utf8" instead of "utf-8"
  This is not according to standard, but this method provide an ability to catch desired mistakes manually in code
  
  @param contentTypeValue Content-Type header value to parse
  @return the {@code CharSequence} with charset from message's Content-Type header
  or {@code null} if charset is not presented
  @throws NullPointerException in case if {@code contentTypeValue == null}