[GHC] #5666: Can't use writeFile to write unicode characters.

GHC cvs-ghc at haskell.org
Mon Nov 28 23:51:24 CET 2011


#5666: Can't use writeFile to write unicode characters.
-------------------------------+--------------------------------------------
    Reporter:  tsou            |       Owner:                   
        Type:  bug             |      Status:  new              
    Priority:  normal          |   Component:  libraries (other)
     Version:  7.0.4           |    Keywords:                   
    Testcase:                  |   Blockedby:                   
          Os:  OpenBSD         |    Blocking:                   
Architecture:  x86_64 (amd64)  |     Failure:  Runtime crash    
-------------------------------+--------------------------------------------
 I tried to the "locale" environmental variables to "en_US.utf8",
 but still I cannot write unicode characters.

 source:

 {{{
 main = do
     hSetEncoding stdout utf8
     putStrLn "αρχίδια"
     writeFile "hello.txt" "σκατούλες"

 }}}

 output:

 {{{
 αρχίδια
 commitBuffer: invalid argument (Illegal byte sequence)
 }}}


 without manually hSetEncoding stdin, putStrLn also
 fails with the same error message.

 From what I was told on #haskell, on linux ghc
 uses setlocale to figure out what encoding to use,
 but this is not present in OpenBSD.

 Simply making those functions read $LANG (I think)
 would solve this for OpenBSD, but I might be wrong.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5666>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list