curlEscape.RdThese 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.
curlEscape(urls)
curlUnescape(urls)
curlPercentEncode(x, amp = TRUE, codes = PercentCodes, post.amp = FALSE)a character vector giving the strings to be escaped or unescaped.
the strings to be encoded via the percent-encoding method
a logical value indicating whether to encode & characters.
the named character vector giving the encoding map. The names are the characters we encode, the values are what we encode them as.
a logical value controlling whether the resulting string is further processed to escape the percent (%) prefixes with the code for percent, i.e. %25.
This calls curl_escape or curl_unescape in the libcurl library.
A character vector that has corresponding elements to the input with the characters escaped or not.
Curl homepage https://curl.se/
Percent encoding explained in https://en.wikipedia.org/wiki/Percent-encoding
curlEscape("http://www.abc.com?x=a is a sentence&a b=and another")
#> [1] "http%3A%2F%2Fwww.abc.com%3Fx%3Da%20is%20a%20sentence%26a%20b%3Dand%20another"
# Reverse it should get back original
curlUnescape(curlEscape("http://www.abc.com?x=a is a sentence&a b=and another"))
#> [1] "http://www.abc.com?x=a is a sentence&a b=and another"