| 339 | } |
| 340 | |
| 341 | wstring 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 | |
| 375 | void DataTree::decodeXMLText(DataNode *elem, const char *src_text, DT_FloatingPointPolicy fpp) { |
| 376 | |