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 ; }
Fetch charset from Content - Type header value as a char sequence .