[vlc-commits] commit: Win32: ToWide() converts UTF-8 to UTF-16 ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Thu Jul 22 19:35:15 CEST 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 22 19:53:21 2010 +0300| [e6295d4587187f3b0e2f560ef86dcfc02d5fc0d9] | committer: Rémi Denis-Courmont
Win32: ToWide() converts UTF-8 to UTF-16
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e6295d4587187f3b0e2f560ef86dcfc02d5fc0d9
---
include/vlc_charset.h | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/include/vlc_charset.h b/include/vlc_charset.h
index aaa9d58..8674aee 100644
--- a/include/vlc_charset.h
+++ b/include/vlc_charset.h
@@ -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
/**
More information about the vlc-commits
mailing list