小编sfa*_*zio的帖子

如何使用 R/RCurl 对反斜杠进行 URL 编码

我目前正在尝试对字符串进行编码以插入到 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"
Run Code Online (Sandbox Code Playgroud)

r urlencode rcurl

2
推荐指数
1
解决办法
3万
查看次数

标签 统计

r ×1

rcurl ×1

urlencode ×1