217
217
SetWindowText(SDL_Window, lpszW);
221
* Try loading SetWindowTextW from kernel32.dll first, and if it exists,
222
* pass the UCS-2 string to it. If it doesn't, use
223
* WideCharToMultiByte(CP_ACP) and hope that the codepage can support the
224
* string data in question. This lets us keep binary compatibility with
225
* Win95/98/ME but still use saner Unicode on NT-based Windows.
227
static int tried_loading = 0;
228
static PtrSetWindowTextW swtw = NULL;
229
220
Uint16 *lpsz = SDL_iconv_utf8_ucs2(title);
230
if (!tried_loading) {
231
HMODULE dll = LoadLibrary("user32.dll");
233
swtw = (PtrSetWindowTextW) GetProcAddress(dll, "SetWindowTextW");
242
swtw(SDL_Window, lpsz);
244
size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
245
char *cvt = SDL_malloc(len + 1);
246
WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
247
SetWindowText(SDL_Window, cvt);
221
size_t len = WideCharToMultiByte(CP_ACP, 0, lpsz, -1, NULL, 0, NULL, NULL);
222
char *cvt = SDL_stack_alloc(char, len + 1);
223
WideCharToMultiByte(CP_ACP, 0, lpsz, -1, cvt, len, NULL, NULL);
224
SetWindowText(SDL_Window, cvt);