Module: URI::Escape
- Included in:
- URI
- Defined in:
- lib/uri/common.rb
Instance Method Summary (collapse)
-
- (Object) escape(*arg)
(also: #encode)
Synopsis.
-
- (Object) unescape(*arg)
(also: #decode)
Synopsis.
Instance Method Details
- (Object) escape(*arg) Also known as: encode
Synopsis
URI.escape(str [, unsafe])
Args
str |
String to replaces in. |
unsafe |
Regexp that matches all symbols that must be replaced with codes. By default uses REGEXP::UNSAFE. When this argument is a String, it represents a character set. |
Description
Escapes the string, replacing all unsafe characters with codes.
Usage
require 'uri'
enc_uri = URI.escape("http://example.com/?a=\11\15")
p enc_uri
# => "http://example.com/?a=%09%0D"
p URI.unescape(enc_uri)
# => "http://example.com/?a=\t\r"
p URI.escape("@?@!", "!?")
# => "@%3F@%21"
503 504 505 506 |
# File 'lib/uri/common.rb', line 503 def escape(*arg) warn "#{caller(1)[0]}: warning: URI.escape is obsolete" if $VERBOSE DEFAULT_PARSER.escape(*arg) end |
- (Object) unescape(*arg) Also known as: decode
Synopsis
URI.unescape(str)
Args
str |
Unescapes the string. |
Usage
require 'uri'
enc_uri = URI.escape("http://example.com/?a=\11\15")
p enc_uri
# => "http://example.com/?a=%09%0D"
p URI.unescape(enc_uri)
# => "http://example.com/?a=\t\r"
529 530 531 532 |
# File 'lib/uri/common.rb', line 529 def unescape(*arg) warn "#{caller(1)[0]}: warning: URI.unescape is obsolete" if $VERBOSE DEFAULT_PARSER.unescape(*arg) end |