[GHC] #4471: Incorrect Unicode output on Windows Console
GHC
cvs-ghc at haskell.org
Fri Nov 19 16:37:04 EST 2010
#4471: Incorrect Unicode output on Windows Console
-------------------------+--------------------------------------------------
Reporter: sankeld | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.2.1
Component: Compiler | Version: 6.12.3
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Windows | Blocking:
Architecture: x86 | Failure: Incorrect result at runtime
-------------------------+--------------------------------------------------
Comment(by sankeld):
I think I have the bug pinpointed and can explain the behavior of the
original test program.
I've verified that the posix `write` system call (when applied to stdout
where stdout is attached to a console with code page 65001) returns the
number of *characters* written instead of the number of *bytes*. This can
probably be traced to
[http://connect.microsoft.com/VisualStudio/feedback/details/543801
/unicode-issues-with-writefile-and-in-the-crt this issue].
The reasoning for our original output
{{{
∷⇒∀→←⋯⊢ -- outputs correctly, but runtime thinks that 9/15 characters
remain
→←⋯⊢ -- runtime tries to output the remaining characters, but still thinks
characters remain.
⋯⊢ -- ...and so on until a buffer overrun I assume.
∷⇒∀→←⋯⊢→←⋯⊢←⋯⊢⋯⊢⊢⊢⊢<stdout>: hFlush: permission denied (Permission denied)
}}}
The GHC/IO/FD.hs's fdWrite function source confirms this behavior.
An ugly solution, if we want to work around this write bug, would be to
check, upon write, if this is a 65001 console (not piped to a file). If
so, treat the return value of write as a number of characters instead of a
number of bytes.
Arg.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4471#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list