| 306 | } |
| 307 | |
| 308 | std::string Utf16ToUtf8(const std::wstring & wstr) |
| 309 | { |
| 310 | if (wstr.empty()) { |
| 311 | return std::string(); |
| 312 | } |
| 313 | |
| 314 | #ifdef _WIN32 |
| 315 | int sz = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); |
| 316 | std::string str(sz, 0); |
| 317 | WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], sz, NULL, NULL); |
| 318 | return str; |
| 319 | #else |
| 320 | throw Exception("Only supported by the Windows platform."); |
| 321 | #endif |
| 322 | } |
| 323 | |
| 324 | // Here is the explanation of the stat() method: |
| 325 | // https://pubs.opengroup.org/onlinepubs/009695299/basedefs/sys/stat.h.html |