MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / utf8_to_windows

Function utf8_to_windows

libraries/lib-polymer/src/util-win32.cpp:20–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#pragma comment(lib, "Shlwapi.lib")
19
20std::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
31std::string windows_file_dialog(const std::string & filter_type, const std::string & extension, bool must_exist)

Callers 2

windows_file_dialogFunction · 0.85
file_existsFunction · 0.85

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected