Mercurial > trustbridge
comparison common/strhelp.c @ 1158:ffdc8cba139a
(issue36) Add acp_to_wchar based on utf8_to_wchar
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 18 Sep 2014 15:43:48 +0200 |
parents | 698b6a9bd75e |
children |
comparison
equal
deleted
inserted
replaced
1157:fd7d04bb37cb | 1158:ffdc8cba139a |
---|---|
279 return NULL; | 279 return NULL; |
280 } | 280 } |
281 result[n] = 0; | 281 result[n] = 0; |
282 return result; | 282 return result; |
283 } | 283 } |
284 | |
285 wchar_t | |
286 *acp_to_wchar (const char *string, size_t len) | |
287 { | |
288 int n, ilen; | |
289 wchar_t *result; | |
290 | |
291 ilen = (int) len; | |
292 if (ilen < 0) | |
293 return NULL; | |
294 | |
295 n = MultiByteToWideChar (CP_ACP, 0, string, ilen, NULL, 0); | |
296 if (n < 0 || n + 1 < 0) | |
297 return NULL; | |
298 | |
299 result = xmalloc ((size_t)(n+1) * sizeof *result); | |
300 n = MultiByteToWideChar (CP_ACP, 0, string, ilen, result, n); | |
301 if (n < 0) | |
302 { | |
303 xfree (result); | |
304 return NULL; | |
305 } | |
306 result[n] = 0; | |
307 return result; | |
308 } | |
284 #endif | 309 #endif |