use WIN_StringToUTF8W instead of WIN_StringToUTF8 where needed (#2)

cf. bug #5435.
- SDL_wasapi_win32.c (GetWasapiDeviceName): pwszVal is WCHAR*
- windows/SDL_sysfilesystem.c (SDL_GetBasePath, SDL_GetPrefPath)
- windows/SDL_sysurl.c (SDL_SYS_OpenURL): wurl is WCHAR*
- SDL_windowssensor.c (ConnectSensor): bstr_name is WCHAR*
- windows/SDL_systhread.c (SDL_SYS_SetupThread): strw is WCHAR*
This commit is contained in:
Ozkan Sezer 2021-01-05 15:50:02 +03:00
parent 516042b4d6
commit 265a1cc97a
6 changed files with 10 additions and 11 deletions

View file

@ -79,7 +79,7 @@ GetWasapiDeviceName(IMMDevice *device)
PROPVARIANT var; PROPVARIANT var;
PropVariantInit(&var); PropVariantInit(&var);
if (SUCCEEDED(IPropertyStore_GetValue(props, &SDL_PKEY_Device_FriendlyName, &var))) { if (SUCCEEDED(IPropertyStore_GetValue(props, &SDL_PKEY_Device_FriendlyName, &var))) {
utf8dev = WIN_StringToUTF8(var.pwszVal); utf8dev = WIN_StringToUTF8W(var.pwszVal);
} }
PropVariantClear(&var); PropVariantClear(&var);
IPropertyStore_Release(props); IPropertyStore_Release(props);

View file

@ -93,7 +93,7 @@ SDL_GetBasePath(void)
SDL_assert(i > 0); /* Should have been an absolute path. */ SDL_assert(i > 0); /* Should have been an absolute path. */
path[i+1] = '\0'; /* chop off filename. */ path[i+1] = '\0'; /* chop off filename. */
retval = WIN_StringToUTF8(path); retval = WIN_StringToUTF8W(path);
SDL_free(path); SDL_free(path);
return retval; return retval;
@ -130,13 +130,13 @@ SDL_GetPrefPath(const char *org, const char *app)
return NULL; return NULL;
} }
worg = WIN_UTF8ToString(org); worg = WIN_UTF8ToStringW(org);
if (worg == NULL) { if (worg == NULL) {
SDL_OutOfMemory(); SDL_OutOfMemory();
return NULL; return NULL;
} }
wapp = WIN_UTF8ToString(app); wapp = WIN_UTF8ToStringW(app);
if (wapp == NULL) { if (wapp == NULL) {
SDL_free(worg); SDL_free(worg);
SDL_OutOfMemory(); SDL_OutOfMemory();
@ -181,7 +181,7 @@ SDL_GetPrefPath(const char *org, const char *app)
lstrcatW(path, L"\\"); lstrcatW(path, L"\\");
retval = WIN_StringToUTF8(path); retval = WIN_StringToUTF8W(path);
return retval; return retval;
} }

View file

@ -37,7 +37,7 @@ SDL_SYS_OpenURL(const char *url)
return WIN_SetErrorFromHRESULT("CoInitialize failed", hr); return WIN_SetErrorFromHRESULT("CoInitialize failed", hr);
} }
wurl = WIN_UTF8ToString(url); wurl = WIN_UTF8ToStringW(url);
if (wurl == NULL) { if (wurl == NULL) {
WIN_CoUninitialize(); WIN_CoUninitialize();
return SDL_OutOfMemory(); return SDL_OutOfMemory();

View file

@ -18,8 +18,7 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include <windows.h>
#include <Windows.h>
#include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_windows.h"
#include "../SDL_sysurl.h" #include "../SDL_sysurl.h"
@ -27,7 +26,7 @@
int int
SDL_SYS_OpenURL(const char *url) SDL_SYS_OpenURL(const char *url)
{ {
WCHAR *wurl = WIN_UTF8ToString(url); WCHAR *wurl = WIN_UTF8ToStringW(url);
if (!wurl) { if (!wurl) {
return SDL_OutOfMemory(); return SDL_OutOfMemory();
} }

View file

@ -279,7 +279,7 @@ static int ConnectSensor(ISensor *sensor)
hr = ISensor_GetFriendlyName(sensor, &bstr_name); hr = ISensor_GetFriendlyName(sensor, &bstr_name);
if (SUCCEEDED(hr) && bstr_name) { if (SUCCEEDED(hr) && bstr_name) {
name = WIN_StringToUTF8(bstr_name); name = WIN_StringToUTF8W(bstr_name);
} else { } else {
name = SDL_strdup("Unknown Sensor"); name = SDL_strdup("Unknown Sensor");
} }

View file

@ -170,7 +170,7 @@ SDL_SYS_SetupThread(const char *name)
} }
if (pSetThreadDescription != NULL) { if (pSetThreadDescription != NULL) {
WCHAR *strw = WIN_UTF8ToString(name); WCHAR *strw = WIN_UTF8ToStringW(name);
if (strw) { if (strw) {
pSetThreadDescription(GetCurrentThread(), strw); pSetThreadDescription(GetCurrentThread(), strw);
SDL_free(strw); SDL_free(strw);