From 9001ca34f73ad861c049f367e2ef8477d19e7432 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Mon, 6 Apr 2015 17:41:33 -0400 Subject: Implemented what we have so far, but on Windows. --- new/util_windows.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 new/util_windows.c (limited to 'new/util_windows.c') diff --git a/new/util_windows.c b/new/util_windows.c new file mode 100644 index 0000000..c3f8971 --- /dev/null +++ b/new/util_windows.c @@ -0,0 +1,18 @@ +// 6 april 2015 +#include "ui_windows.h" + +#define MBTWC(str, wstr, bufsiz) MultiByteToWideChar(CP_UTF8, 0, str, -1, wstr, bufsiz) + +WCHAR *toUTF16(const char *str) +{ + WCHAR *wstr; + int n; + + n = MBTWC(str, NULL, 0); + if (n == 0) + logLastError("error figuring out number of characters to convert to in toUTF16()"); + wstr = (WCHAR *) uiAlloc(n * sizeof (WCHAR)); + if (MBTWC(str, wstr, n) != n) + logLastError("error converting from UTF-8 to UTF-16 in toUTF16()"); + return wstr; +} -- cgit v1.2.3