X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=cbits%2FPrelIOUtils.c;h=9e05f08396be7df894733564fd449263b4458f5a;hb=7b2cb5626544e89431b8fbc42ab3eca072913b23;hp=b910c28de2bbce25c9c9db21d73d3a7debaad009;hpb=428b6c66cd56f0a56fa118d3ac4ca3eacbf73320;p=ghc-base.git diff --git a/cbits/PrelIOUtils.c b/cbits/PrelIOUtils.c index b910c28..9e05f08 100644 --- a/cbits/PrelIOUtils.c +++ b/cbits/PrelIOUtils.c @@ -24,12 +24,28 @@ void debugBelch2(const char*s, char *t) debugBelch(s,t); } -// Use a C wrapper for this because we avoid hsc2hs in base -#if HAVE_LANGINFO_H -#include -char *localeEncoding (void) +#if defined(HAVE_LIBCHARSET) +# include +#elif defined(HAVE_LANGINFO_H) +# include +#endif + +#if !defined(mingw32_HOST_OS) +const char* localeEncoding(void) { +#if defined(HAVE_LIBCHARSET) + return locale_charset(); + +#elif defined(HAVE_LANGINFO_H) return nl_langinfo(CODESET); + +#else +#warning Depending on the unportable behavior of GNU iconv due to absence of both libcharset and langinfo.h + /* GNU iconv accepts "" to mean the current locale's + * encoding. Warning: This isn't portable. + */ + return ""; +#endif } #endif