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

Method wsEncode

src/util/DataTree.cpp:318–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318string DataTree::wsEncode(const wstring& wstr) {
319 stringstream encStream;
320
321 //wchar_t is typically 16 bits on windows, and 32 bits on Unix, so use sizeof(wchar_t) everywhere.
322 size_t bufSizeBytes = (wstr.length()+1) * sizeof(wchar_t);
323
324 char *data_str = (char *)calloc(bufSizeBytes, sizeof(char));
325
326 wcstombs(data_str, wstr.c_str(), bufSizeBytes - sizeof(wchar_t));
327
328 std::string byte_str(data_str);
329
330 free(data_str);
331
332 encStream << std::hex;
333
334 for(char & i : byte_str) {
335 encStream << '%' << setfill('0') << (unsigned int)((unsigned char)i);
336 }
337
338 return encStream.str();
339}
340
341wstring DataTree::wsDecode(const string& str) {
342

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected