7

I am trying to use GHC on wine to build one of my Haskell applications for windows. So far, this works well, but I am stuck running my test suite, which is intended to be run in an UTF8-locale (LANG=C.utf8 for example.)

Unfortunately, under wine, the Haskell runtime always believes I want to use a non-unicode codepage:

$ wine ghc -e 'GHC.IO.Encoding.CodePage.localeEncoding'
CP850
$ LANG=C.utf8 wine ghc -e 'GHC.IO.Encoding.CodePage.localeEncoding'
CP437
$ LC_ALL=C.utf8 wine ghc -e 'GHC.IO.Encoding.CodePage.localeEncoding'
CP437

Besides changing the actual code to set the encoding of all handles: How would I make the Haskell program use UTF-8 (i.e. codepage 65001) here?

Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139

2 Answers2

2

I don't have a Wine/Haskell setup here, so take this with many grains of salt. It looks GHC.IO.Encoding has what might be the right pieces for this:

setLocaleEncoding :: TextEncoding -> IO () 
utf8 :: TextEncoding

You could try making your test programs setLocaleEncoding utf8 before they get going. This isn't quite what you wanted, but if it works it seems easier than setting it separately for each handle.

dfeuer
  • 48,079
  • 5
  • 63
  • 167
  • Thanks. I’d really like something that does not modify the code, so that I’m able to test the program as if it was running on the users’ machine with utf8 enabled. I’ll keep searching. – Joachim Breitner Oct 15 '15 at 21:06
0

I don't know if this works for Wine, but have you tried using the CHCP command to set the current Windows code page?

MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220