MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / wsDecode

Method wsDecode

src/util/DataTree.cpp:341–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341wstring DataTree::wsDecode(const string& str) {
342
343 std::stringstream decStream;
344 std::stringstream mbstr;
345 unsigned int x;
346
347 string decStr = str;
348 std::replace( decStr.begin(), decStr.end(), '%', ' ');
349 decStream << trim(decStr);
350
351 string sResult;
352
353 //this actually assume we will get as many char as wchar_t from the decodes string,
354 //who cares ?
355 size_t maxLen = decStr.length();
356
357 //wchar_t is typically 16 bits on windows, and 32 bits on Unix, so use sizeof(wchar_t) everywhere.
358 auto *wc_str = (wchar_t *) ::calloc(maxLen + 1, sizeof(wchar_t));
359
360 while (!decStream.eof()) {
361 decStream >> std::hex >> x;
362 //extract actually 2 hex-chars by 2 hex-chars to form a char value.
363 mbstr << (unsigned char) x;
364 }
365
366 ::mbstowcs(wc_str, mbstr.str().c_str(), maxLen);
367
368 wstring result(wc_str);
369
370 ::free(wc_str);
371
372 return result;
373}
374
375void DataTree::decodeXMLText(DataNode *elem, const char *src_text, DT_FloatingPointPolicy fpp) {
376

Callers

nothing calls this directly

Calls 3

c_strMethod · 0.80
trimFunction · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected