diff options
Diffstat (limited to 'glib')
-rw-r--r-- | glib/glib.h | 2 | ||||
-rw-r--r-- | glib/gutils.c | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/glib/glib.h b/glib/glib.h index ea31dbb22..d585282b9 100644 --- a/glib/glib.h +++ b/glib/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 diff --git a/glib/gutils.c b/glib/gutils.c index 09646ccb5..f09715ac2 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -72,6 +72,10 @@ # 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 +} |