Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed Oct 2, 2024
1 parent 4ea8b54 commit 2711b94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main(int argc, argv_t* argv[]) {
int wsize = 0;

struct M3U8DownloadedStreams downloaded_streams = {0};

fprintf("%i\n", "00000");
#if defined(_WIN32) && defined(_UNICODE)
wio_setunicode();
#endif
Expand Down
31 changes: 17 additions & 14 deletions src/wio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,49 +20,52 @@ int wio_printf(const char* const format, ...) {
wsize = vsnprintf(NULL, 0, format, list);

if (wsize < 0) {
return wsize;
wsize = -1;
goto end;
}

value = malloc((size_t) wsize + 1);

if (value == NULL) {
return -1;
wsize = -1;
goto end;
}

wsize = vsnprintf(value, (size_t) wsize + 1, format, list);

if (wsize < 0) {
free(value);
return wsize;
wsize = -1;
goto end;
}

va_end(list);

wsize = MultiByteToWideChar(CP_UTF8, 0, value, -1, NULL, 0);

if (wsize == 0) {
return -1;
wsize = -1;
goto end;
}

wvalue = malloc((size_t) wsize);

if (wvalue == NULL) {
free(value);
return -1;
wsize = -1;
goto end;
}

if (MultiByteToWideChar(CP_UTF8, 0, value, -1, wvalue, wsize) == 0) {
free(value);
free(wvalue);
return -1;
wsize = -1;
goto end;
}

free(value);

wsize = wprintf(L"%ls", wvalue);

end:;

free(value);
free(wvalue);

va_end(list);

return wsize;

}
Expand Down

0 comments on commit 2711b94

Please sign in to comment.