Create process with wide chars on Windows
Windows does not support UTF-8, so pushing a file with non-ASCII characters failed. Convert the UTF-8 command line to a wide characters string and call CreateProcessW(). Fixes <https://github.com/Genymobile/scrcpy/issues/422>
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# include <tchar.h>
|
||||
#endif
|
||||
|
||||
size_t xstrncpy(char *dest, const char *src, size_t n) {
|
||||
size_t i;
|
||||
for (i = 0; i < n - 1 && src[i] != '\0'; ++i)
|
||||
@@ -47,3 +52,22 @@ char *strquote(const char *src) {
|
||||
quoted[len + 2] = '\0';
|
||||
return quoted;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
wchar_t *utf8_to_wide_char(const char *utf8) {
|
||||
int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
|
||||
if (!len) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wchar_t *wide = malloc(len * sizeof(wchar_t));
|
||||
if (!wide) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wide, len);
|
||||
return wide;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user