The R Project SVN R

Rev

Rev 59039 | Rev 67599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/utils/man/URLencode.Rd
2
% Part of the R package, http://www.R-project.org
59039 ripley 3
% Copyright 1995-2008 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
34323 ripley 6
\name{URLencode}
56186 murdoch 7
\alias{URLencode}
34323 ripley 8
\alias{URLdecode}
9
\title{Encode or Decode a (partial) URL}
10
\description{
11
  Functions to encode or decode characters in URLs.
12
}
13
\usage{
34354 maechler 14
URLencode(URL, reserved = FALSE)
34323 ripley 15
URLdecode(URL)
16
}
17
\arguments{
18
  \item{URL}{A character string.}
44184 ripley 19
  \item{reserved}{should reserved characters be encoded?  See
20
    \sQuote{Details}.}
34323 ripley 21
}
22
\details{
34324 ripley 23
  Characters in a URL other than the English alphanumeric characters and
47259 ripley 24
  \samp{$ - _ . + ! * ' ( ) ,} should be encoded as \code{\%}
34324 ripley 25
  plus a two-digit hexadecimal representation, and any single-byte
34340 ripley 26
  character can be so encoded. (Multi-byte characters are encoded as
27
  byte-by-byte.)
34354 maechler 28
 
46945 murdoch 29
  In addition, \samp{; / ? : @ = &} are reserved characters, and should
34323 ripley 30
  be encoded unless used in their reserved sense, which is scheme
34340 ripley 31
  specific.  The default in \code{URLencode} is to leave them alone, which
46945 murdoch 32
  is appropriate for \samp{file://} URLs, but probably not for
33
  \samp{http://} ones.
34323 ripley 34
}
35
\value{
36
  A character string.
37
}
38
\references{
39
  RFC1738, \url{http://www.rfc-editor.org/rfc/rfc1738.txt}
40
}
41
\examples{
34324 ripley 42
(y <- URLencode("a url with spaces and / and @"))
43
URLdecode(y)
61160 ripley 44
(y <- URLencode("a url with spaces and / and @", reserved = TRUE))
34324 ripley 45
URLdecode(y)
34323 ripley 46
URLdecode("ab\%20cd")
47
}
48
\keyword{utilities}