[R] "Special" characters in URI

Gregor GORJANC gregor.gorjanc at bfro.uni-lj.si
Tue May 3 12:54:09 CEST 2005


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"))
{
  ## 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.
> 

-- 
Lep pozdrav / With regards,
    Gregor Gorjanc

----------------------------------------------------------------------
University of Ljubljana
Biotechnical Faculty        URI: http://www.bfro.uni-lj.si/MR/ggorjan
Zootechnical Department     mail: gregor.gorjanc <at> bfro.uni-lj.si
Groblje 3                   tel: +386 (0)1 72 17 861
SI-1230 Domzale             fax: +386 (0)1 72 17 888
Slovenia, Europe
----------------------------------------------------------------------
"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.




More information about the R-help mailing list