Re: [R] "Special" characters in URI

From: Henrik Bengtsson <hb_at_maths.lth.se>
Date: Tue 03 May 2005 - 21:40:49 EST

Gregor GORJANC wrote:
> Prof Brian Ripley wrote:
>

>>On Tue, 3 May 2005, Gorjanc Gregor wrote:
>>
>>
>>>I am crossposting this to R-help and BioC, since it is relevant to both
>>>groups.
>>
>>I don't see the relevance to R-help.  But the answer to your subject is

>
> Is it more rellevant for R-devel?
>
>
>>unambiguous: valid URLs do not contain `special' characters -- they must
>>be encoded.  See RFC1738 at e.g. ftp://ftp.funet.fi/pub/doc/rfc/rfc1738.txt

>
> Yes, I understand that completely and I just wanted to know how other
> handle or have solved this issue. Having this in mind I am looking forward
> to your 'filePathToURL' function. Do you have any scratches of it already?
> What do you think about this scratch, which afcourse doesn't solve all
> "special" characters:
>
> fixURLchar <- function(URL,
> from = c(" ", "\"", ",", "#"),
> to = c("%20", "%22", "%2c", "%23"))

Just a comment. It is much safer/easier to use named vectors for mapping, e.g.

  map <- c(" "="%20", "\""="%22", ","="%2c", "#"="%23")

/Henrik

> {
> ## Checks
> if (length(from) != length(to))
> stop("Length of 'from' and 'to' must be the same")
>
> ## Core
> for (i in seq(along=from)) {
> URL <- gsub(pattern=from[i], replacement=to[i], x=URL)
> }
>
> return(URL)
> }
>
>
>

>>At some point (probably 2.2.0) I intend to ensure that the mapping to
>>file:// URLs that is done is a few places is encoded as necessary.  This
>>will likely result in a utility function filePathToURL or some such.
>>

>

>

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 03 21:49:29 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:32 EST