The R Project SVN R

Rev

Rev 67898 | Rev 68447 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 67898 Rev 67899
Line 9... Line 9...
9
\title{Encode or Decode a (partial) URL}
9
\title{Encode or Decode a (partial) URL}
10
\description{
10
\description{
11
  Functions to encode or decode characters in URLs.
11
  Functions to encode or decode characters in URLs.
12
}
12
}
13
\usage{
13
\usage{
14
URLencode(URL, reserved = FALSE)
14
URLencode(URL, reserved = FALSE, repeated = FALSE)
15
URLdecode(URL)
15
URLdecode(URL)
16
}
16
}
17
\arguments{
17
\arguments{
18
  \item{URL}{A character string.}
18
  \item{URL}{a character string.}
19
  \item{reserved}{should reserved characters be encoded?  See
19
  \item{reserved}{logical: should \sQuote{reserved} characters be
20
    \sQuote{Details}.}
20
    encoded? See \sQuote{Details}.}
-
 
21
  \item{repeated}{logical: should apparently already-encoded URLs be
-
 
22
    encoded again?}
21
}
23
}
22
\details{
24
\details{
23
  Characters in a URL other than the English alphanumeric characters and
25
  Characters in a URL other than the English alphanumeric characters and
24
  \samp{- _ . ~} should be encoded as \code{\%}
26
  \samp{- _ . ~} should be encoded as \code{\%}
25
  plus a two-digit hexadecimal representation, and any single-byte
27
  plus a two-digit hexadecimal representation, and any single-byte
Line 30... Line 32...
30
  characters, and should be encoded unless used in their reserved sense,
32
  characters, and should be encoded unless used in their reserved sense,
31
  which is scheme specific.  The default in \code{URLencode} is to leave
33
  which is scheme specific.  The default in \code{URLencode} is to leave
32
  them alone, which is appropriate for \samp{file://} URLs, but probably
34
  them alone, which is appropriate for \samp{file://} URLs, but probably
33
  not for \samp{http://} ones.
35
  not for \samp{http://} ones.
34
 
36
 
35
  \code{URLencode} will encode further the \code{\%} characters in an
37
  An \sQuote{apparently already-encoded URL} is one containing
36
  already-encoded URL. 
38
  \code{\%xx} for two hexadecimal digits.
37
}
39
}
38
\value{
40
\value{
39
  A character string.
41
  A character string.
40
}
42
}
41
\references{
43
\references{
Line 44... Line 46...
44
\examples{
46
\examples{
45
(y <- URLencode("a url with spaces and / and @"))
47
(y <- URLencode("a url with spaces and / and @"))
46
URLdecode(y)
48
URLdecode(y)
47
(y <- URLencode("a url with spaces and / and @", reserved = TRUE))
49
(y <- URLencode("a url with spaces and / and @", reserved = TRUE))
48
URLdecode(y)
50
URLdecode(y)
-
 
51
 
49
URLdecode("ab\%20cd")
52
URLdecode(z <- "ab\%20cd")
-
 
53
c(URLencode(z), URLencode(z, repeated = TRUE)) # first is usually wanted
50
}
54
}
51
\keyword{utilities}
55
\keyword{utilities}