X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=cbits%2FPrelIOUtils.c;h=9e05f08396be7df894733564fd449263b4458f5a;hb=57b9366e5fd3db86719d12b45320e6145b040fa6;hp=cf74a8ea5f24e969b2f931181f6985dbde0d0fbc;hpb=ff82e794381b8ff689aef037ae28454b65b81d94;p=ghc-base.git diff --git a/cbits/PrelIOUtils.c b/cbits/PrelIOUtils.c index cf74a8e..9e05f08 100644 --- a/cbits/PrelIOUtils.c +++ b/cbits/PrelIOUtils.c @@ -5,9 +5,14 @@ */ #define INLINE + +#ifdef __GLASGOW_HASKELL__ +# include "Rts.h" +#endif + #include "HsBase.h" -#include "Stg.h" -#include "RtsMessages.h" + +#ifdef __GLASGOW_HASKELL__ void errorBelch2(const char*s, char *t) { @@ -18,3 +23,30 @@ void debugBelch2(const char*s, char *t) { debugBelch(s,t); } + +#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 + +#endif /* __GLASGOW_HASKELL__ */