setlocale

Tristan Allwood tora at zonetora.co.uk
Thu Mar 13 17:31:34 EDT 2008


Hi,

I've been playing around with hs-curses and utf8, and have discovered
that I need to use an ffi call at the top of my main to
setlocale(LC_ALL, "") in order to get the hscurses bindings to display
utf8-encoded strings correctly.

If I understand correctly, the fact that I need to do this means that
the ghc rts is either not setting the default locale, or is forcing it
to be a c-style one.  With that as my context I'm just wondering:

a) if this is a known issue

b) if there's a known work-around other than rolling your own ffi
    wrapped call (a library function that I'm not aware of)

c) any side effects this might have elsewhere

d) if I'm being stupid and could get this to work by just using env vars

Regards,

Tristan Allwood

21:23:39 - tora at colorado:~
>locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

>ghc -v
Glasgow Haskell Compiler, Version 6.8.2, for Haskell 98, stage 2 booted by GHC version 6.8.1

>uname -a
Linux colorado 2.6.24-1-amd64 #1 SMP Mon Feb 11 13:47:43 UTC 2008 x86_64 GNU/Linux


-- 
Tristan Allwood
PhD Student
Department of Computing
Imperial College London


More information about the Glasgow-haskell-users mailing list