diff options
author | pho@cielonegro.org <unknown> | 2010-05-19 01:31:12 +0000 |
---|---|---|
committer | pho@cielonegro.org <unknown> | 2010-05-19 01:31:12 +0000 |
commit | 264ffc73e6ded49d87ac65f18838273d91aa304e (patch) | |
tree | 51ab751a0b0ebc2483508ed25e049d80b50631ee /libraries/base/cbits/PrelIOUtils.c | |
parent | 0771aab9fdea7dab8607203f5a531df1a0ce89de (diff) | |
download | haskell-264ffc73e6ded49d87ac65f18838273d91aa304e.tar.gz |
Use libcharset instead of nl_langinfo(CODESET) if possible.
nl_langinfo(CODESET) doesn't always return standardized variations of the encoding names. Use libcharset if possible, which is shipped together with GNU libiconv.
Diffstat (limited to 'libraries/base/cbits/PrelIOUtils.c')
-rw-r--r-- | libraries/base/cbits/PrelIOUtils.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/libraries/base/cbits/PrelIOUtils.c b/libraries/base/cbits/PrelIOUtils.c index b910c28de2..f43f5d8a64 100644 --- a/libraries/base/cbits/PrelIOUtils.c +++ b/libraries/base/cbits/PrelIOUtils.c @@ -24,13 +24,27 @@ 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 <langinfo.h> -char *localeEncoding (void) +#if defined(HAVE_LIBCHARSET) +# include <libcharset.h> +#elif defined(HAVE_LANGINFO_H) +# include <langinfo.h> +#endif + +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 /* __GLASGOW_HASKELL__ */ |