#ifndef errno
extern int errno;
#endif
+
+#if HAVE_ICONV
+# include <iconv.h>
+#endif
+
+/* Some systems, like SunOS 4, don't have EILSEQ. On these systems,
+ define EILSEQ to some value other than EINVAL, because our invokers
+ may want to distinguish EINVAL from EILSEQ. */
#ifndef EILSEQ
-# define EILSEQ EINVAL
+# define EILSEQ ENOENT
#endif
#ifndef ENOTSUP
# define ENOTSUP EINVAL
#endif
-#if HAVE_ICONV
-# include <iconv.h>
+#if HAVE_LANGINFO_CODESET && ! USE_INCLUDED_LIBINTL
+# include <langinfo.h>
#endif
#include "unicodeio.h"
if (!initialized)
{
+ const char *charset;
+
+#if USE_INCLUDED_LIBINTL
extern const char *locale_charset PARAMS ((void));
- const char *charset = locale_charset ();
+ charset = locale_charset ();
+#else
+# if HAVE_LANGINFO_CODESET
+ charset = nl_langinfo (CODESET);
+# else
+ charset = "";
+# endif
+#endif
is_utf8 = !strcmp (charset, UTF8_NAME);
#if HAVE_ICONV