Skip to content
Permalink
Browse files

Fixed bug #139

The text in SDL_WM_SetCaption() is in UTF-8 encoding.
  • Loading branch information
slouken committed Mar 13, 2006
1 parent 9120aff commit 844c38838501d727259ec0c8600c1e99cfc26b67
Showing with 22 additions and 14 deletions.
  1. +1 −1 include/SDL_video.h
  2. +2 −6 src/video/wincommon/SDL_sysevents.c
  3. +5 −4 src/video/wincommon/SDL_syswm.c
  4. +14 −3 src/video/x11/SDL_x11wm.c
@@ -818,7 +818,7 @@ extern DECLSPEC void SDLCALL SDL_GL_Unlock(void);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
* Sets/Gets the title and icon text of the display window
* Sets/Gets the title and icon text of the display window (UTF-8 encoded)
*/
extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon);
extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
@@ -762,13 +762,9 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
if ( name ) {
#ifdef _WIN32_WCE
/* WinCE uses the UNICODE version */
size_t nLen = SDL_strlen(name)+1;
SDL_Appname = SDL_malloc(nLen*2);
MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
SDL_Appname = SDL_iconv_utf8_ucs2(name);
#else
size_t nLen = SDL_strlen(name)+1;
SDL_Appname = SDL_malloc(nLen);
SDL_strlcpy(SDL_Appname, name, nLen);
SDL_Appname = SDL_iconv_utf8_latin1(name);
#endif /* _WIN32_WCE */
SDL_Appstyle = style;
SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
@@ -230,12 +230,13 @@ void WIN_SetWMCaption(_THIS, const char *title, const char *icon)
{
#ifdef _WIN32_WCE
/* WinCE uses the UNICODE version */
int nLen = SDL_strlen(title)+1;
LPWSTR lpszW = alloca(nLen*2);
MultiByteToWideChar(CP_ACP, 0, title, -1, lpszW, nLen);
LPWSTR lpszW = SDL_iconv_utf8_ucs2(title);
SetWindowText(SDL_Window, lpszW);
SDL_free(lpszW);
#else
SetWindowText(SDL_Window, title);
char *lpsz = SDL_iconv_utf8_latin1(title);
SetWindowText(SDL_Window, lpsz);
SDL_free(lpsz);
#endif
}

@@ -255,8 +255,13 @@ void X11_SetCaption(_THIS, const char *title, const char *icon)
&titleprop);
#endif
if ( error != Success ) {
pXStringListToTextProperty((char **)&title, 1,
&titleprop);
char *title_latin1 = SDL_iconv_utf8_latin1((char *)title);
if ( !title_latin1 ) {
SDL_OutOfMemory();
return;
}
pXStringListToTextProperty(&title_latin1, 1, &titleprop);
SDL_free(title_latin1);
}
pXSetWMName(SDL_Display, WMwindow, &titleprop);
pXFree(titleprop.value);
@@ -268,7 +273,13 @@ void X11_SetCaption(_THIS, const char *title, const char *icon)
(char **)&icon, 1, XUTF8StringStyle, &iconprop);
#endif
if ( error != Success ) {
pXStringListToTextProperty((char **)&icon, 1, &iconprop);
char *icon_latin1 = SDL_iconv_utf8_latin1((char *)title);
if ( !icon_latin1 ) {
SDL_OutOfMemory();
return;
}
pXStringListToTextProperty(&icon_latin1, 1, &iconprop);
SDL_free(icon_latin1);
}
pXSetWMIconName(SDL_Display, WMwindow, &iconprop);
pXFree(iconprop.value);

0 comments on commit 844c388

Please sign in to comment.