method
escape
v1_9_2_180 -
Show latest stable
- Class:
URI::Parser
escape(str, unsafe = @regexp[:UNSAFE])public
No documentation available.
# File lib/uri/common.rb, line 214
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