Fixed bug #447
Xlib uses the native locale, not latin1 ... the question is... what does the server use? :) --HG-- branch : SDL-1.2 extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402407
This commit is contained in:
parent
13be73d999
commit
6450125a74
3 changed files with 35 additions and 10 deletions
|
@ -584,8 +584,7 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, siz
|
||||||
string that must be freed with SDL_free() or NULL on error.
|
string that must be freed with SDL_free() or NULL on error.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft);
|
extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft);
|
||||||
#define SDL_iconv_utf8_ascii(S) SDL_iconv_string("646", "UTF-8", S, SDL_strlen(S)+1)
|
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
|
||||||
#define SDL_iconv_utf8_latin1(S) SDL_iconv_string("8859-1", "UTF-8", S, SDL_strlen(S)+1)
|
|
||||||
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
|
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
|
||||||
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
|
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
|
||||||
|
|
||||||
|
|
|
@ -772,6 +772,26 @@ int SDL_iconv_close(SDL_iconv_t cd)
|
||||||
|
|
||||||
#endif /* !HAVE_ICONV */
|
#endif /* !HAVE_ICONV */
|
||||||
|
|
||||||
|
static const char *getlocale()
|
||||||
|
{
|
||||||
|
const char *lang;
|
||||||
|
|
||||||
|
lang = SDL_getenv("LC_ALL");
|
||||||
|
if ( !lang ) {
|
||||||
|
lang = SDL_getenv("LC_CTYPE");
|
||||||
|
}
|
||||||
|
if ( !lang ) {
|
||||||
|
lang = SDL_getenv("LC_MESSAGES");
|
||||||
|
}
|
||||||
|
if ( !lang ) {
|
||||||
|
lang = SDL_getenv("LANG");
|
||||||
|
}
|
||||||
|
if ( !lang || SDL_strcmp(lang, "C") == 0 ) {
|
||||||
|
lang = "ASCII";
|
||||||
|
}
|
||||||
|
return lang;
|
||||||
|
}
|
||||||
|
|
||||||
char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
|
char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
|
||||||
{
|
{
|
||||||
SDL_iconv_t cd;
|
SDL_iconv_t cd;
|
||||||
|
@ -781,6 +801,12 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||||
size_t outbytesleft;
|
size_t outbytesleft;
|
||||||
size_t retCode = 0;
|
size_t retCode = 0;
|
||||||
|
|
||||||
|
if ( !fromcode || !*fromcode ) {
|
||||||
|
fromcode = getlocale();
|
||||||
|
}
|
||||||
|
if ( !tocode || !*tocode ) {
|
||||||
|
tocode = getlocale();
|
||||||
|
}
|
||||||
cd = SDL_iconv_open(tocode, fromcode);
|
cd = SDL_iconv_open(tocode, fromcode);
|
||||||
if ( cd == (SDL_iconv_t)-1 ) {
|
if ( cd == (SDL_iconv_t)-1 ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -257,13 +257,13 @@ void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( title != NULL ) {
|
if ( title != NULL ) {
|
||||||
char *title_latin1 = SDL_iconv_utf8_latin1((char *)title);
|
char *title_locale = SDL_iconv_utf8_locale(title);
|
||||||
if ( !title_latin1 ) {
|
if ( !title_locale ) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
status = XStringListToTextProperty(&title_latin1, 1, &titleprop);
|
status = XStringListToTextProperty(&title_locale, 1, &titleprop);
|
||||||
SDL_free(title_latin1);
|
SDL_free(title_locale);
|
||||||
if ( status ) {
|
if ( status ) {
|
||||||
XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
|
XSetTextProperty(SDL_Display, WMwindow, &titleprop, XA_WM_NAME);
|
||||||
XFree(titleprop.value);
|
XFree(titleprop.value);
|
||||||
|
@ -280,13 +280,13 @@ void X11_SetCaptionNoLock(_THIS, const char *title, const char *icon)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if ( icon != NULL ) {
|
if ( icon != NULL ) {
|
||||||
char *icon_latin1 = SDL_iconv_utf8_latin1((char *)icon);
|
char *icon_locale = SDL_iconv_utf8_locale(icon);
|
||||||
if ( !icon_latin1 ) {
|
if ( !icon_locale ) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
status = XStringListToTextProperty(&icon_latin1, 1, &iconprop);
|
status = XStringListToTextProperty(&icon_locale, 1, &iconprop);
|
||||||
SDL_free(icon_latin1);
|
SDL_free(icon_locale);
|
||||||
if ( status ) {
|
if ( status ) {
|
||||||
XSetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
|
XSetTextProperty(SDL_Display, WMwindow, &iconprop, XA_WM_ICON_NAME);
|
||||||
XFree(iconprop.value);
|
XFree(iconprop.value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue