Opened 5 years ago

Closed 19 months ago

Last modified 19 months ago

#5666 closed bug (worksforme)

Can't use writeFile to write unicode characters.

Reported by: tsou Owned by: ekmett
Priority: normal Milestone:
Component: Core Libraries Version: 7.4.2
Keywords: unicode writeFile Cc:
Operating System: OpenBSD Architecture: x86_64 (amd64)
Type of failure: Runtime crash Test Case:
Blocked By: Blocking:
Related Tickets: #8118 Differential Rev(s):
Wiki Page:

Description

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.

Change History (10)

comment:1 Changed 5 years ago by igloo

difficulty: Unknown
Milestone: 7.6.1
Status: newinfoneeded

What exactly do you mean by 'the "locale" environmental variables'?

Also, do you have a "locale" program? If so, what is the output when you run it?

comment:2 Changed 4 years ago by igloo

Milestone: 7.6.17.6.2

comment:3 Changed 4 years ago by igloo

Resolution: worksforme
Status: infoneededclosed

No response from submitter, so closing.

comment:4 Changed 4 years ago by tsou

Keywords: unicode writeFile added
Resolution: worksforme
Status: closednew
Version: 7.0.47.4.2

What exactly do you mean by 'the "locale" environmental variables'?

I meant LANG and LC_ALL, etc.

Also, do you have a "locale" program? If so, what is the output when you run it?

There's no locale program. Only a setlocale(3) function.. http://www.openbsd.org/cgi-bin/man.cgi?query=setlocale&apropos=0&sektion=0&manpath=OpenBSD+Current&arch=i386&format=html

Usually, applications (for example tmux, mutt, etc.) that may need to output unicode characters, understand the locale by reading those enviromental variables I mentioned above. I thought it would work like that with haskell, but I was wrong.

Let me know if you need anything else.

Thanks!

comment:5 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:6 Changed 2 years ago by thoughtpolice

Component: libraries (other)Core Libraries
Owner: set to ekmett

Moving over to new owning component 'Core Libraries'.

comment:7 Changed 2 years ago by thomie

Cc: core-libraries-committee@… added
Status: newinfoneeded

Can anyone on OpenBSD confirm this is still a problem with GHC 7.8.3?

comment:8 Changed 2 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:9 in reply to:  7 Changed 19 months ago by thomie

Resolution: worksforme
Status: infoneededclosed

Can anyone on OpenBSD confirm this is still a problem with GHC 7.8.3?

No response. Closing again.

comment:10 Changed 19 months ago by thomie

Cc: core-libraries-committee@… removed
Milestone: 7.12.1

Please comment in #8118 if this is still a problem.

Note: See TracTickets for help on using tickets.