Exemple #1
0
        /// <summary>Parse out a charset from a content type header.</summary>
        /// <remarks>
        /// Parse out a charset from a content type header. If the charset is not supported, returns null (so the default
        /// will kick in.)
        /// </remarks>
        /// <param name="contentType">e.g. "text/html; charset=EUC-JP"</param>
        /// <returns>"EUC-JP", or null if not found. Charset is trimmed and uppercased.</returns>
        internal static String GetCharsetFromContentType(String contentType)
        {
            if (contentType == null)
            {
                return(null);
            }
            Match m = iText.IO.Util.StringUtil.Match(charsetPattern, contentType);

            if (PortUtil.IsSuccessful(m))
            {
                String charset = iText.IO.Util.StringUtil.Group(m, 1).Trim();
                charset = charset.Replace("charset=", "");
                return(ValidateCharset(charset));
            }
            return(null);
        }