class Nokogiri::HTML4::EncodingReader::SAXHandler

def initialize

def initialize
  @encoding = nil
  super()
end

def start_element(name, attrs = [])

def start_element(name, attrs = [])
  return unless name == "meta"
  attr = Hash[attrs]
  (charset = attr["charset"]) &&
    (@encoding = charset)
  (http_equiv = attr["http-equiv"]) &&
    http_equiv.match(/\AContent-Type\z/i) &&
    (content = attr["content"]) &&
    (m = content.match(/;\s*charset\s*=\s*([\w-]+)/)) &&
    (@encoding = m[1])
end