2015-04-06 16:41:33 -05:00
|
|
|
// 6 april 2015
|
2015-04-06 23:26:27 -05:00
|
|
|
#include "uipriv_windows.h"
|
2015-04-06 16:41:33 -05:00
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|