ui/winui/util.cpp

branch
newapi
changeset 192
bcacd00ea955
parent 180
f34953bf4ac7
child 205
b1ac0dd1d38b
--- a/ui/winui/util.cpp	Sun Oct 01 17:22:17 2023 +0200
+++ b/ui/winui/util.cpp	Sun Oct 01 18:54:23 2023 +0200
@@ -26,4 +26,20 @@
     wstr[wlen] = 0;
 
     return wstr;
-}
\ No newline at end of file
+}
+
+char* wchar2utf8(const wchar_t* wstr, size_t wlen) {
+    size_t maxlen = wlen * 4;
+    char* ret = (char*)malloc(maxlen + 1);
+    int ret_len = WideCharToMultiByte(
+        CP_UTF8,
+        0,
+        wstr,
+        wlen,
+        ret,
+        maxlen,
+        NULL,
+        NULL);
+    ret[ret_len] = 0;
+    return ret;
+}

mercurial