Monobjc.Tools.Generator.Parsers.Sgml.HtmlStream.SniffMeta C# (CSharp) Method

SniffMeta() private method

private SniffMeta ( ) : Decoder
return System.Text.Decoder
        internal Decoder SniffMeta()
        {
            int i = this.ReadChar();
            while (i != EOF)
            {
                char ch = (char) i;
                if (ch == '<')
                {
                    string name = this.SniffName();
                    if (name != null && StringUtilities.EqualsIgnoreCase(name, "meta"))
                    {
                        string httpequiv = null;
                        string content = null;
                        while (true)
                        {
                            string value = this.SniffAttribute(out name);
                            if (name == null)
                            {
                                break;
                            }

                            if (StringUtilities.EqualsIgnoreCase(name, "http-equiv"))
                            {
                                httpequiv = value;
                            }
                            else if (StringUtilities.EqualsIgnoreCase(name, "content"))
                            {
                                content = value;
                            }
                        }

                        if (httpequiv != null && StringUtilities.EqualsIgnoreCase(httpequiv, "content-type") && content != null)
                        {
                            int j = content.IndexOf("charset");
                            if (j >= 0)
                            {
                                //charset=utf-8
                                j = content.IndexOf("=", j);
                                if (j >= 0)
                                {
                                    j++;
                                    int k = content.IndexOf(";", j);
                                    if (k < 0)
                                    {
                                        k = content.Length;
                                    }
                                    string charset = content.Substring(j, k - j).Trim();
                                    try
                                    {
                                        Encoding e = Encoding.GetEncoding(charset);
                                        this.m_encoding = e;
                                        return e.GetDecoder();
                                    }
                                    catch (ArgumentException) {}
                                }
                            }
                        }
                    }
                }
                i = this.ReadChar();
            }
            return null;
        }