43 |
if (n < 0) |
if (n < 0) |
44 |
return NULL; |
return NULL; |
45 |
|
|
46 |
result = (wchar_t*)malloc ((n+1) * sizeof *result); |
result = new wchar_t[n+1]; |
47 |
if (!result) |
if (!result) |
48 |
BUG (0); |
BUG (0); |
49 |
|
|
50 |
n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n); |
n = MultiByteToWideChar (GetACP (), 0, string, -1, result, n); |
51 |
if (n < 0) { |
if (n < 0) { |
52 |
free (result); |
free_if_alloc (result); |
53 |
return NULL; |
return NULL; |
54 |
} |
} |
55 |
|
|
57 |
if (n < 0) |
if (n < 0) |
58 |
return NULL; |
return NULL; |
59 |
|
|
60 |
native = (char*)malloc (n+1); |
native = new char[n+1]; |
61 |
if (!native) |
if (!native) |
62 |
BUG (0); |
BUG (0); |
63 |
|
|
64 |
n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL); |
n = WideCharToMultiByte (CP_UTF8, 0, result, -1, native, n, NULL, NULL); |
65 |
if (n < 0) { |
if (n < 0) { |
66 |
free (result); |
free_if_alloc (result); |
67 |
return NULL; |
return NULL; |
68 |
} |
} |
69 |
|
|
70 |
free (result); |
free_if_alloc (result); |
71 |
return native; |
return native; |
72 |
} |
} |
73 |
|
|