Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中的URL编码-给出不同的结果?_R_Url_Encoding - Fatal编程技术网

R中的URL编码-给出不同的结果?

R中的URL编码-给出不同的结果?,r,url,encoding,R,Url,Encoding,我在韩国报纸网站上做网页抓取,但我在处理url编码方面遇到了麻烦。原来的关键字是“실업률"(失业率),首先我尝试使用[URLencode]和[curlsecve]函数(即url_keyTaking)실 (U+C2E4),我们看到它的UTF-8值是0xEC 0x8B 0xA4(3个字节)。这与预期的URL编码相匹配。看来您的错误结果是由另一个字符集(EUC-KR?)引起的我不知道韩语中的刮码,但您看过rvest包吗?您能发布sessionInfo的输出吗()?当我执行URLencode(“실업률“

我在韩国报纸网站上做网页抓取,但我在处理url编码方面遇到了麻烦。原来的关键字是“실업률"(失业率),首先我尝试使用[URLencode]和[curlsecve]函数(即url_keyTaking)실 (U+C2E4),我们看到它的UTF-8值是
0xEC 0x8B 0xA4
(3个字节)。这与预期的URL编码相匹配。看来您的错误结果是由另一个字符集(EUC-KR?)引起的

我不知道韩语中的刮码,但您看过
rvest
包吗?您能发布
sessionInfo的输出吗()
?当我执行
URLencode(“실업률“
在我的macOS系统上,它返回为“
%EC%8B%A4%EC%97%85%EB%A5%A0
”@AmitKohli谢谢。我会试试的。@hrbrmstr谢谢。我添加了它。我不确定这是否有效(我无法将我的区域设置设置为您的),但请尝试:
使用r::with_locale(c(LC_CTYPE=“c”,LC_COLLATE=“c”),URLencode(”실업률)你的提示解决了我的问题!我发现我的默认编码是“cp949”,还有两行,ff
R version 3.2.4 (2016-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949   
[3] LC_MONETARY=Korean_Korea.949 LC_NUMERIC=C                
[5] LC_TIME=Korean_Korea.949    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] RCurl_1.95-4.8 bitops_1.0-6   plyr_1.8.4     stringr_1.1.0 
[5] XML_3.98-1.4  

loaded via a namespace (and not attached):
[1] magrittr_1.5  tools_3.2.4   Rcpp_0.12.7   stringi_1.1.2