class Nokogiri::HTML::Document

def meta_encoding= encoding

content tag, nil is returned and the encoding is not set.
Set the meta tag encoding for this document. If there is no meta
##
def meta_encoding= encoding
  return nil unless meta = css('meta').find { |node|
    node['http-equiv'] =~ /Content-Type/i
  }
  meta['content'] = "text/html; charset=%s" % encoding
  encoding
end