Joachim Breitner
Joachim Breitner

Reputation: 25782

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?

Upvotes: 8

Views: 760

Answers (2)

MathematicalOrchid
MathematicalOrchid

Reputation: 62868

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

Upvotes: 0

dfeuer
dfeuer

Reputation: 48631

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.

Upvotes: 2

Related Questions