'Beautiful Soup can detect a charset included in a META tag,
try to convert the document to that charset, and re-parse the
document from the beginning.'

def start_meta(self, attrs):

    httpEquiv = None
    contentType = None
    contentTypeIndex = None
    tagNeedsEncodingSubstitution = False
    for i in range(0, len(attrs)):
        (key, value) = attrs[i]
        key = key.lower()
        if (key == 'http-equiv'):
            httpEquiv = value
        elif (key == 'content'):
            contentType = value
            contentTypeIndex = i
    if (httpEquiv and contentType):
        match = self.CHARSET_RE.search(contentType)
        if match:
            if ((self.declaredHTMLEncoding is not None) or (self.originalEncoding == self.fromEncoding)):
                def rewrite(match):
                    return (match.group(1) + '%SOUP-ENCODING%')
                newAttr = self.CHARSET_RE.sub(rewrite, contentType)
                attrs[contentTypeIndex] = (attrs[contentTypeIndex][0], newAttr)
                tagNeedsEncodingSubstitution = True
            else:
                newCharset = match.group(3)
                if (newCharset and (newCharset != self.originalEncoding)):
                    self.declaredHTMLEncoding = newCharset
                    self._feed(self.declaredHTMLEncoding)
                    raise StopParsing
                pass
    tag = self.unknown_starttag('meta', attrs)
    if (tag and tagNeedsEncodingSubstitution):
        tag.containsSubstitutions = True
