true if RUBY_VERSION is 1.9.0 or later
contains encoding error classes to raise
default mime type data for Page::Image#mime_type. You can use another Apache-compatible mimetab.
mimetab = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types') Mechanize::Util::DefaultMimeTypes.replace(mimetab)
# File lib/mechanize/util.rb, line 30 30: def self.build_query_string(parameters, enc=nil) 31: parameters.map { |k,v| 32: # WEBrick::HTTP.escape* has some problems about m17n on ruby-1.9.*. 33: [CGI.escape(k.to_s), CGI.escape(v.to_s)].join("=") if k 34: }.compact.join('&') 35: end
# File lib/mechanize/util.rb, line 78 78: def self.detect_charset(src) 79: case enc = src && NKF.guess(src) 80: when Integer 81: # Ruby <= 1.8 82: CODE_DIC[enc] 83: else 84: # Ruby >= 1.9 85: enc && enc.to_s.upcase 86: end || "ISO-8859-1" 87: end
Converts string s from code to UTF-8.
# File lib/mechanize/util.rb, line 38 38: def self.from_native_charset(s, code, ignore_encoding_error=false, log=nil) 39: return s unless s && code 40: return s unless Mechanize.html_parser == Nokogiri::HTML 41: 42: begin 43: encode_to(code, s) 44: rescue *ENCODING_ERRORS => ex 45: log.debug("from_native_charset: #{ex.class}: form encoding: #{code.inspect} string: #{s}") if log 46: if ignore_encoding_error 47: s 48: else 49: raise 50: end 51: end 52: end
# File lib/mechanize/util.rb, line 64 64: def self.html_unescape(s) 65: return s unless s 66: s.gsub(/&(\w+|#[0-9]+);/) { |match| 67: number = case match 68: when /&(\w+);/ 69: Mechanize.html_parser::NamedCharacters[$1] 70: when /&#([0-9]+);/ 71: $1.to_i 72: end 73: 74: number ? ([number].pack('U') rescue match) : match 75: } 76: end
# File lib/mechanize/util.rb, line 89 89: def self.uri_escape str, unsafe = nil 90: @parser ||= begin 91: URI::Parser.new 92: rescue NameError 93: URI 94: end 95: 96: if URI == @parser then 97: unsafe ||= URI::UNSAFE 98: else 99: unsafe ||= @parser.regexp[:UNSAFE] 100: end 101: 102: @parser.escape str, unsafe 103: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.