"Simon Marlow" <simonmar@microsoft.com> wrote,
I have put RC 14 at
http://www.cse.unsw.edu.au/~chak/haskell/ffi/
including all the feedback on RC13. Please especially have a look at Section 6.3 (Section "CString"), where some of the wording changed.
The spec is silent on how exactly a Haskell Char is translated to a CWchar, and there aren't any conversion functions ala castCharToCCHar / castCCharToChar.
Hmm, should we maybe have a `castCharToCwchar' and `castCwcharToChar'?
So presumably the expected behaviour is that the implementation does its best to translate between Unicode Char and whatever encoding the prevailing C library is using for wchar. Any sensible implementation will be using Unicode for wchar too, so the translation will be a simple no-op, but the C standard doesn't specify this. Older systems will probably have a locale-dependent encoding for wchar. The GNU C library has a slight bug in this regard, too (see previous discussion).
I expect that when we implement the CWString operations for GHC we won't bother with any locale-dependent translations, so the implementation will only work on "sensible" systems.
There is a fair bit that is non-obvious here, so I feel the spec ought to say something.
Yes, I agree. The question is, what do we actually want for the standard? Do we want to restrict the standard to only work for "sensible" systems? If so, what is the proper phrase to identify "sensible" systems? Cheers, Manuel