【发布时间】:2014-12-05 21:41:25
【问题描述】:
我目前正在尝试对字符串进行编码以插入 URL。我的问题是,当我的字符串包含反斜杠时,这似乎失败了。到目前为止,我已经使用 URLencode、curlEscape(来自 RCurl)和 curlPercentEncode(来自 RCurl)函数尝试了 4 种方法,但都没有成功。
> URLencode("hello\hello")
Error: '\h' is an unrecognized escape in character string starting ""hello\h"
> curlEscape("hello\hello")
Error: '\h' is an unrecognized escape in character string starting ""hello\h"
> curlPercentEncode("hello\hello")
Error: '\h' is an unrecognized escape in character string starting ""hello\h"
> curlPercentEncode("hello\hello", amp=TRUE)
Error: '\h' is an unrecognized escape in character string starting ""hello\h"
【问题讨论】:
-
你试过
URLencode("hello\\hello")吗?