MCPcopy Create free account
hub / github.com/arvidn/libtorrent / escape_string_impl

Function escape_string_impl

src/escape_string.cpp:141–164  ·  view source on GitHub ↗

the offset is used to ignore the first characters in the unreserved_chars table.

Source from the content-addressed store, hash-verified

139
140 // the offset is used to ignore the first characters in the unreserved_chars table.
141 std::string escape_string_impl(const char* str, int const len, int const offset)
142 {
143 TORRENT_ASSERT(str != nullptr);
144 TORRENT_ASSERT(len >= 0);
145 TORRENT_ASSERT(offset >= 0);
146 TORRENT_ASSERT(offset < int(sizeof(unreserved_chars)) - 1);
147
148 std::string ret;
149 for (int i = 0; i < len; ++i)
150 {
151 if (std::strchr(unreserved_chars + offset, *str) && *str != 0)
152 {
153 ret += *str;
154 }
155 else
156 {
157 ret += '%';
158 ret += aux::hex_chars[std::uint8_t(*str) >> 4];
159 ret += aux::hex_chars[std::uint8_t(*str) & 15];
160 }
161 ++str;
162 }
163 return ret;
164 }
165
166 } // anonymous namespace
167

Callers 2

escape_stringFunction · 0.85
escape_pathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected