| 3567 | } |
| 3568 | |
| 3569 | static char *wide_to_utf8(const wchar_t *value) { |
| 3570 | if (!value) { |
| 3571 | return NULL; |
| 3572 | } |
| 3573 | int needed = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, value, -1, NULL, 0, NULL, NULL); |
| 3574 | if (needed <= 0) { |
| 3575 | return NULL; |
| 3576 | } |
| 3577 | char *utf8 = malloc((size_t)needed); |
| 3578 | if (!utf8 || WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, value, -1, utf8, needed, NULL, |
| 3579 | NULL) <= 0) { |
| 3580 | free(utf8); |
| 3581 | return NULL; |
| 3582 | } |
| 3583 | return utf8; |
| 3584 | } |
| 3585 | |
| 3586 | static wchar_t *wide_copy(const wchar_t *value) { |
| 3587 | if (!value) { |
no outgoing calls
no test coverage detected