-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from schochastics/URLdecode-speedup
cpp implementation of URLdecode
- Loading branch information
Showing
9 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ Version: 0.1.0.9000 | |
Authors@R: | ||
c(person("David", "Schoch", , "[email protected]", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0003-2952-4812")), | ||
person("Chung-hong", "Chan", role = c("ctb"), email = "[email protected]", | ||
person("Chung-hong", "Chan", role = c("aut"), email = "[email protected]", | ||
comment = c(ORCID = "0000-0002-6232-7530")) | ||
) | ||
Description: A wrapper for ada-url, a WHATWG-compliant and fast URL parser written in modern C++. Also contains auxiliary functions to extract public suffix. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <Rcpp.h> | ||
|
||
using namespace Rcpp; | ||
|
||
//' Function to percent-decode characters in URLs | ||
//' | ||
//' Similar to [utils::URLdecode] | ||
//' | ||
//' @param url a character vector | ||
//' @export | ||
//' @examples | ||
//' url_decode("Hello%20World") | ||
// [[Rcpp::export]] | ||
CharacterVector url_decode(CharacterVector url) { | ||
return sapply(url, [](const String& u) { | ||
std::string input = u; | ||
std::string output; | ||
size_t i = 0; | ||
|
||
while (i < input.length()) { | ||
if (input[i] != '%') { | ||
output += input[i]; | ||
i++; | ||
} else { | ||
unsigned int value; | ||
sscanf(input.substr(i + 1, 2).c_str(), "%x", &value); | ||
output += static_cast<char>(value); | ||
i += 3; | ||
} | ||
} | ||
|
||
return output; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters