class Nokogiri::HTML::Document::EncodingReader::SAXHandler

:nodoc:
:nodoc:

def found(encoding)

def found(encoding)
  @encoding = encoding
  throw :found
end

def not_found(encoding)

def not_found(encoding)
  found nil
end

def start_element(name, attrs = [])

def start_element(name, attrs = [])
  case name
  when /\A(?:div|h1|img|p|br)\z/
    not_found
  when 'meta'
    attr = Hash[attrs]
    charset = attr['charset'] and
      found charset
    http_equiv = attr['http-equiv'] and
      http_equiv.match(/\AContent-Type\z/i) and
      content = attr['content'] and
      m = content.match(/;\s*charset\s*=\s*([\w-]+)/) and
      found m[1]
  end
end