| 18 | #pragma comment(lib, "Shlwapi.lib") |
| 19 | |
| 20 | std::wstring utf8_to_windows(const std::string & str) |
| 21 | { |
| 22 | if (!str.size()) return {}; |
| 23 | auto l = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), static_cast<int>(str.size()), nullptr, 0); |
| 24 | if (l == 0) throw std::invalid_argument("string cannot be converted to utf8: " + str); |
| 25 | std::wstring win(l, ' '); |
| 26 | ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.data(), static_cast<int>(str.size()), &win[0], static_cast<int>(win.size())); |
| 27 | return win; |
| 28 | } |
| 29 | |
| 30 | // Adapted from https://github.com/sgorsten/editor/blob/master/src/editor/xplat.h |
| 31 | std::string windows_file_dialog(const std::string & filter_type, const std::string & extension, bool must_exist) |
no test coverage detected