| 543 | |
| 544 | #if defined ARCH_WIN |
| 545 | std::string UTF16toUTF8(const std::wstring& w) { |
| 546 | if (w.empty()) |
| 547 | return ""; |
| 548 | // Compute length of output buffer |
| 549 | int len = WideCharToMultiByte(CP_UTF8, 0, &w[0], w.size(), NULL, 0, NULL, NULL); |
| 550 | assert(len > 0); |
| 551 | std::string s; |
| 552 | // Allocate enough space for null character |
| 553 | s.resize(len); |
| 554 | len = WideCharToMultiByte(CP_UTF8, 0, &w[0], w.size(), &s[0], len, 0, 0); |
| 555 | assert(len > 0); |
| 556 | return s; |
| 557 | } |
| 558 | |
| 559 | |
| 560 | std::wstring UTF8toUTF16(const std::string& s) { |
no test coverage detected