comparison: ui/winui/util.cpp
ui/winui/util.cpp
- branch
- newapi
- changeset 180
- f34953bf4ac7
- child 192
- bcacd00ea955
equal
deleted
inserted
replaced
|
1 |
|
2 |
|
3 #include "util.h" |
|
4 |
|
5 #include <stdlib.h> |
|
6 |
|
7 #include <Windows.h> |
|
8 |
|
9 |
|
10 wchar_t* str2wstr(const char* str, int* newlen) { |
|
11 size_t len = strlen(str); |
|
12 |
|
13 |
|
14 wchar_t* wstr = (wchar_t*)calloc(len + 1, sizeof(wchar_t)); |
|
15 int wlen = MultiByteToWideChar( |
|
16 CP_UTF8, |
|
17 0, |
|
18 str, |
|
19 len, |
|
20 wstr, |
|
21 len + 1 |
|
22 ); |
|
23 if (newlen) { |
|
24 *newlen = wlen; |
|
25 } |
|
26 wstr[wlen] = 0; |
|
27 |
|
28 return wstr; |
|
29 } |