Fixed bug #139
authorSam Lantinga <slouken@libsdl.org>
Mon, 13 Mar 2006 01:33:58 +0000
changeset 15054d005dfbb7f5
parent 1504 7b4b31075f67
child 1506 dc057a602e98
Fixed bug #139
The text in SDL_WM_SetCaption() is in UTF-8 encoding.
include/SDL_video.h
src/video/wincommon/SDL_sysevents.c
src/video/wincommon/SDL_syswm.c
src/video/x11/SDL_x11wm.c
     1.1 --- a/include/SDL_video.h	Mon Mar 13 01:20:05 2006 +0000
     1.2 +++ b/include/SDL_video.h	Mon Mar 13 01:33:58 2006 +0000
     1.3 @@ -818,7 +818,7 @@
     1.4  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
     1.5  
     1.6  /*
     1.7 - * Sets/Gets the title and icon text of the display window
     1.8 + * Sets/Gets the title and icon text of the display window (UTF-8 encoded)
     1.9   */
    1.10  extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon);
    1.11  extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon);
     2.1 --- a/src/video/wincommon/SDL_sysevents.c	Mon Mar 13 01:20:05 2006 +0000
     2.2 +++ b/src/video/wincommon/SDL_sysevents.c	Mon Mar 13 01:33:58 2006 +0000
     2.3 @@ -762,13 +762,9 @@
     2.4  	if ( name ) {
     2.5  #ifdef _WIN32_WCE
     2.6  		/* WinCE uses the UNICODE version */
     2.7 -		size_t nLen = SDL_strlen(name)+1;
     2.8 -		SDL_Appname = SDL_malloc(nLen*2);
     2.9 -		MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen);
    2.10 +		SDL_Appname = SDL_iconv_utf8_ucs2(name);
    2.11  #else
    2.12 -		size_t nLen = SDL_strlen(name)+1;
    2.13 -		SDL_Appname = SDL_malloc(nLen);
    2.14 -		SDL_strlcpy(SDL_Appname, name, nLen);
    2.15 +		SDL_Appname = SDL_iconv_utf8_latin1(name);
    2.16  #endif /* _WIN32_WCE */
    2.17  		SDL_Appstyle = style;
    2.18  		SDL_Instance = hInst ? hInst : SDL_GetModuleHandle();
     3.1 --- a/src/video/wincommon/SDL_syswm.c	Mon Mar 13 01:20:05 2006 +0000
     3.2 +++ b/src/video/wincommon/SDL_syswm.c	Mon Mar 13 01:33:58 2006 +0000
     3.3 @@ -230,12 +230,13 @@
     3.4  {
     3.5  #ifdef _WIN32_WCE
     3.6  	/* WinCE uses the UNICODE version */
     3.7 -	int nLen = SDL_strlen(title)+1;
     3.8 -	LPWSTR lpszW = alloca(nLen*2);
     3.9 -	MultiByteToWideChar(CP_ACP, 0, title, -1, lpszW, nLen);
    3.10 +	LPWSTR lpszW = SDL_iconv_utf8_ucs2(title);
    3.11  	SetWindowText(SDL_Window, lpszW);
    3.12 +	SDL_free(lpszW);
    3.13  #else
    3.14 -	SetWindowText(SDL_Window, title);
    3.15 +	char *lpsz = SDL_iconv_utf8_latin1(title);
    3.16 +	SetWindowText(SDL_Window, lpsz);
    3.17 +	SDL_free(lpsz);
    3.18  #endif
    3.19  }
    3.20  
     4.1 --- a/src/video/x11/SDL_x11wm.c	Mon Mar 13 01:20:05 2006 +0000
     4.2 +++ b/src/video/x11/SDL_x11wm.c	Mon Mar 13 01:33:58 2006 +0000
     4.3 @@ -255,8 +255,13 @@
     4.4  				&titleprop);
     4.5  #endif
     4.6  		if ( error != Success ) {
     4.7 -			pXStringListToTextProperty((char **)&title, 1,
     4.8 -					&titleprop);
     4.9 +			char *title_latin1 = SDL_iconv_utf8_latin1((char *)title);
    4.10 +			if ( !title_latin1 ) {
    4.11 +				SDL_OutOfMemory();
    4.12 +				return;
    4.13 +			}
    4.14 +			pXStringListToTextProperty(&title_latin1, 1, &titleprop);
    4.15 +			SDL_free(title_latin1);
    4.16  		}
    4.17  		pXSetWMName(SDL_Display, WMwindow, &titleprop);
    4.18  		pXFree(titleprop.value);
    4.19 @@ -268,7 +273,13 @@
    4.20  				(char **)&icon, 1, XUTF8StringStyle, &iconprop);
    4.21  #endif
    4.22  		if ( error != Success ) {
    4.23 -			pXStringListToTextProperty((char **)&icon, 1, &iconprop);
    4.24 +			char *icon_latin1 = SDL_iconv_utf8_latin1((char *)title);
    4.25 +			if ( !icon_latin1 ) {
    4.26 +				SDL_OutOfMemory();
    4.27 +				return;
    4.28 +			}
    4.29 +			pXStringListToTextProperty(&icon_latin1, 1, &iconprop);
    4.30 +			SDL_free(icon_latin1);
    4.31  		}
    4.32  		pXSetWMIconName(SDL_Display, WMwindow, &iconprop);
    4.33  		pXFree(iconprop.value);