Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Haskell programs to assume a UTF8 locale under wine

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?

like image 903
Joachim Breitner Avatar asked Oct 15 '15 19:10

Joachim Breitner


1 Answers

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.

like image 127
dfeuer Avatar answered Nov 13 '22 17:11

dfeuer