--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/winui/util.cpp Tue May 23 14:19:06 2023 +0200 @@ -0,0 +1,29 @@ + + +#include "util.h" + +#include <stdlib.h> + +#include <Windows.h> + + +wchar_t* str2wstr(const char* str, int* newlen) { + size_t len = strlen(str); + + + wchar_t* wstr = (wchar_t*)calloc(len + 1, sizeof(wchar_t)); + int wlen = MultiByteToWideChar( + CP_UTF8, + 0, + str, + len, + wstr, + len + 1 + ); + if (newlen) { + *newlen = wlen; + } + wstr[wlen] = 0; + + return wstr; +} \ No newline at end of file