[topic] URL特殊文字のエスケープ
Posted feedbacks - R
CGIwithRというライブラリーにアンエスケープの関数はあったのですが、
エスケープする関数はないようです。
> escape("~url quote/ほげ")
[1] "%7eurl%20quote%2f%82%d9%82%b0"
1 2 3 4 5 | escape <- function(str){
paste(sapply(unlist(strsplit(str, "")),
function(s){ifelse((regexpr("\\W", s, perl=TRUE)[1] > 0),
paste("%", charToRaw(s), collapse="", sep=""), s)}), collapse="")
}
|


にしお
#4156()
Rating0/0=0.00
URL用に特殊な文字をエスケープする。
[ reply ]