From d518059ada3498f070e462f77322ba5ca0c42018 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 14 Oct 2010 22:22:45 +0200 Subject: [PATCH] Use locale_charset() from iconv which will use nl_langinfo (CODESET) anyways but it will do canonicalization so we will get the correct charset name, because nl_langinfo (CODESET) can return different things on different systems. This at least fixes OpenBSD. --- eglib/configure.ac | 2 +- eglib/src/gunicode.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eglib/configure.ac b/eglib/configure.ac index 0d9de69c7803..39aa42816c22 100644 --- a/eglib/configure.ac +++ b/eglib/configure.ac @@ -114,7 +114,7 @@ if test "x$have_iso_varargs" = "xyes"; then fi AC_SUBST(G_HAVE_ISO_VARARGS) -AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h) +AC_CHECK_HEADERS(getopt.h sys/time.h sys/wait.h pwd.h iconv.h localcharset.h) if test $ac_cv_sizeof_void_p != $ac_cv_sizeof_int; then GPOINTER_TO_INT="((gint)(long) (ptr))" diff --git a/eglib/src/gunicode.c b/eglib/src/gunicode.c index af1177444649..3e322b28c304 100644 --- a/eglib/src/gunicode.c +++ b/eglib/src/gunicode.c @@ -53,6 +53,9 @@ # ifdef HAVE_ICONV_H # include # endif +# ifdef HAVE_LOCALCHARSET_H +# include +# endif #endif static char *my_charset; @@ -303,8 +306,8 @@ g_get_charset (G_CONST_RETURN char **charset) #else if (my_charset == NULL){ /* These shouldn't be heap allocated */ -#if HAVE_LANGINFO_H - my_charset = nl_langinfo (CODESET); +#if HAVE_LOCALCHARSET_H + my_charset = locale_charset (); #else my_charset = "UTF-8"; #endif