windows: fix Unicode function and type inconsistencies

The surrounding code in all of these instances expects the Unicode
variants. Previously, this code mixed Unicode and ANSI/ASCII calls if
`UNICODE` was undefined, which caused type and logic errors. Explicitly
spelling out the W removes any reliance on that macro.
This commit is contained in:
nmlgc
2025-04-12 20:04:27 +02:00
committed by Sam Lantinga
parent d9e58baa6d
commit 37b86a6d2f
8 changed files with 24 additions and 24 deletions

View File

@@ -261,7 +261,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
char *result = NULL;
if (WIN_IsEqualGUID(guid, &nullguid)) {
return WIN_StringToUTF8(name); // No GUID, go with what we've got.
return WIN_StringToUTF8W(name); // No GUID, go with what we've got.
}
ptr = (const unsigned char *)guid;
@@ -270,37 +270,37 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6],
ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]);
strw = WIN_UTF8ToString(keystr);
strw = WIN_UTF8ToStringW(keystr);
rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS);
SDL_free(strw);
if (!rc) {
return WIN_StringToUTF8(name); // oh well.
return WIN_StringToUTF8W(name); // oh well.
}
rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, NULL, &len) == ERROR_SUCCESS);
if (!rc) {
RegCloseKey(hkey);
return WIN_StringToUTF8(name); // oh well.
return WIN_StringToUTF8W(name); // oh well.
}
strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR));
if (!strw) {
RegCloseKey(hkey);
return WIN_StringToUTF8(name); // oh well.
return WIN_StringToUTF8W(name); // oh well.
}
rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, (LPBYTE)strw, &len) == ERROR_SUCCESS);
RegCloseKey(hkey);
if (!rc) {
SDL_free(strw);
return WIN_StringToUTF8(name); // oh well.
return WIN_StringToUTF8W(name); // oh well.
}
strw[len / 2] = 0; // make sure it's null-terminated.
result = WIN_StringToUTF8(strw);
result = WIN_StringToUTF8W(strw);
SDL_free(strw);
return result ? result : WIN_StringToUTF8(name);
return result ? result : WIN_StringToUTF8W(name);
#endif
}