ENDIF(HAVE_NONPOSIX_ICONV_IN_LIBC)
ENDIF(HAVE_POSIX_ICONV_IN_LIBC)
ENDIF(ICONV_INCLUDE_DIR)
+#
+IF(HAVE_POSIX_ICONV_IN_LIBICONV)
+ CHECK_INCLUDE_FILES("localcharset.h" HAVE_LOCALCHARSET_H)
+ CHECK_FUNCTION_EXISTS_GLIBC(locale_charset HAVE_LOCALE_CHARSET)
+ IF(NOT HAVE_LOCALE_CHARSET)
+ FIND_LIBRARY(LIBCHARSET_PATH charset)
+ IF(LIBCHARSET_PATH)
+ SET(CMAKE_REQUIRED_LIBRARIES ${LIBCHARSET_PATH})
+ CHECK_FUNCTION_EXISTS_GLIBC(locale_charset HAVE_LOCALE_CHARSET)
+ IF(HAVE_LOCALE_CHARSET)
+ LIST(APPEND ADDITIONAL_LIBS ${LIBCHARSET_PATH})
+ ENDIF(HAVE_LOCALE_CHARSET)
+ ENDIF(LIBCHARSET_PATH)
+ ENDIF(NOT HAVE_LOCALE_CHARSET)
+ENDIF(HAVE_POSIX_ICONV_IN_LIBICONV)
#
# Find Libxml2
if test "x$with_iconv" != "xno"; then
AC_CHECK_HEADERS([iconv.h])
AM_ICONV
+ if test "x$am_cv_lib_iconv" != "xno"; then
+ AC_CHECK_HEADERS([localcharset.h])
+ am_save_LIBS="$LIBS"
+ LIBS="${LIBS} ${LIBICONV}"
+ AC_CHECK_FUNCS([locale_charset])
+ LIBS="${am_save_LIBS}"
+ if test "x$ac_cv_func_locale_charset" != "xyes"; then
+ # If locale_charset() is not in libiconv, we have to find libcharset.
+ AC_CHECK_LIB(charset,locale_charset)
+ fi
+ fi
fi
AC_ARG_WITH([lzma],
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
+#ifdef HAVE_LOCALCHARSET_H
+#include <localcharset.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
* But iconv on Mac OS 10.6 doesn't seem to handle this correctly;
* on that system, we have to explicitly call nl_langinfo()
* to get the right name. Not sure about other platforms.
+ *
+ * NOTE: GNU libiconv does not recognize the character-set name
+ * which some platform nl_langinfo(CODESET) returns, so we should
+ * use locale_charset() instead of nl_langinfo(CODESET) for GNU libiconv.
*/
static const char *
default_iconv_charset(const char *charset) {
if (charset != NULL && charset[0] != '\0')
return charset;
-#if HAVE_NL_LANGINFO
+#if HAVE_LOCALE_CHARSET
+ return locale_charset();
+#elif HAVE_NL_LANGINFO
return nl_langinfo(CODESET);
#else
return "";