MCPcopy Create free account
hub / github.com/audacity/audacity / UrlEncode

Function UrlEncode

libraries/lib-string-utils/UrlEncode.cpp:17–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15{
16
17std::string UrlEncode (const std::string_view url)
18{
19 std::string escaped;
20
21 for (char c : url)
22 {
23 if (('0' <= c && c <= '9') ||
24 ('A' <= c && c <= 'Z') ||
25 ('a' <= c && c <= 'z') ||
26 (c == '~' || c == '-' || c == '_' || c == '.')
27 )
28 {
29 escaped.push_back (c);
30 }
31 else
32 {
33 static const char symbolLookup[] = "0123456789ABCDEF";
34
35 escaped.push_back ('%');
36
37 escaped.push_back (symbolLookup[(c & 0xF0) >> 4]);
38 escaped.push_back (symbolLookup[(c & 0x0F) >> 0]);
39 }
40 }
41
42 return escaped;
43}
44
45}

Callers 3

RefreshMethod · 0.85
RefreshMethod · 0.85

Calls 1

push_backMethod · 0.45

Tested by

no test coverage detected