From b60f5cf11bb91165d248dfdbf6546dcf4c353f8e Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 21 Feb 2008 13:07:49 +0000 Subject: [PATCH] glib/gutf8.c (g_get_charset) glib/gconvert.c (g_locale_from_utf8) Clarify 2008-02-21 Tor Lillqvist * glib/gutf8.c (g_get_charset) * glib/gconvert.c (g_locale_from_utf8) * docs/reference/glib/running.sgml: Clarify character set issues on Windows. svn path=/trunk/; revision=6551 --- ChangeLog | 6 ++++++ docs/reference/ChangeLog | 4 ++++ docs/reference/glib/running.sgml | 16 ++++++++++++++++ glib/gconvert.c | 3 ++- glib/gutf8.c | 6 ++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f246840..09f20ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-02-21 Tor Lillqvist + + * glib/gutf8.c (g_get_charset) + * glib/gconvert.c (g_locale_from_utf8): Clarify character set + issues on Windows. + 2008-02-20 Tor Lillqvist * glib/gtestutils.c (g_test_trap_fork) [Win32]: Change the diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 35dc6fd..08be3c0 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2008-02-21 Tor Lillqvist + + * glib/running.sgml: Clarify character set issues on Windows. + 2008-02-13 Ryan Lortie * gio/gio-sections.txt: add G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT diff --git a/docs/reference/glib/running.sgml b/docs/reference/glib/running.sgml index a8952d2..c4060c2 100644 --- a/docs/reference/glib/running.sgml +++ b/docs/reference/glib/running.sgml @@ -214,6 +214,22 @@ call setlocale (LC_ALL, "") to set up the current locale. + +On Windows, in a C program there are several locale concepts +that not necessarily are synchronized. On one hand, there is the +system default ANSI code-page, which determines what encoding is used +for file names handled by the C library's functions and the Win32 +API. (We are talking about the "narrow" functions here that take +character pointers, not the "wide" ones.) + + + +On the other hand, there is the C library's current locale. The +character set (code-page) used by that is not necessarily the same as +the system default ANSI code-page. Strings in this character set are +returned by functions like strftime. + + diff --git a/glib/gconvert.c b/glib/gconvert.c index 4a6f010..e6fd8bd 100644 --- a/glib/gconvert.c +++ b/glib/gconvert.c @@ -1098,7 +1098,8 @@ g_locale_to_utf8 (const gchar *opsysstring, * * Converts a string from UTF-8 to the encoding used for strings by * the C runtime (usually the same as that used by the operating - * system) in the current locale. + * system) in the current locale. On + * Windows this means the system codepage. * * Return value: The converted string, or %NULL on an error. **/ diff --git a/glib/gutf8.c b/glib/gutf8.c index 2676c41..9e0d955 100644 --- a/glib/gutf8.c +++ b/glib/gutf8.c @@ -510,6 +510,12 @@ charset_cache_free (gpointer data) * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8() * are nice shortcuts, though.) * + * On Windows the character set returned by this function is the + * so-called system default ANSI code-page. That is the character set + * used by the "narrow" versions of C library and Win32 functions that + * handle file names. It might be different from the character set + * used by the C library's current locale. + * * The return value is %TRUE if the locale's encoding is UTF-8, in that * case you can perhaps avoid calling g_convert(). * -- 2.7.4