mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-11 13:10:07 +00:00
Must pass the format string to strftime in the C library's locale's
2008-02-21 Tor Lillqvist <tml@novell.com> * gtk/gtkfilechooserdefault.c (list_mtime_data_func) [Win32]: Must pass the format string to strftime in the C library's locale's charset, not the system's. Correspondingly, the return value from strftime() is in the C library's locale's charset. (#509885) svn path=/trunk/; revision=19625
This commit is contained in:
parent
fbe4c4f8b6
commit
7a9bbf551f
@ -1,3 +1,10 @@
|
||||
2008-02-21 Tor Lillqvist <tml@novell.com>
|
||||
|
||||
* gtk/gtkfilechooserdefault.c (list_mtime_data_func) [Win32]: Must
|
||||
pass the format string to strftime in the C library's locale's
|
||||
charset, not the system's. Correspondingly, the return value from
|
||||
strftime() is in the C library's locale's charset. (#509885)
|
||||
|
||||
2008-02-20 Richard Hult <richard@imendio.com>
|
||||
|
||||
* gdk/quartz/gdkwindow-quartz.c: (gdk_window_set_decorations): Set
|
||||
|
@ -73,6 +73,7 @@
|
||||
#if defined (G_OS_UNIX)
|
||||
#include "gtkfilesystemunix.h"
|
||||
#elif defined (G_OS_WIN32)
|
||||
#include <windows.h>
|
||||
#include "gtkfilesystemwin32.h"
|
||||
#endif
|
||||
|
||||
@ -10974,6 +10975,11 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
||||
time_t time_mtime;
|
||||
gchar *date_str = NULL;
|
||||
gboolean sensitive = TRUE;
|
||||
#ifdef G_OS_WIN32
|
||||
const char *locale, *dot = NULL;
|
||||
gint64 codepage = -1;
|
||||
char charset[20];
|
||||
#endif
|
||||
|
||||
impl = data;
|
||||
|
||||
@ -11092,10 +11098,46 @@ list_mtime_data_func (GtkTreeViewColumn *tree_column,
|
||||
format = "%x"; /* Any other date */
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* g_locale_from_utf8() returns a string in the system
|
||||
* code-page, which is not always the same as that used by the C
|
||||
* library. For instance when running a GTK+ program with
|
||||
* LANG=ko on an English version of Windows, the system
|
||||
* code-page is 1252, but the code-page used by the C library is
|
||||
* 949. (It's GTK+ itself that sets the C library locale when it
|
||||
* notices the LANG environment variable. See gtkmain.c The
|
||||
* Microsoft C library doesn't look at any locale environment
|
||||
* variables.) We need to pass strftime() a string in the C
|
||||
* library's code-page. See bug #509885.
|
||||
*/
|
||||
locale = setlocale (LC_ALL, NULL);
|
||||
if (locale != NULL)
|
||||
dot = strchr (locale, '.');
|
||||
if (dot != NULL)
|
||||
{
|
||||
codepage = g_ascii_strtoll (dot+1, NULL, 10);
|
||||
|
||||
/* All codepages should fit in 16 bits AFAIK */
|
||||
if (codepage > 0 && codepage < 65536)
|
||||
{
|
||||
sprintf (charset, "CP%u", (guint) codepage);
|
||||
locale_format = g_convert (format, -1, charset, "UTF-8", NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
|
||||
|
||||
if (strftime (buf, sizeof (buf), locale_format, &tm_mtime) != 0)
|
||||
date_str = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
|
||||
#endif
|
||||
if (locale_format != NULL &&
|
||||
strftime (buf, sizeof (buf), locale_format, &tm_mtime) != 0)
|
||||
{
|
||||
#ifdef G_OS_WIN32
|
||||
/* As above but in opposite direction... */
|
||||
if (codepage > 0 && codepage < 65536)
|
||||
date_str = g_convert (buf, -1, "UTF-8", charset, NULL, NULL, NULL);
|
||||
#else
|
||||
date_str = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
date_str = g_strdup (_("Unknown"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user