MCPcopy Create free account
hub / github.com/NativeScript/android / percent_encode

Function percent_encode

test-app/runtime/src/main/cpp/ada/ada.cpp:10866–10890  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10864}
10865
10866std::string percent_encode(const std::string_view input,
10867 const uint8_t character_set[]) {
10868 auto pointer = std::ranges::find_if(input, [character_set](const char c) {
10869 return character_sets::bit_at(character_set, c);
10870 });
10871 // Optimization: Don't iterate if percent encode is not required
10872 if (pointer == input.end()) {
10873 return std::string(input);
10874 }
10875
10876 std::string result;
10877 result.reserve(input.length()); // in the worst case, percent encoding might
10878 // produce 3 characters.
10879 result.append(input.substr(0, std::distance(input.begin(), pointer)));
10880
10881 for (; pointer != input.end(); pointer++) {
10882 if (character_sets::bit_at(character_set, *pointer)) {
10883 result.append(character_sets::hex + uint8_t(*pointer) * 4, 3);
10884 } else {
10885 result += *pointer;
10886 }
10887 }
10888
10889 return result;
10890}
10891
10892template <bool append>
10893bool percent_encode(const std::string_view input, const uint8_t character_set[],

Callers 9

update_base_searchMethod · 0.85
to_stringMethod · 0.85
parse_opaque_hostMethod · 0.85
set_usernameMethod · 0.85
set_passwordMethod · 0.85
set_hashMethod · 0.85
set_searchMethod · 0.85
parse_url_implFunction · 0.85

Calls 8

bit_atFunction · 0.85
appendMethod · 0.65
clearMethod · 0.65
endMethod · 0.45
reserveMethod · 0.45
lengthMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected