summaryrefslogtreecommitdiff
path: root/src/openvpnserv/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvpnserv/common.c')
-rw-r--r--src/openvpnserv/common.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/openvpnserv/common.c b/src/openvpnserv/common.c
index dba4724..eafee20 100644
--- a/src/openvpnserv/common.c
+++ b/src/openvpnserv/common.c
@@ -216,3 +216,15 @@ MsgToEventLog (DWORD flags, LPCTSTR format, ...)
return error;
}
+
+/* Convert a utf8 string to utf16. Caller should free the result */
+wchar_t *
+utf8to16 (const char *utf8)
+{
+ int n = MultiByteToWideChar (CP_UTF8, 0, utf8, -1, NULL, 0);
+ wchar_t *utf16 = malloc (n * sizeof (wchar_t));
+ if (!utf16)
+ return NULL;
+ MultiByteToWideChar (CP_UTF8, 0, utf8, -1, utf16, n);
+ return utf16;
+}