]> git.sesse.net Git - vlc/commitdiff
Win32: ToWide() converts UTF-8 to UTF-16
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 22 Jul 2010 16:53:21 +0000 (19:53 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 22 Jul 2010 16:53:21 +0000 (19:53 +0300)
include/vlc_charset.h

index aaa9d58a6526d891d5a8cd10524a7debd10b24dd..8674aeed8e2b446657f5f7345f43b13f7990e9b9 100644 (file)
@@ -54,10 +54,24 @@ static inline char *FromWide (const wchar_t *wide)
 
     char *out = (char *)malloc (len);
 
-    if (out)
+    if (likely(out))
         WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
     return out;
 }
+
+LIBVLC_USED
+static inline wchar_t *ToWide (const char *utf8)
+{
+    int len = MultiByteToWideChar (CP_UTF8, 0, utf8, -1, NULL, 0);
+    if (len == 0)
+        return NULL;
+
+    wchar_t *out = (wchar_t *)malloc (len * sizeof (wchar_t));
+
+    if (likely(out))
+        MultiByteToWideChar (CP_UTF8, 0, utf8, -1, out, len);
+    return out;
+}
 #endif
 
 /**