| 1 |
\name{curlEscape} |
| 2 |
\alias{curlEscape} |
| 3 |
\alias{curlUnescape} |
| 4 |
\alias{curlPercentEncode} |
| 5 |
\title{Handle characters in URL that need to be escaped} |
| 6 |
\description{ |
| 7 |
These functions convert between URLs that are |
| 8 |
human-readable and those that have special characters |
| 9 |
escaped. For example, to send a URL with a space, |
| 10 |
we need to represent the space as \code{\%20}. |
| 11 |
|
| 12 |
\code{curlPercentEncode} uses a different format than the |
| 13 |
\code{curlEscape} |
| 14 |
function and this is needed for x-www-form-encoded POST submissions. |
| 15 |
} |
| 16 |
\usage{ |
| 17 |
curlEscape(urls) |
| 18 |
curlUnescape(urls) |
| 19 |
curlPercentEncode(x, amp = TRUE, codes = PercentCodes, post.amp = FALSE) |
| 20 |
} |
| 21 |
%- maybe also 'usage' for other objects documented here. |
| 22 |
\arguments{ |
| 23 |
\item{urls}{ a character vector giving the strings to be escaped or |
| 24 |
unescaped.} |
| 25 |
\item{x}{the strings to be encoded via the percent-encoding method} |
| 26 |
\item{amp}{a logical value indicating whether to encode & |
| 27 |
characters.} |
| 28 |
\item{codes}{the named character vector giving the encoding map. The |
| 29 |
names are the characters we encode, the values are what we encode them |
| 30 |
as.} |
| 31 |
\item{post.amp}{a logical value controlling whether the resulting |
| 32 |
string is further processed to escape the percent (\%) prefixes with |
| 33 |
the code for percent, i.e. \%25.} |
| 34 |
} |
| 35 |
\details{ |
| 36 |
This calls \code{curl_escape} or \code{curl_unescape} in the libcurl library. |
| 37 |
} |
| 38 |
\value{ |
| 39 |
A character vector that has corresponding elements |
| 40 |
to the input with the characters escaped or not. |
| 41 |
} |
| 42 |
\references{ |
| 43 |
Curl homepage \url{https://curl.se/} |
| 44 |
|
| 45 |
Percent encoding explained in \url{https://en.wikipedia.org/wiki/Percent-encoding} |
| 46 |
} |
| 47 |
\author{Duncan Temple Lang} |
| 48 |
|
| 49 |
\examples{ |
| 50 |
curlEscape("http://www.abc.com?x=a is a sentence&a b=and another") |
| 51 |
|
| 52 |
# Reverse it should get back original |
| 53 |
curlUnescape(curlEscape("http://www.abc.com?x=a is a sentence&a b=and another")) |
| 54 |
} |
| 55 |
\keyword{IO} |
| 56 |
|
| 57 |
|