Use GetACP to get the current ANSI codepage.
authorTor Lillqvist <tml@iki.fi>
Sun, 17 Dec 2000 18:43:57 +0000 (18:43 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sun, 17 Dec 2000 18:43:57 +0000 (18:43 +0000)
2000-12-17  Tor Lillqvist  <tml@iki.fi>

* gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
the current ANSI codepage.

* gunicode.h: Add comment that the static string g_get_charset
sets the parameter to point to should be copied in case the
charset might be changed later in the program.

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gunicode.h
glib/gutf8.c
gobject/gobject.def
gunicode.h
gutf8.c

index 10165c0..5906d1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 10165c0..5906d1a 100644 (file)
@@ -1,3 +1,12 @@
+2000-12-17  Tor Lillqvist  <tml@iki.fi>
+
+       * gutf8.c (g_utf8_get_charset_internal): (Win32) Use GetACP to get
+       the current ANSI codepage.
+
+       * gunicode.h: Add comment that the static string g_get_charset
+       sets the parameter to point to should be copied in case the
+       charset might be changed later in the program.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.{mingw,msc}.in: No need to -DGSPAWN_HELPER when
index 6810a21..93f3683 100644 (file)
@@ -105,7 +105,9 @@ typedef enum
 
 /* Returns TRUE if current locale uses UTF-8 charset.  If CHARSET is
  * not null, sets *CHARSET to the name of the current locale's
- * charset.  This value is statically allocated.
+ * charset.  This value is statically allocated, and should be copied
+ * in case the locale's charset will be changed later using setlocale()
+ * or in some other way.
  */
 gboolean g_get_charset (char **charset);
 
index f79ab48..f584080 100644 (file)
 
 #include "glib.h"
 
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
+
 #define UTF8_COMPUTE(Char, Mask, Len)                                        \
   if (Char < 128)                                                            \
     {                                                                        \
@@ -318,8 +322,21 @@ g_utf8_get_charset_internal (char **a)
     }
 #endif
 
+#ifdef G_OS_WIN32
+  if (a && ! *a)
+    {
+      static char codepage[10];
+      
+      sprintf (codepage, "CP%d", GetACP ());
+      *a = codepage;
+      /* What about codepage 1200? Is that UTF-8? */
+      return FALSE;
+    }
+#else
   if (a && ! *a) 
     *a = "US-ASCII";
+#endif
+
   /* Assume this for compatibility at present.  */
   return FALSE;
 }
index 453a401..a2f3bdf 100644 (file)
@@ -86,7 +86,6 @@ EXPORTS
        g_param_value_set_default
        g_param_value_validate
        g_param_values_cmp
-       g_signal_add_emission_hook_full
        g_signal_connect_closure
        g_signal_connect_closure_by_id
        g_signal_connect_data
@@ -112,7 +111,6 @@ EXPORTS
        g_signal_new_valist
        g_signal_parse_name
        g_signal_query
-       g_signal_remove_emission_hook
        g_signal_stop_emission
        g_signal_type_cclosure_new
        g_type_add_class_cache_func
index 6810a21..93f3683 100644 (file)
@@ -105,7 +105,9 @@ typedef enum
 
 /* Returns TRUE if current locale uses UTF-8 charset.  If CHARSET is
  * not null, sets *CHARSET to the name of the current locale's
- * charset.  This value is statically allocated.
+ * charset.  This value is statically allocated, and should be copied
+ * in case the locale's charset will be changed later using setlocale()
+ * or in some other way.
  */
 gboolean g_get_charset (char **charset);
 
diff --git a/gutf8.c b/gutf8.c
index f79ab48..f584080 100644 (file)
--- a/gutf8.c
+++ b/gutf8.c
 
 #include "glib.h"
 
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
+
 #define UTF8_COMPUTE(Char, Mask, Len)                                        \
   if (Char < 128)                                                            \
     {                                                                        \
@@ -318,8 +322,21 @@ g_utf8_get_charset_internal (char **a)
     }
 #endif
 
+#ifdef G_OS_WIN32
+  if (a && ! *a)
+    {
+      static char codepage[10];
+      
+      sprintf (codepage, "CP%d", GetACP ());
+      *a = codepage;
+      /* What about codepage 1200? Is that UTF-8? */
+      return FALSE;
+    }
+#else
   if (a && ! *a) 
     *a = "US-ASCII";
+#endif
+
   /* Assume this for compatibility at present.  */
   return FALSE;
 }