MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / URLEncode

Function URLEncode

cpp/src/platform/HttpClient.cpp:332–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332void URLEncode
333(
334const std::string& s,
335std::string& enc
336)
337{
338 const size_t len = s.length();
339 char buf[3];
340 buf[0] = '%';
341 for(size_t i = 0; i < len; i++)
342 {
343 const unsigned char c = s[i];
344 // from https://www.ietf.org/rfc/rfc1738.txt, page 3
345 // with some changes for compatibility
346 if(isalnum(c) || c == '-' || c == '_' || c == '.' || c == ',')
347 enc += (char)c;
348 else if(c == ' ')
349 enc += '+';
350 else
351 {
352 unsigned nib = (c >> 4) & 0xf;
353 buf[1] = nib < 10 ? '0' + nib : 'a' + (nib-10);
354 nib = c & 0xf;
355 buf[2] = nib < 10 ? '0' + nib : 'a' + (nib-10);
356 enc.append(&buf[0], 3);
357 }
358 }
359}
360
361static bool _SetNonBlocking
362(

Callers 1

HttpClient.cppFile · 0.85

Calls 1

lengthMethod · 0.45

Tested by

no test coverage detected