utf8_to_utf16: align with libuv

- take a size parameter
- always NUL-terminate the result
- return libuv error code
- handle error in caller only (avoid redundant messages)

53995a3825
4c945f4936
This commit is contained in:
Justin M. Keyes
2019-08-13 05:47:58 +02:00
parent fc60d92795
commit 8727f7a6a4
4 changed files with 47 additions and 51 deletions

View File

@@ -1180,12 +1180,10 @@ char *os_resolve_shortcut(const char *fname)
&IID_IShellLinkW, (void **)&pslw);
if (hr == S_OK) {
wchar_t *p;
const int conversion_result = utf8_to_utf16(fname, &p);
const int conversion_result = utf8_to_utf16(fname, len, &p);
if (conversion_result != 0) {
EMSG2("utf8_to_utf16 failed: %d", conversion_result);
}
if (p != NULL) {
} else if (p != NULL) {
// Get a pointer to the IPersistFile interface.
hr = pslw->lpVtbl->QueryInterface(
pslw, &IID_IPersistFile, (void **)&ppf);