Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

curlEscape

Handle characters in URL that need to be escaped


Description

These functions convert between URLs that are human-readable and those that have special characters escaped. For example, to send a URL with a space, we need to represent the space as %20.

curlPercentEncode uses a different format than the curlEscape function and this is needed for x-www-form-encoded POST submissions.

Usage

curlEscape(urls)
curlUnescape(urls)
curlPercentEncode(x, amp = TRUE, codes = PercentCodes, post.amp = FALSE)

Arguments

urls

a character vector giving the strings to be escaped or unescaped.

x

the strings to be encoded via the percent-encoding method

amp

a logical value indicating whether to encode \& characters.

codes

the named character vector giving the encoding map. The names are the characters we encode, the values are what we encode them as.

post.amp

a logical value controlling whether the resulting string is further processed to escape the percent (%) prefixes with the code for percent, i.e. %25.

Details

This calls curl_escape or curl_unescape in the libcurl library.

Value

A character vector that has corresponding elements to the input with the characters escaped or not.

Author(s)

Duncan Temple Lang

References

Curl homepage http://curl.haxx.se

Percent encoding explained in http://en.wikipedia.org/wiki/Percent-encoding

Examples

curlEscape("http://www.abc.com?x=a is a sentence&a b=and another")

  # Reverse it should get back original
  curlUnescape(curlEscape("http://www.abc.com?x=a is a sentence&a b=and another"))

RCurl

General Network (HTTP/FTP/...) Client Interface for R

v1.98-1.3
BSD_3_clause + file LICENSE
Authors
CRAN Team [ctb, cre] (de facto maintainer since 2013), Duncan Temple Lang [aut] (<https://orcid.org/0000-0003-0159-1546>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.