MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / wstr_to_str

Function wstr_to_str

components/windows/src/context.cpp:48–62  ·  view source on GitHub ↗

@brief Converts wstring to string using Windows specific function @param wstr Wide string to convert @return A converted utf8 string

Source from the content-addressed store, hash-verified

46/// @param wstr Wide string to convert
47/// @return A converted utf8 string
48inline std::string wstr_to_str(const std::wstring &wstr)
49{
50 if (wstr.empty())
51 {
52 return {};
53 }
54
55 auto wstr_len = static_cast<int>(wstr.size());
56 auto str_len = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr_len, NULL, 0, NULL, NULL);
57
58 std::string str(str_len, 0);
59 WideCharToMultiByte(CP_UTF8, 0, &wstr[0], wstr_len, &str[0], str_len, NULL, NULL);
60
61 return str;
62}
63
64inline std::vector<std::string> get_args()
65{

Callers 1

get_argsFunction · 0.85

Calls 2

emptyMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected