Add function to get the codeset name for the current locale.
authorOwen Taylor <otaylor@redhat.com>
Mon, 29 May 2000 18:48:29 +0000 (18:48 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 29 May 2000 18:48:29 +0000 (18:48 +0000)
Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>

* gutils.c (g_locale_get_codeset): Add function to get the
codeset name for the current locale.

* configure.in acconfig.h: Add check for nl_langinfo(CODESET);

14 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
acconfig.h
configure.in
glib.h
glib/glib.h
glib/gutils.c
gutils.c

index 79c419a..ba5352d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 79c419a..ba5352d 100644 (file)
@@ -1,3 +1,10 @@
+Mon May 29 14:10:35 2000  Owen Taylor  <otaylor@redhat.com>
+
+       * gutils.c (g_locale_get_codeset): Add function to get the 
+       codeset name for the current locale.
+
+       * configure.in acconfig.h: Add check for nl_langinfo(CODESET);
+
 Fri May 19 11:39:29 2000  Tim Janik  <timj@gtk.org>
 
 
index 70d0114..f79d400 100644 (file)
@@ -54,6 +54,7 @@
 #undef GLIB_BYTE_CONTENTS_GRECMUTEX
 
 #undef HAVE_BROKEN_WCTYPE
+#undef HAVE_CODESET
 #undef HAVE_DOPRNT
 #undef HAVE_FLOAT_H
 #undef HAVE_GETPWUID_R
index 2c5af75..d834e59 100644 (file)
@@ -449,6 +449,17 @@ AC_CACHE_VAL(glib_cv_sane_realloc,[
 ])
 AC_MSG_RESULT($glib_cv_sane_realloc)
 
+dnl Check for nl_langinfo and CODESET
+
+AC_MSG_CHECKING([for nl_langinfo (CODESET)])
+AC_TRY_COMPILE([#include <langinfo.h>],
+       [char *codeset = nl_langinfo (CODESET);],
+   AC_DEFINE(HAVE_CODESET)
+   have_codeset=yes,
+   have_codeset=no)
+
+AC_MSG_RESULT($have_codeset)
+  
 
 dnl **********************
 dnl *** va_copy checks ***
diff --git a/glib.h b/glib.h
index ea31dbb..d585282 100644 (file)
--- a/glib.h
+++ b/glib.h
@@ -1712,6 +1712,8 @@ gchar*    g_get_current_dir       (void);
  * must not be freed. */
 gchar*  g_getenv               (const gchar *variable);
 
+gchar * g_locale_get_codeset    (void);
+
 /* we use a GLib function as a replacement for ATEXIT, so
  * the programmer is not required to check the return value
  * (if there is any in the implementation) and doesn't encounter
index ea31dbb..d585282 100644 (file)
@@ -1712,6 +1712,8 @@ gchar*    g_get_current_dir       (void);
  * must not be freed. */
 gchar*  g_getenv               (const gchar *variable);
 
+gchar * g_locale_get_codeset    (void);
+
 /* we use a GLib function as a replacement for ATEXIT, so
  * the programmer is not required to check the return value
  * (if there is any in the implementation) and doesn't encounter
index 09646cc..f09715a 100644 (file)
 #  include <io.h>
 #endif /* G_OS_WIN32 */
 
+#ifdef HAVE_CODESET
+#include <langinfo.h>
+#endif
+
 const guint glib_major_version = GLIB_MAJOR_VERSION;
 const guint glib_minor_version = GLIB_MINOR_VERSION;
 const guint glib_micro_version = GLIB_MICRO_VERSION;
@@ -756,3 +760,16 @@ g_int_hash (gconstpointer v)
 {
   return *(const gint*) v;
 }
+
+gchar *
+g_locale_get_codeset (void)
+{
+#ifdef HAVE_CODESET  
+  char *result = nl_langinfo (CODESET);
+  return g_strdup (result);
+#else
+  /* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
+   */
+  return g_strdup ("ISO-8859-1");
+#endif
+}
index 09646cc..f09715a 100644 (file)
--- a/gutils.c
+++ b/gutils.c
 #  include <io.h>
 #endif /* G_OS_WIN32 */
 
+#ifdef HAVE_CODESET
+#include <langinfo.h>
+#endif
+
 const guint glib_major_version = GLIB_MAJOR_VERSION;
 const guint glib_minor_version = GLIB_MINOR_VERSION;
 const guint glib_micro_version = GLIB_MICRO_VERSION;
@@ -756,3 +760,16 @@ g_int_hash (gconstpointer v)
 {
   return *(const gint*) v;
 }
+
+gchar *
+g_locale_get_codeset (void)
+{
+#ifdef HAVE_CODESET  
+  char *result = nl_langinfo (CODESET);
+  return g_strdup (result);
+#else
+  /* FIXME: Do something more intelligent based on setlocale (LC_CTYPE, NULL)
+   */
+  return g_strdup ("ISO-8859-1");
+#endif
+}