# File lib/cgi.rb, line 376
  def CGI::unescapeHTML(string)
    enc = string.encoding
    string.gsub(/&(amp|quot|gt|lt|\#[0-9]+|\#x[0-9A-Fa-f]+);/) do
      match = $1.dup
      case match
      when 'amp'                 then '&'
      when 'quot'                then '"'
      when 'gt'                  then '>'
      when 'lt'                  then '<'
      when /\A#0*(\d+)\z/        then
        if Integer($1) < 256
          Integer($1).chr.force_encoding(enc)
        else
          "&##{$1};"
        end
      when /\A#x([0-9a-f]+)\z/i then
        if $1.hex < 256
          $1.hex.chr.force_encoding(enc)
        else
          "&#x#{$1};"
        end
      else
        "&#{match};"
      end
    end
  end