class Gem::URI::RFC2396_Parser

def escape(str, unsafe = @regexp[:UNSAFE])


replacing them with codes.
Constructs a safe String from +str+, removing unsafe characters,

== Description

Regexp to apply. Defaults to +self.regexp[:UNSAFE]+
+unsafe+::
String to make safe
+str+::

== Args

escape( str, unsafe )
escape( str )
:call-seq:
def escape(str, unsafe = @regexp[:UNSAFE])
  unless unsafe.kind_of?(Regexp)
    # perhaps unsafe is String object
    unsafe = Regexp.new("[#{Regexp.quote(unsafe)}]", false)
  end
  str.gsub(unsafe) do
    us = $&
    tmp = ''
    us.each_byte do |uc|
      tmp << sprintf('%%%02X', uc)
    end
    tmp
  end.force_encoding(Encoding::US_ASCII)
end